diff --git a/prefix/__init__.py b/prefix/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/prefix/admin.py b/prefix/admin.py new file mode 100644 index 00000000..14176112 --- /dev/null +++ b/prefix/admin.py @@ -0,0 +1,7 @@ +"""Prefix Admin Pannel +""" + +from django.contrib import admin +from prefix.models import Prefix + +admin.site.register(Prefix) \ No newline at end of file diff --git a/prefix/apis.py b/prefix/apis.py new file mode 100644 index 00000000..e69de29b diff --git a/prefix/apps.py b/prefix/apps.py new file mode 100644 index 00000000..e69de29b diff --git a/prefix/migrations/__init__.py b/prefix/migrations/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/prefix/models.py b/prefix/models.py new file mode 100644 index 00000000..c40dd5af --- /dev/null +++ b/prefix/models.py @@ -0,0 +1,18 @@ +from django.db import models +from django.contrib.auth.models import Group, User +from django.utils import timezone + +class Prefix(models.Model): + """ + """ + + prefix = models.CharField(primary_key=True, max_length=5) + certifying_key = models.TextField(blank=True, null=True) + created = models.DateTimeField(default=timezone.now, blank=True, null=True) + description = models.TextField(blank=True, null=True) + owner = models.ForeignKey(User, on_delete=models.CASCADE, to_field="username") + authorized_groups = models.ManyToManyField(Group, blank=True, related_name='authorized_prefix') + + def __str__(self): + """String for representing the BCO model (in Admin site etc.).""" + return f"{self.prefix}" \ No newline at end of file diff --git a/prefix/selectors.py b/prefix/selectors.py new file mode 100644 index 00000000..07c0d64c --- /dev/null +++ b/prefix/selectors.py @@ -0,0 +1,7 @@ + + +def is_accessible_by(self, user): + """If no authorized_groups are specified, it's accessible by everyone""" + if self.authorized_users.exists(): + return self.authorized_users.filter(id=user.id).exists() + return True \ No newline at end of file diff --git a/prefix/services.py b/prefix/services.py new file mode 100644 index 00000000..e69de29b diff --git a/prefix/urls.py b/prefix/urls.py new file mode 100644 index 00000000..14176112 --- /dev/null +++ b/prefix/urls.py @@ -0,0 +1,7 @@ +"""Prefix Admin Pannel +""" + +from django.contrib import admin +from prefix.models import Prefix + +admin.site.register(Prefix) \ No newline at end of file