-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathrdm_addons.py
More file actions
52 lines (38 loc) · 2.38 KB
/
rdm_addons.py
File metadata and controls
52 lines (38 loc) · 2.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# -*- coding: utf-8 -*-
from django.db import models
from osf.models.base import BaseModel
from osf.models import Institution, AbstractNode
from osf.models.external import ExternalAccount
from osf.utils.datetime_aware_jsonfield import DateTimeAwareJSONField
# see admin.rdm_addons.utils.get_rdm_addon_option
class CommonMixin(object):
def get_one_external_account(self):
if not self.external_accounts.exists():
return None
return self.external_accounts.first()
class RdmAddonOption(BaseModel, CommonMixin):
provider = models.CharField(max_length=50, blank=False, null=False, db_index=True)
is_forced = models.BooleanField(default=False)
is_allowed = models.BooleanField(default=True)
management_node = models.ForeignKey(AbstractNode, blank=True, null=True, default=None, on_delete=models.CASCADE,
related_name='management_rdm_addon_option_set')
organizational_node = models.ForeignKey(AbstractNode, blank=True, null=True, default=None, on_delete=models.CASCADE,
related_name='organizational_rdm_addon_option_set')
# カラム追加
admin_notes = models.CharField(max_length=500, blank=True, null=True)
institution = models.ForeignKey(Institution, blank=False, null=False)
external_accounts = models.ManyToManyField(ExternalAccount, blank=True)
extended = DateTimeAwareJSONField(default=dict, blank=True)
class Meta:
unique_together = (('provider', 'institution'),)
class RdmAddonNoInstitutionOption(BaseModel, CommonMixin):
provider = models.CharField(max_length=50, blank=False, null=False, unique=True, db_index=True)
is_forced = models.BooleanField(default=False)
is_allowed = models.BooleanField(default=True)
management_node = models.ForeignKey(AbstractNode, blank=True, null=True, default=None, on_delete=models.CASCADE,
related_name='management_rdm_addon_no_institution_option_set')
organizational_node = models.ForeignKey(AbstractNode, blank=True, null=True, default=None, on_delete=models.CASCADE,
related_name='organizational_rdm_addon_no_institution_option_set')
# カラム追加
admin_notes = models.CharField(max_length=500, blank=True, null=True)
external_accounts = models.ManyToManyField(ExternalAccount, blank=True)