Skip to content

Commit

Permalink
Framework for BioCompute model
Browse files Browse the repository at this point in the history
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
  • Loading branch information
HadleyKing committed Mar 14, 2024
1 parent 8fdb62a commit 4cde8dc
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 0 deletions.
Empty file added biocompute/__init__.py
Empty file.
10 changes: 10 additions & 0 deletions biocompute/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
"""BioCompute Object Admin Pannel
"""

from django.contrib import admin
from biocompute.models import Bco

# class BioComputeAdmin(admin.ModelAdmin):
# list_display = ["", ""]

admin.site.register(Bco)
1 change: 1 addition & 0 deletions biocompute/apis.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#biocompute/apis.py
Empty file.
63 changes: 63 additions & 0 deletions biocompute/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/usr/bin/env python3
# biocompute/models.py

import sys
from django.db import models
from django.conf import settings
from django.contrib.auth.models import Group, User
from django.db.models.signals import post_save
from django.dispatch import receiver
from django.utils import timezone
from rest_framework.authtoken.models import Token
from prefix.models import Prefix

STATE_CHOICES = [
("REFERENCED", "referenced"),
("PUBLISHED", "published"),
("DRAFT", "draft"),
("DELETE", "delete")
]

class Bco(models.Model):
"""BioComput Object Model.
Attributes:
-----------
object_id: str
BCO Object Identifier, and primary key
contents: JSONField
BCO JSON contents
authorized_group: ManyToManyField(Group)
String representing the django.contrib.auth.models.Group that 'owns' the object
owner_user = ForeignKey(User)
String representing the django.contrib.auth.models.User that 'owns' the object
prefix: str
Prefix for the BCO
state:str
State of object. REFERENCED, PUBLISHED, DRAFT, and DELETE are currently accepted values.
last_update: DateTime
Date Time object for the last database change to this object
"""

object_id = models.TextField(primary_key=True)
contents = models.JSONField()
prefix = models.ForeignKey(Prefix, on_delete=models.CASCADE, to_field="prefix")
owner = models.ForeignKey(
User,
on_delete=models.CASCADE,
related_name="owned_bcos"
)
authorized_users = models.ManyToManyField(
User,
related_name="authorized_bcos",
blank=True
)
authorized_groups = models.ManyToManyField(Group,blank=True)
state = models.CharField(max_length=20, choices=STATE_CHOICES, default="DRAFT")
last_update = models.DateTimeField()
access_count = models.IntegerField(default=0)

def __str__(self):
"""String for representing the BCO model (in Admin site etc.)."""
return str(self.object_id)
Empty file added biocompute/selectors.py
Empty file.
Empty file added biocompute/services.py
Empty file.
7 changes: 7 additions & 0 deletions biocompute/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# biocompute/urls.py

from django.urls import path

urlpatterns = [

]

0 comments on commit 4cde8dc

Please sign in to comment.