Add model definitions

This commit is contained in:
Mark Veidemanis 2023-10-17 22:09:05 +01:00
parent 5169f5033c
commit cbca55ff49
Signed by: m
GPG Key ID: 5ACFCEED46C0904F
1 changed files with 127 additions and 0 deletions

View File

@ -6,6 +6,53 @@ from django.db import models
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
SITE_CHOICES = (
("5HT2C", "5-HT2C"),
("5HT2A", "5-HT2A"),
("GABAB", "GABAB"),
("NMDA", "NMDA"),
)
MECHANISM_CHOICES = (
("AGONISM", "Agonism"),
("ANTAGONISM", "Antagomism"),
("MODULATION", "Modulation"),
)
SOURCE_TYPE_CHOICES = (
("PSITE", "Professional pharmaceutical data repository"),
("DWIKI", "Dedicated peer-reviewed community wiki"),
("CWIKI", "Peer-reviewed community wiki"),
("WIKI", "Private wiki"),
("DFORUM", "Dedicated community forum"),
("FORUM", "Community forum"),
)
DOSAGE_UNIT_CHOICES = (
("mg", "mg"),
("g", "g"),
("ug", "ug"),
)
DOSAGE_TIMING_CHOICES = (
("SECONDS", "Seconds"),
("MINUTES", "Minutes"),
("HOURS", "Hours"),
("DAYS", "Days :D"),
("WEEKS", "Weeks :O"),
("MONTHS", "Months :-|"),
("YEARS", "Years x_X"),
)
SEI_TYPE_CHOICES = (
("PHYSICAL", "Physical"),
("COGNITIVE", "Cognitive"),
("VISUAL", "Visual"),
("AUDITORY", "Auditory"),
("MULTISENSORY", "Multi-sensory"),
("TRANSPERSONAL", "Transpersonal"),
)
class User(AbstractUser): class User(AbstractUser):
# Stripe customer ID # Stripe customer ID
@ -31,6 +78,86 @@ class NotificationSettings(models.Model):
return f"Notification settings for {self.user}" return f"Notification settings for {self.user}"
class Source(models.Model):
name = models.CharField(max_length=255, unique=True)
type = models.CharField(max_length=255, choices=SOURCE_TYPE_CHOICES)
endpoint = models.CharField(max_length=1024, blank=True, null=True)
score = models.IntegerField(blank=True)
class Entry(models.Model):
source = models.ForeignKey(Source)
slug = models.CharField(max_length=1024)
class Dosage(models.Model):
entry = models.ForeignKey("core.Entry")
unit = models.CharField(max_length=255, choices=DOSAGE_UNIT_CHOICES)
threshold = models.IntegerField()
light = models.IntegerField()
common = models.IntegerField()
strong = models.IntegerField()
heavy = models.IntegerField()
class Timing(models.Model):
entry = models.ForeignKey("core.Entry")
unit = models.CharField(
max_length=255, choices=DOSAGE_TIMING_CHOICES, default="HOURS"
)
onset = models.IntegerField()
comeup = models.IntegerField()
peak = models.IntegerField()
total = models.IntegerField()
class SEI(models.Model):
"""
Subjective Effect Index from Psychonaut Wiki.
"""
type = models.CharField(
max_length=255, choices=SEI_TYPE_CHOICES, default="PHYSICAL"
)
description = models.CharField(max_length=4096, blank=True, null=True)
class Effect(models.Model):
entry = models.ForeignKey("core.Entry")
subjective_effects = models.ManyToManyField(SEI)
class Action(models.Model):
"""
Site action record for a drug.
"""
site = models.CharField(max_length=255, choices=SITE_CHOICES)
mechanism = models.CharField(max_length=255, choices=MECHANISM_CHOICES)
affinity = models.IntegerField(blank=True)
class Drug(models.Model):
"""
Model of a drug. Not open to interpretation.
"""
# Lysergic acid diethylamide, Phenibut
name = models.CharField(max_length=255, unique=True)
# Psychedelic, Sedative
drug_class = models.CharField(max_length=255)
# LSD
common_name = models.CharField(max_length=1024, unique=True)
links = models.ManyToManyField(Entry)
dosages = models.ManyToManyField(Dosage)
timings = models.ManyToManyField(Timing)
effects = models.ManyToManyField(Effect)
actions = models.ManyToManyField(Action)
# class Perms(models.Model): # class Perms(models.Model):
# class Meta: # class Meta:
# permissions = ( # permissions = (