Skip to content

Commit

Permalink
Merge pull request #232 from ImperialCollegeLondon/polymer
Browse files Browse the repository at this point in the history
Remove polymer field from component
  • Loading branch information
dandavies99 authored Dec 22, 2022
2 parents 792950c + 77a40d9 commit 307ed52
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 18 deletions.
2 changes: 1 addition & 1 deletion dfndb/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class DataParameterInline(admin.TabularInline):


class ComponentAdmin(BaseAdmin):
list_display = BaseAdmin.list_display + ["type", "polymer"]
list_display = BaseAdmin.list_display + ["type"]
list_filter = BaseAdmin.list_filter + ["type"]
inlines = (ComponentCompositionInline,)

Expand Down
3 changes: 1 addition & 2 deletions dfndb/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class NewComponentForm(DataCreateForm):

class Meta:
model = Component
fields = ["name", "type", "polymer", "notes"]
fields = ["name", "type", "notes"]

def __init__(self, *args, **kwargs):
super(NewComponentForm, self).__init__(*args, **kwargs)
Expand All @@ -76,7 +76,6 @@ def __init__(self, *args, **kwargs):
Div(HTML("<h1> Component </h1>")),
Column("name", css_class="col-4"),
Column("type", css_class="col-4"),
Column("polymer", css_class="col-4"),
Fieldset(
"Composition",
Div(
Expand Down
17 changes: 17 additions & 0 deletions dfndb/migrations/0017_remove_component_polymer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 4.1.3 on 2022-12-09 11:04

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('dfndb', '0016_alter_compound_unique_together_alter_component_name_and_more'),
]

operations = [
migrations.RemoveField(
model_name='component',
name='polymer',
),
]
6 changes: 0 additions & 6 deletions dfndb/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,6 @@ class Component(cm.BaseModelMandatoryName):
(4, "Separator"),
]
type = models.PositiveSmallIntegerField(choices=MATERIAL_TYPE_CHOICES)
polymer = models.PositiveIntegerField(
default=0,
help_text=(
"Degree of polymerisation if this component is a polymer, otherwise 0"
),
)

def __str__(self):
return self.name or ""
Expand Down
6 changes: 0 additions & 6 deletions dfndb/templates/component.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,6 @@ <h5>Component details</h5>
<br>
{{ object.get_type_display }}
<br><br>
{% if object.polymer > 0 %}
<b>Degree of polymerisation</b>
<br>
{{ object.polymer }}
<br><br>
{% endif %}
<b>Composition</b>
<br>
<table class="table">
Expand Down
2 changes: 1 addition & 1 deletion tests/dfndb/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def test_component_admin(self):
ma = ComponentAdmin(Component, self.site)
self.assertEqual(ma.model, Component)
self.assertEqual(
ma.get_list_display(request), BaseAdmin.list_display + ["type", "polymer"]
ma.get_list_display(request), BaseAdmin.list_display + ["type"]
)
self.assertEqual(ma.get_list_filter(request), BaseAdmin.list_filter + ["type"])
self.assertTrue(site.is_registered(Component))
Expand Down
3 changes: 1 addition & 2 deletions tests/dfndb/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def setUp(self):
)
comp2 = baker.make_recipe("tests.dfndb.compound", name="Sulphur", formula="S")
self.model = baker.make_recipe(
"tests.dfndb.component", name="Contaminant", type=1, polymer=0
"tests.dfndb.component", name="Contaminant", type=1
)
baker.make_recipe(
"tests.dfndb.composition_part",
Expand All @@ -72,7 +72,6 @@ def test_component_creation(self):
self.assertEqual(self.model.composition.all().count(), 2)
self.assertEqual(self.model.composition.get(name=name), cmp)
self.assertEqual(self.model.type, 1)
self.assertEqual(self.model.polymer, 0)

def test_str(self):
self.assertEqual(self.model.__str__(), "Contaminant")
Expand Down

0 comments on commit 307ed52

Please sign in to comment.