-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changes to be committed: new file: prefix/__init__.py new file: prefix/admin.py new file: prefix/apis.py new file: prefix/apps.py new file: prefix/migrations/__init__.py new file: prefix/models.py new file: prefix/selectors.py new file: prefix/services.py new file: prefix/urls.py
- Loading branch information
1 parent
4cde8dc
commit 2c7366f
Showing
9 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
"""Prefix Admin Pannel | ||
""" | ||
|
||
from django.contrib import admin | ||
from prefix.models import Prefix | ||
|
||
admin.site.register(Prefix) |
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
"""Prefix Admin Pannel | ||
""" | ||
|
||
from django.contrib import admin | ||
from prefix.models import Prefix | ||
|
||
admin.site.register(Prefix) |