Skip to content

Commit

Permalink
Merge pull request #515 from xchem/m2ms-1277-tags
Browse files Browse the repository at this point in the history
Site observation tags (1277)
  • Loading branch information
kaliif authored Feb 5, 2024
2 parents a0e16c9 + f324610 commit c6cb1e1
Show file tree
Hide file tree
Showing 9 changed files with 303 additions and 23 deletions.
2 changes: 2 additions & 0 deletions viewer/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ def filter_qs(self):
"experiment",
"experiment__experiment_upload",
"experiment__experiment_upload__target",
"cmpd",
).annotate(
target=F("experiment__experiment_upload__target"),
compound_code=F("cmpd__compound_code"),
)

return qs
Expand Down
39 changes: 39 additions & 0 deletions viewer/migrations/0038_auto_20240202_1030.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Generated by Django 3.2.23 on 2024-02-02 10:30

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
('viewer', '0037_rename_event_map_info_experiment_map_info'),
]

operations = [
migrations.AddField(
model_name='historicalsiteobservation',
name='longcode',
field=models.TextField(null=True),
),
migrations.AddField(
model_name='siteobservation',
name='longcode',
field=models.TextField(null=True),
),
migrations.AddField(
model_name='xtalformsite',
name='xtalform_site_num',
field=models.IntegerField(
help_text='numeric xtalform site id (enumerated on creation)', null=True
),
),
migrations.AlterField(
model_name='historicalsiteobservation',
name='code',
field=models.TextField(null=True),
),
migrations.AlterField(
model_name='siteobservation',
name='code',
field=models.TextField(null=True),
),
]
19 changes: 19 additions & 0 deletions viewer/migrations/0039_canonsite_canon_site_num.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 3.2.23 on 2024-02-02 11:35

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
('viewer', '0038_auto_20240202_1030'),
]

operations = [
migrations.AddField(
model_name='canonsite',
name='canon_site_num',
field=models.IntegerField(
help_text='numeric canon site id (enumerated on creation)', null=True
),
),
]
19 changes: 19 additions & 0 deletions viewer/migrations/0040_quatassembly_assembly_num.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 3.2.23 on 2024-02-02 11:47

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
('viewer', '0039_canonsite_canon_site_num'),
]

operations = [
migrations.AddField(
model_name='quatassembly',
name='assembly_num',
field=models.IntegerField(
help_text='numeric assembly id (enumerated on creation)', null=True
),
),
]
19 changes: 19 additions & 0 deletions viewer/migrations/0041_xtalform_xtalform_num.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 3.2.23 on 2024-02-05 11:27

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
('viewer', '0040_quatassembly_assembly_num'),
]

operations = [
migrations.AddField(
model_name='xtalform',
name='xtalform_num',
field=models.IntegerField(
help_text='numeric xtalform id (enumerated on creation)', null=True
),
),
]
20 changes: 20 additions & 0 deletions viewer/migrations/0042_alter_xtalformsite_xtalform_site_num.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Generated by Django 3.2.23 on 2024-02-05 12:02

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
('viewer', '0041_xtalform_xtalform_num'),
]

operations = [
migrations.AlterField(
model_name='xtalformsite',
name='xtalform_site_num',
field=models.TextField(
help_text='alphabetic xtalform site id (enumerated on creation)',
null=True,
),
),
]
16 changes: 15 additions & 1 deletion viewer/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,9 @@ class Meta:
class QuatAssembly(models.Model):
chains = models.TextField()
name = models.TextField()
assembly_num = models.IntegerField(
null=True, help_text="numeric assembly id (enumerated on creation)"
)

objects = models.Manager()
filter_manager = QuatAssemblyDataManager()
Expand All @@ -301,6 +304,9 @@ class Xtalform(models.Model):
through="XtalformQuatAssembly",
through_fields=("xtalform", "quat_assembly"),
)
xtalform_num = models.IntegerField(
null=True, help_text="numeric xtalform id (enumerated on creation)"
)

objects = models.Manager()
filter_manager = XtalformDataManager()
Expand Down Expand Up @@ -360,6 +366,9 @@ class CanonSite(models.Model):
ref_conf_site = models.OneToOneField(
"CanonSiteConf", null=True, on_delete=models.CASCADE
)
canon_site_num = models.IntegerField(
null=True, help_text="numeric canon site id (enumerated on creation)"
)

objects = models.Manager()
filter_manager = CanonSiteDataManager()
Expand All @@ -379,6 +388,10 @@ class XtalformSite(models.Model):
xtalform_site_id = models.TextField(
null=False, help_text="xtalform site id from YAML"
)
# unused, remove when certain
xtalform_site_num = models.TextField(
null=True, help_text="alphabetic xtalform site id (enumerated on creation)"
)

objects = models.Manager()
filter_manager = XtalformSiteDataManager()
Expand Down Expand Up @@ -414,7 +427,8 @@ def __repr__(self) -> str:


class SiteObservation(models.Model):
code = models.TextField()
code = models.TextField(null=True)
longcode = models.TextField(null=True)
experiment = models.ForeignKey(Experiment, on_delete=models.CASCADE)
cmpd = models.ForeignKey(Compound, null=True, on_delete=models.CASCADE)
xtalform_site = models.ForeignKey(XtalformSite, on_delete=models.CASCADE)
Expand Down
2 changes: 2 additions & 0 deletions viewer/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -950,6 +950,8 @@ class Meta:


class SiteObservationReadSerializer(serializers.ModelSerializer):
compound_code = serializers.StringRelatedField()

class Meta:
model = models.SiteObservation
fields = '__all__'
Expand Down
Loading

0 comments on commit c6cb1e1

Please sign in to comment.