Skip to content
Permalink
Browse files

#MC-366 Add Work Development 40m refactoring: artefact.chronology_cat…

…egory display and reference removal

- preparing artefact.chronology_category db field removal we first remove all references to it
  • Loading branch information...
bletourmy committed Apr 12, 2019
1 parent 0635e98 commit f9c517db64ce75f77778b02afcf5af131cbe76ac
@@ -32,9 +32,9 @@ class ArtefactAdmin(admin.ModelAdmin):
fieldsets = [
('Own fields', {
'fields': ['description', 'inventory_number', 'recorded_conservation_data',
'sample_description', 'sample_number', 'date_aim_sampling']}),
'sample_description', 'sample_number', 'date_aim_sampling','chronology_tpq','chronology_taq','chronology_comment']}),
('Foreign keys', {
'fields': ['author', 'metal1', 'metalx', 'alloy', 'type', 'origin', 'recovering_date', 'chronology_period',
'fields': ['author', 'metal1', 'metalx', 'alloy', 'type', 'origin', 'recovering_date', 'chronology_category',
'environment', 'location', 'owner', 'technology', 'sample_location',
'responsible_institution', 'microstructure', 'corrosion_form', 'corrosion_type', 'object']})
]
@@ -49,8 +49,8 @@ def user(self, obj):
user.admin_order_field = 'object__user'


list_display = ('id','url',linkify('object'), 'user','modified','inventory_number', 'alloy', 'chronology_category', linkify('chronology_period'),'origin_country')
list_filter = ['chronology_period__chronology_category','object__user','chronology_period']
list_display = ('id','url',linkify('object'), 'user','modified','inventory_number', 'alloy', 'origin_country', linkify('chronology_category'),'chronology_tpq','chronology_taq','chronology_comment')
list_filter = ['chronology_category','object__user']
date_hierarchy = 'modified'

def origin_country(self, obj):
@@ -60,12 +60,6 @@ def origin_country(self, obj):
country = obj.origin.city.country.name
return country

def chronology_category(self, obj):
chronology = ""
if obj.chronology_period:
chronology = obj.chronology_period.chronology_category
return chronology


class ChronologyCategoryAdmin(admin.ModelAdmin):
list_display = ('name','order','tpq','taq')
@@ -77,7 +71,7 @@ class ArtefactInline(admin.StackedInline):
fieldsets = [
('Own fields', {'fields': ['id','validated','published']}),
('Foreign keys', {
'fields': ['object', 'type', 'origin', 'author', 'chronology_period']})
'fields': ['object', 'type', 'origin', 'author', 'chronology_category']})
]


@@ -114,7 +114,6 @@ class Meta:
'type', # fk
'origin', # fk
'recovering_date', # fk
'chronology_period', # fk
'chronology_category', # fk
'chronology_tpq',
'chronology_taq',
@@ -203,7 +202,6 @@ class Meta:
widgets = {
'type': TextInput(),
'recovering_date': TextInput(),
'chronology_period': TextInput(),
}

class ImageCreateForm(forms.ModelForm):
@@ -274,7 +274,7 @@ class Artefact(TimeStampedModel):
help_text='The place, city and country where the artefact comes from or the object to which the section considered belongs to')
recovering_date = models.ForeignKey(RecoveringDate, verbose_name='date of recovering', blank=True, null=True, help_text='The date of excavation for archaeological objects, of production and use for other artefacts')
chronology_period = models.ForeignKey(ChronologyPeriod, verbose_name='dating of artefact (Tpq _ Taq)', blank=True, null=True,
help_text='The dating of the artefact')
help_text='The dating of the artefact', editable=False)
chronology_category = models.ForeignKey(ChronologyCategory, blank=True, null=True, help_text='A general dating of the artefact')
chronology_tpq = YearField( blank=True, default=0, help_text='Dating of artefact TPQ (Terminus post quem) e.g. "3000 B.C."')
chronology_taq = YearField( blank=True, default=0, help_text='Dating of artefact TAQ (Terminus ante quem) e.g. "200 A.D."')
@@ -297,7 +297,7 @@ class Artefact(TimeStampedModel):
class Meta:
verbose_name = 'Artefact'
verbose_name_plural = 'Artefacts'
ordering = ['metal1', 'alloy', 'chronology_period__chronology_category', 'type']
ordering = ['metal1', 'alloy', 'chronology_category', 'type']

def get_authors(self):
authors_list = []
@@ -319,9 +319,8 @@ def artefact_verbose_description(self):
artefact.append(self.inventory_number)
if self.alloy:
artefact.append(self.alloy.name)
if self.chronology_period:
if self.chronology_period.chronology_category:
artefact.append(self.chronology_period.chronology_category.name)
if self.chronology_category:
artefact.append(self.chronology_category.name)
if self.origin:
if self.origin.city:
artefact.append(self.origin.city.country.name)
@@ -331,9 +330,8 @@ def artefact_verbose_description_short(self):
artefact = [self.object.name]
if self.alloy:
artefact.append(self.alloy.name)
if self.chronology_period:
if self.chronology_period.chronology_category:
artefact.append(self.chronology_period.chronology_category.name)
if self.chronology_category:
artefact.append(self.chronology_category.name)
if self.origin:
if self.origin.city:
if self.origin.city.country:
@@ -19,7 +19,7 @@ class ArtefactIndex(indexes.SearchIndex, indexes.Indexable):
type = indexes.CharField(model_attr='type')
origin = indexes.CharField(model_attr='origin')
recovering_date = indexes.CharField(model_attr='recovering_date')
chronology_period = indexes.CharField(model_attr='chronology_period')
chronology_category = indexes.CharField(model_attr='chronology_category')
environment = indexes.CharField(model_attr='environment')
location = indexes.CharField(model_attr='location')
owner = indexes.CharField(model_attr='owner')
@@ -54,4 +54,4 @@ def index_queryset(self, using=None):
"""
Used when the entire index for model is updated.
"""
return self.get_model().objects.all()
return self.get_model().objects.all()
@@ -23,7 +23,6 @@
url(r'^add/type/?$', artefacts_views.newType),
url(r'^add/origin/?$', artefacts_views.newOrigin),
url(r'^add/recovering_date/?$', artefacts_views.newRecoveringDate),
url(r'^add/chronology_period/?$', artefacts_views.newChronologyPeriod),
url(r'^add/environment/?$', artefacts_views.newEnvironment),
url(r'^add/location/?$', artefacts_views.newLocation),
url(r'^add/owner/?$', artefacts_views.newOwner),
@@ -99,7 +99,7 @@ class ArtefactsListView(generic.ListView):
"""
A list of all the artefacts in the filter
"""
queryset = Artefact.objects.select_related('alloy', 'type', 'chronology_period', 'technology',
queryset = Artefact.objects.select_related('alloy', 'type', 'chronology_category', 'technology',
'microstructure')

def get(self, request, *args, **kwargs):
@@ -154,7 +154,7 @@ class ArtefactsDetailView(generic.DetailView):
"""
A detail view of a selected artefact
"""
queryset = Artefact.objects.select_related('alloy', 'type', 'origin', 'recovering_date', 'chronology_period',
queryset = Artefact.objects.select_related('alloy', 'type', 'origin', 'recovering_date', 'chronology_category',
'environment', 'location', 'owner', 'technology', 'sample_location',
'responsible_institution', 'microstructure', 'corrosion_form', 'corrosion_type')
template_name = 'artefacts/artefact_update_page.html'
@@ -294,10 +294,6 @@ def newRecoveringDate(request):
return handlePopAdd(request, RecoveringDateCreateForm, 'recovering_date')


@login_required
def newChronologyPeriod(request):
return handlePopAdd(request, ChronologyCreateForm, 'chronology_period')


@login_required
def newEnvironment(request):
@@ -987,7 +983,7 @@ class CollaborationCommentView(generic.CreateView):
"""
A detail view of a selected artefact
"""
queryset = Artefact.objects.select_related('alloy', 'type', 'origin', 'recovering_date', 'chronology_period',
queryset = Artefact.objects.select_related('alloy', 'type', 'origin', 'recovering_date', 'chronology_category',
'environment', 'location', 'owner', 'technology', 'sample_location',
'responsible_institution', 'microstructure', 'corrosion_form', 'corrosion_type')

@@ -1691,7 +1687,7 @@ class AdministrationArtefactDetailView(generic.DetailView):
model = Publication
template_name_suffix = '_administration_detail'

"""queryset = Artefact.objects.select_related('alloy', 'type', 'origin', 'recovering_date', 'chronology_period',
"""queryset = Artefact.objects.select_related('alloy', 'type', 'origin', 'recovering_date', 'chronology_category',
'environment', 'location', 'owner', 'technology', 'sample_location',
'responsible_institution', 'microstructure', 'corrosion_form', 'corrosion_type')
"""
@@ -666,7 +666,7 @@ def match(self, data):
line['artefact_metal1'] = published_artefact.metal1.element
line['artefact_alloy'] = published_artefact.alloy.name
line['artefact_type'] = published_artefact.type.name
line['artefact_chronology_category'] = published_artefact.chronology_period.chronology_category.name
line['artefact_chronology_category'] = published_artefact.chronology_category.name
line['artefact_technology'] = published_artefact.technology.name
line['artefact_microstructure'] = published_artefact.microstructure.name
result_list.append(line)
@@ -70,7 +70,7 @@
</div>
<div class="row">
<div class="c3"><em>Chronology</em></div>
<div class="c9"><p>{{ artefact.chronology_period.chronology_category }}</p></div>
<div class="c9"><p>{{ artefact.chronology_category }}</p></div>
</div>
<div class="row">
<div class="c3"><em>Burial conditions / environment</em></div>
@@ -68,7 +68,7 @@ <h2>{{ artefact }}</h2>

<div class="row">
<div class="col-xs-4 column1">Chronology</div>
<div class="col-xs-8 column2">{{ artefact.chronology_period.chronology_category }}</div>
<div class="col-xs-8 column2">{{ artefact.chronology_category }}</div>
</div>

<br/>
@@ -232,4 +232,4 @@ <h2>{{ artefact }}</h2>
{% endif %}

</div>
{% endblock content %}
{% endblock content %}
@@ -64,7 +64,7 @@ <h1>Results</h1>
<td>{{ artefact.type|default:"" }}</td>
<td>{{ artefact.object.name|default:"" }}</td>
<td>{{ artefact.origin|default:"" }}</td>
<td>{{ artefact.chronology_period.chronology_category.name|default:"" }}</td>
<td>{{ artefact.chronology_category.name|default:"" }}</td>
<td>{{ artefact.technology|default:"" }}</td>
<td>{{ artefact.location|default:"" }}</td>
</tr>
@@ -306,7 +306,7 @@ <h1>{{ artefact.artefact_verbose_description_short }}</h1>
<!-- Chronology -->
<div class="row">
<div class="c3"><em>Chronology</em></div>
<div class="c8"><p>{{ artefact.chronology_period.chronology_category }}</p></div>
<div class="c8"><p>{{ artefact.chronology_category }}</p></div>
<div class="c1">
<div class="pull-right">
{% for key, values in tokenComments.items %}

0 comments on commit f9c517d

Please sign in to comment.
You can’t perform that action at this time.