-
-
Notifications
You must be signed in to change notification settings - Fork 91
Expand file tree
/
Copy pathmodels.py
More file actions
82 lines (58 loc) · 2.12 KB
/
models.py
File metadata and controls
82 lines (58 loc) · 2.12 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
from django.contrib.auth.models import Group as AbstractGroup
from django.core.validators import RegexValidator
from django.db import models
from organizations.abstract import (
AbstractOrganization,
AbstractOrganizationInvitation,
AbstractOrganizationOwner,
AbstractOrganizationUser,
)
from openwisp_users.base.models import (
AbstractUser,
BaseGroup,
BaseOrganization,
BaseOrganizationOwner,
BaseOrganizationUser,
)
class DetailsModel(models.Model):
"""
You do not need to copy this model in your
application it is only for testing purposes.
This field serves no purpose, it only serves as an example
for extending models and used for testing purposes.
It will be inherited by all the models.
"""
details = models.CharField(max_length=64, blank=True, null=True)
class Meta:
abstract = True
class User(DetailsModel, AbstractUser):
# Remember to set `blank=False` if you don't want your users to
# skip filling this information.
social_security_number = models.CharField(
max_length=11,
null=True,
blank=True,
validators=[RegexValidator(r"^\d\d\d-\d\d-\d\d\d\d$")],
)
class Meta(AbstractUser.Meta):
abstract = False
class Organization(DetailsModel, BaseOrganization, AbstractOrganization):
pass
class OrganizationUser(DetailsModel, BaseOrganizationUser, AbstractOrganizationUser):
pass
class OrganizationOwner(DetailsModel, BaseOrganizationOwner, AbstractOrganizationOwner):
pass
# only needed for django-organizations~=2.x
class OrganizationInvitation(AbstractOrganizationInvitation):
pass
class Group(DetailsModel, BaseGroup, AbstractGroup):
pass
#########################################
# You do not need to copy the following in
# your application it is only for module
# testing purposes.
#########################################
class UserInlineModel(DetailsModel, models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE)
class OrganizationInlineModel(DetailsModel, models.Model):
organization = models.OneToOneField(Organization, on_delete=models.CASCADE)