Commit dda876be authored by ibuler's avatar ibuler

[Update] Stash it

parent 51b0fee9
from django.db import models
from django.utils.translation import ugettext_lazy as _
from django.conf import settings
from common.fields import JsonListTextField
from orgs.mixins import OrgModelMixin
class BaseRole(models.Model):
......@@ -13,38 +14,38 @@ class BaseRole(models.Model):
class Meta:
abstract = True
def __str__(self):
return self.name
class Role(BaseRole):
org_id = models.CharField(max_length=36, blank=True, default='',
verbose_name=_("Organization"), db_index=True)
class Role(OrgModelMixin, BaseRole):
pass
class ClusterRole(BaseRole):
non_resource_urls = JsonListTextField()
pass
class Rule(models.Model):
VERBOSE_CHOICES = [
('list', 'List'),
('retrieve', 'Retrieve'),
('create', 'Create'),
('update', 'Update'),
('patch', 'PartialUpdate'),
('delete', 'Delete'),
]
api_groups = JsonListTextField()
resources = JsonListTextField()
resourcesIDs = JsonListTextField()
verbs = JsonListTextField()
apps = JsonListTextField()
resources = JsonListTextField()
resources_ids = JsonListTextField()
non_resource_urls = JsonListTextField()
class BaseRoleBinding(models.Model):
role = models.ForeignKey('Role', on_delete=models.CASCADE)
users = models.ManyToManyField(settings.AUTH_USER_MODEL)
groups = models.ManyToManyField(settings.AUTH_GROUP_MODEL)
date_created = models.DateTimeField(auto_now_add=True)
created_by = models.CharField(max_length=128, blank=True, default='')
class Meta:
abstract = True
class RoleBinding(BaseRoleBinding):
class RoleBinding(OrgModelMixin, BaseRoleBinding):
pass
......
......@@ -8,7 +8,7 @@ from ..utils import get_signer
__all__ = [
'JsonMixin', 'JsonDictMixin', 'JsonListMix', 'JsonTypeMixin',
'JsonMixin', 'JsonDictMixin', 'JsonListMixin', 'JsonTypeMixin',
'JsonCharField', 'JsonTextField', 'JsonListCharField', 'JsonListTextField',
'JsonDictCharField', 'JsonDictTextField', 'EncryptCharField',
'EncryptTextField', 'EncryptMixin',
......@@ -83,18 +83,30 @@ class JsonDictTextField(JsonDictMixin, models.TextField):
description = _("Marshal dict data to text field")
class JsonListMix(JsonTypeMixin):
class JsonListMixin(JsonTypeMixin):
tp = list
class JsonListCharField(JsonListMix, models.CharField):
class JsonStrListMixin(JsonListMixin):
pass
class JsonListCharField(JsonListMixin, models.CharField):
description = _("Marshal list data to char field")
class JsonListTextField(JsonListMix, models.TextField):
class JsonListTextField(JsonListMixin, models.TextField):
description = _("Marshal list data to text field")
class JsonCharField(JsonMixin, models.CharField):
description = _("Marshal data to char field")
class JsonTextField(JsonMixin, models.TextField):
description = _("Marshal data to text field")
class EncryptMixin:
def from_db_value(self, value, expression, connection, context):
if value is not None:
......@@ -117,9 +129,4 @@ class EncryptCharField(EncryptMixin, models.CharField):
super().__init__(*args, **kwargs)
class JsonCharField(JsonMixin, models.CharField):
description = _("Marshal data to char field")
class JsonTextField(JsonMixin, models.TextField):
description = _("Marshal data to text field")
......@@ -64,6 +64,7 @@ INSTALLED_APPS = [
'terminal.apps.TerminalConfig',
'audits.apps.AuditsConfig',
'authentication.apps.AuthenticationConfig', # authentication
'authorization.apps.AuthorizationConfig',
'rest_framework',
'rest_framework_swagger',
'drf_yasg',
......@@ -367,6 +368,7 @@ AUTHENTICATION_BACKENDS = [
# Custom User Auth model
AUTH_USER_MODEL = 'users.User'
AUTH_GROUP_MODEL = 'users.UserGroup'
# File Upload Permissions
FILE_UPLOAD_PERMISSIONS = 0o644
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment