Skip to content

Commit

Permalink
update to wikidata representation functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
stuchalk committed Dec 4, 2024
1 parent 2cb75a0 commit 5e26ff7
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 17 deletions.
12 changes: 11 additions & 1 deletion dashboard/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from wdfunctions import *


choice = 'wdq'
choice = 'wdc'

local = timezone("America/New_York")

Expand Down Expand Up @@ -773,3 +773,13 @@
# print(quant)
else:
print("already added " + quant['name'])

# check wdquants data against the quantities data
if choice == 'wdqchk':
qs = Wdquants.objects.all().values('quant', 'sect')
for q in qs:
if q['quant'] and q['sect']:
found = Quantities.objects.filter(id=q['quant'], iso_item=q['sect'])
if not found:
print(q)
exit()
23 changes: 23 additions & 0 deletions dashboard/functions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import os
import django

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "umisconfig.settings")
django.setup()

from dashboard.repsys_ingest import *
from datetime import date, datetime
from units.functions import *
from wdfunctions import *


def movereps(sys):
repids = {"qudt": 10}
reps = Wdunits.objects.filter(qudt__isnull=False).order_by('qudt').values_list('qudt', flat=True)
repid = repids[sys]
for rep in reps:
rs = Representations.objects.filter(repsystem__id=repid).values('id', 'strng__string')
print(rs)
exit()


movereps("qudt")
3 changes: 2 additions & 1 deletion templates/units/newindex.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ <h2 class="left">Units of Measurement <small>(by Quantity Kind)</small></h2>
<td><b>{{ key }}</b>:
<span class="units">
{% for unit in units %}
<a class="unit item" data-content="{{ unit.name|lower }}" href="/units/newview/{{ unit.id }}"> {{ unit.name }} </a>
<a class="unit item" data-content="{{ unit.name|lower }}" href="/units/newview/{{ unit.id }}">
{% if forloop.counter > 1 %}•{% endif %} {{ unit.name }}</a>
{% endfor %}
</span>
</td>
Expand Down
31 changes: 16 additions & 15 deletions units/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,21 +195,6 @@ class Meta:
db_table = 'encodings'


class Representations(models.Model):
unit = models.ForeignKey(Units, on_delete=models.PROTECT, db_column='unit_id')
repsystem = models.ForeignKey(Repsystems, on_delete=models.PROTECT, db_column='repsystem_id')
strng = models.ForeignKey(Strngs, on_delete=models.PROTECT, db_column='strng_id')
url_endpoint = models.CharField(max_length=3, blank=True, null=True)
status = models.CharField(max_length=7, blank=True, null=True)
checked = models.CharField(max_length=3)
updated = models.DateTimeField()

class Meta:
managed = False
db_table = 'representations'
unique_together = (('unit_id', 'repsystem_id', 'strng_id'),)


class Prefixes(models.Model):
name = models.CharField(max_length=32, db_collation='utf8_unicode_ci')
symbol = models.CharField(max_length=64, db_collation='utf8_unicode_ci')
Expand Down Expand Up @@ -387,3 +372,19 @@ class Meta:
managed = False
db_table = 'wdquants'
db_table_comment = 'Table of wikidata quantities'


class Representations(models.Model):
unit = models.ForeignKey(Units, on_delete=models.PROTECT, db_column='unit_id')
wdunit = models.ForeignKey(Wdunits, on_delete=models.PROTECT, db_column='wdunit_id')
repsystem = models.ForeignKey(Repsystems, on_delete=models.PROTECT, db_column='repsystem_id')
strng = models.ForeignKey(Strngs, on_delete=models.PROTECT, db_column='strng_id')
url_endpoint = models.CharField(max_length=3, blank=True, null=True)
status = models.CharField(max_length=7, blank=True, null=True)
checked = models.CharField(max_length=3)
updated = models.DateTimeField()

class Meta:
managed = False
db_table = 'representations'
unique_together = (('unit_id', 'repsystem_id', 'strng_id'),)

0 comments on commit 5e26ff7

Please sign in to comment.