Skip to content

Commit

Permalink
Removed dimensionality from datasets and fixed dimensionality entry i…
Browse files Browse the repository at this point in the history
…ssue when adding systems.
  • Loading branch information
uthpalaherath committed Nov 19, 2024
1 parent fd5782e commit 2a74dc9
Show file tree
Hide file tree
Showing 7 changed files with 303 additions and 256 deletions.
1 change: 0 additions & 1 deletion materials/fixtures/datasets.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"visible": true,
"is_figure": false,
"is_experimental": true,
"dimensionality": 3,
"sample_type": 0,
"extraction_method": "",
"representative": true,
Expand Down
22 changes: 11 additions & 11 deletions materials/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,17 +360,17 @@ class AddDataForm(forms.Form):
help_text=""
"Select whether the origin of data is experimental or theoretical.",
)
dimensionality_of_the_inorganic_component = forms.ChoiceField(
initial=models.Dataset.DIMENSIONALITIES[0],
choices=(models.Dataset.DIMENSIONALITIES),
widget=forms.RadioSelect(),
help_text=""
"Here the term dimensionality refers to the one typically used in the "
"context of organic-inorganic perovskites (a certain arrangement of "
"organic and inorganic components). This is not the standard "
"definition of the dimensionality of a system (single crystal, "
'film, ...). See "sample type" for that.',
)
# dimensionality_of_the_inorganic_component = forms.ChoiceField(
# initial=models.Dataset.DIMENSIONALITIES[0],
# choices=(models.Dataset.DIMENSIONALITIES),
# widget=forms.RadioSelect(),
# help_text=""
# "Here the term dimensionality refers to the one typically used in the "
# "context of organic-inorganic perovskites (a certain arrangement of "
# "organic and inorganic components). This is not the standard "
# "definition of the dimensionality of a system (single crystal, "
# 'film, ...). See "sample type" for that.',
# )
sample_type = forms.ChoiceField(
initial=models.Dataset.SAMPLE_TYPES[0],
choices=(models.Dataset.SAMPLE_TYPES),
Expand Down
17 changes: 17 additions & 0 deletions materials/migrations/0134_remove_dataset_dimensionality.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 3.1.14 on 2024-11-19 02:16

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('materials', '0133_stoichiometry_elements_system_stoichiometry'),
]

operations = [
migrations.RemoveField(
model_name='dataset',
name='dimensionality',
),
]
6 changes: 3 additions & 3 deletions materials/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,9 @@ class Dataset(Base):
visible = models.BooleanField()
is_figure = models.BooleanField()
is_experimental = models.BooleanField() # theoretical if false
dimensionality = models.PositiveSmallIntegerField(
choices=DIMENSIONALITIES, default=0
)
# dimensionality = models.PositiveSmallIntegerField(
# choices=DIMENSIONALITIES, default=0
# )
sample_type = models.PositiveSmallIntegerField(choices=SAMPLE_TYPES)
extraction_method = models.CharField(max_length=300, blank=True)
representative = models.BooleanField(default=False)
Expand Down
16 changes: 12 additions & 4 deletions materials/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ class Meta:
"reference",
"visible",
"is_experimental",
"dimensionality",
# "dimensionality",
"sample_type",
"extraction_method",
"representative",
Expand Down Expand Up @@ -196,7 +196,7 @@ class Meta:
"secondary_unit",
"reference",
"is_experimental",
"dimensionality",
# "dimensionality",
"sample_type",
"extraction_method",
)
Expand All @@ -217,7 +217,7 @@ class Meta:
"secondary_unit",
"reference",
"is_experimental",
"dimensionality",
# "dimensionality",
"sample_type",
)

Expand All @@ -241,7 +241,7 @@ class Meta:
# SystemSerializer with a custom field for stoichiometry
class SystemSerializer(serializers.ModelSerializer):
stoichiometry = serializers.SerializerMethodField()
dimensionality = serializers.SerializerMethodField()
# dimensionality = serializers.SerializerMethodField()

class Meta:
model = models.System
Expand All @@ -257,9 +257,17 @@ class Meta:
"derived_to_from",
"description",
"dimensionality",
"n",
"stoichiometry",
)

def to_representation(self, instance):
representation = super().to_representation(instance)
representation["dimensionality"] = DIMENSIONALITIES.get(
instance.dimensionality, None
)
return representation

def get_stoichiometry(self, obj):
# Retrieve the first related System_Stoichiometry instance
stoichiometry_set = obj.system_stoichiometry_set.first()
Expand Down
Loading

0 comments on commit 2a74dc9

Please sign in to comment.