Skip to content

Commit bcf3c4a

Browse files
committed
Framework for BioCompute model
Changes to be committed: new file: biocompute/__init__.py new file: biocompute/admin.py new file: biocompute/apis.py new file: biocompute/migrations/__init__.py new file: biocompute/models.py new file: biocompute/selectors.py new file: biocompute/services.py new file: biocompute/urls.py
1 parent 62142d1 commit bcf3c4a

File tree

8 files changed

+81
-0
lines changed

8 files changed

+81
-0
lines changed

biocompute/__init__.py

Whitespace-only changes.

biocompute/admin.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
"""BioCompute Object Admin Pannel
2+
"""
3+
4+
from django.contrib import admin
5+
from biocompute.models import Bco
6+
7+
# class BioComputeAdmin(admin.ModelAdmin):
8+
# list_display = ["", ""]
9+
10+
admin.site.register(Bco)

biocompute/apis.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#biocompute/apis.py

biocompute/migrations/__init__.py

Whitespace-only changes.

biocompute/models.py

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/usr/bin/env python3
2+
# biocompute/models.py
3+
4+
import sys
5+
from django.db import models
6+
from django.conf import settings
7+
from django.contrib.auth.models import Group, User
8+
from django.db.models.signals import post_save
9+
from django.dispatch import receiver
10+
from django.utils import timezone
11+
from rest_framework.authtoken.models import Token
12+
from prefix.models import Prefix
13+
14+
STATE_CHOICES = [
15+
("REFERENCED", "referenced"),
16+
("PUBLISHED", "published"),
17+
("DRAFT", "draft"),
18+
("DELETE", "delete")
19+
]
20+
21+
class Bco(models.Model):
22+
"""BioComput Object Model.
23+
24+
Attributes:
25+
-----------
26+
object_id: str
27+
BCO Object Identifier, and primary key
28+
contents: JSONField
29+
BCO JSON contents
30+
authorized_group: ManyToManyField(Group)
31+
String representing the django.contrib.auth.models.Group that 'owns' the object
32+
owner_user = ForeignKey(User)
33+
String representing the django.contrib.auth.models.User that 'owns' the object
34+
prefix: str
35+
Prefix for the BCO
36+
state:str
37+
State of object. REFERENCED, PUBLISHED, DRAFT, and DELETE are currently accepted values.
38+
last_update: DateTime
39+
Date Time object for the last database change to this object
40+
41+
"""
42+
43+
object_id = models.TextField(primary_key=True)
44+
contents = models.JSONField()
45+
prefix = models.ForeignKey(Prefix, on_delete=models.CASCADE, to_field="prefix")
46+
owner = models.ForeignKey(
47+
User,
48+
on_delete=models.CASCADE,
49+
related_name="owned_bcos"
50+
)
51+
authorized_users = models.ManyToManyField(
52+
User,
53+
related_name="authorized_bcos",
54+
blank=True
55+
)
56+
authorized_groups = models.ManyToManyField(Group,blank=True)
57+
state = models.CharField(max_length=20, choices=STATE_CHOICES, default="DRAFT")
58+
last_update = models.DateTimeField()
59+
access_count = models.IntegerField(default=0)
60+
61+
def __str__(self):
62+
"""String for representing the BCO model (in Admin site etc.)."""
63+
return str(self.object_id)

biocompute/selectors.py

Whitespace-only changes.

biocompute/services.py

Whitespace-only changes.

biocompute/urls.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# biocompute/urls.py
2+
3+
from django.urls import path
4+
5+
urlpatterns = [
6+
7+
]

0 commit comments

Comments
 (0)