Skip to content

Commit

Permalink
updates to units models and functions code
Browse files Browse the repository at this point in the history
  • Loading branch information
stuchalk committed Jun 20, 2024
1 parent ca3aa04 commit 8fec1f4
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
9 changes: 9 additions & 0 deletions units/functions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from pytz import timezone
from datetime import datetime


def getds():
est = timezone('US/Eastern')
local = est.localize(datetime.now())
fmt = '%Y-%m-%d %H:%M:%S %z'
return local.strftime(fmt)
19 changes: 17 additions & 2 deletions units/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ class Quantitysystems(models.Model):
class Meta:
managed = False
db_table = 'quantitysystems'
db_table_comment = 'Table of systems of quanitites (e.g. SI)'
app_label = 'quantitysystems'


class Dimensionvectors(models.Model):
Expand Down Expand Up @@ -115,6 +117,7 @@ class Quantities(models.Model):
quantitysystem = models.ForeignKey(Quantitysystems, on_delete=models.PROTECT, db_column='quantitysystem_id')
name = models.CharField(max_length=128)
altnames = models.CharField(max_length=512)
sysnames = models.CharField(max_length=512, blank=True, null=True)
description = models.CharField(max_length=1024, blank=True, null=True)
symbol = models.CharField(max_length=128, blank=True, null=True)
latexsymbol = models.CharField(max_length=512, blank=True, null=True)
Expand Down Expand Up @@ -155,6 +158,7 @@ class Repsystems(models.Model):
fileupdated = models.DateField()
fileformat = models.CharField(max_length=8, blank=True, null=True)
checked = models.DateTimeField()
rawdata = models.TextField(blank=True, null=True)
jsondata = models.TextField(blank=True, null=True)
updated = models.DateTimeField()

Expand Down Expand Up @@ -291,7 +295,7 @@ class Entities(models.Model):
source = models.CharField(max_length=32, blank=True, null=True)
comment = models.CharField(max_length=1024, blank=True, null=True)
migrated = models.CharField(max_length=3, blank=True, null=True)
lastupdate = models.DateField(blank=True, null=True)
lastcheck = models.DateField(blank=True, null=True)
updated = models.DateTimeField()

class Meta:
Expand All @@ -302,8 +306,19 @@ class Meta:
class QuantitykindsUnits(models.Model):
quantitykind = models.ForeignKey(Quantitykinds, on_delete=models.PROTECT, db_column='quantitykind_id')
unit = models.ForeignKey(Units, on_delete=models.PROTECT, db_column='unit_id')
updated = models.DateTimeField()
updated = models.DateTimeField(null=True)

class Meta:
managed = False
db_table = 'quantitykinds_units'


class EntitiesQuantities(models.Model):
entity = models.ForeignKey(Entities, on_delete=models.PROTECT, db_column='entity_id')
quantity = models.ForeignKey(Units, on_delete=models.PROTECT, db_column='quantity_id')
updated = models.DateTimeField()

class Meta:
managed = False
db_table = 'entities_quantities'
db_table_comment = 'Table of quantities associated to unit entities'

0 comments on commit 8fec1f4

Please sign in to comment.