diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2016-12-04 03:29:37 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2016-12-04 03:29:37 +0100 |
commit | 3ab8a09605af6b8a4cd1456fc6e77239d140a179 (patch) | |
tree | 4fc825b2a0dbcbabd34f542fbcc4dee7b666bc95 | |
parent | 495c777c27cb1e75fd89f63f2af3cf5c9183bff2 (diff) | |
download | Ishtar-3ab8a09605af6b8a4cd1456fc6e77239d140a179.tar.bz2 Ishtar-3ab8a09605af6b8a4cd1456fc6e77239d140a179.zip |
Treatment modifications
-rw-r--r-- | archaeological_finds/admin.py | 2 | ||||
-rw-r--r-- | archaeological_finds/forms.py | 18 | ||||
-rw-r--r-- | archaeological_finds/models.py | 28 | ||||
-rw-r--r-- | archaeological_finds/urls.py | 4 | ||||
-rw-r--r-- | archaeological_finds/views.py | 8 | ||||
-rw-r--r-- | archaeological_finds/wizards.py | 4 | ||||
-rw-r--r-- | ishtar_common/models.py | 2 |
7 files changed, 52 insertions, 14 deletions
diff --git a/archaeological_finds/admin.py b/archaeological_finds/admin.py index 95fff4b73..867245194 100644 --- a/archaeological_finds/admin.py +++ b/archaeological_finds/admin.py @@ -59,7 +59,7 @@ admin.site.register(models.Property, PropertyAdmin) class TreatmentAdmin(HistorizedObjectAdmin): - list_display = ('location', 'treatment_type', 'container', 'person') + list_display = ('location', 'treatment_types_lbl', 'container', 'person') model = models.Treatment admin.site.register(models.Treatment, TreatmentAdmin) diff --git a/archaeological_finds/forms.py b/archaeological_finds/forms.py index f03583598..98017f7e2 100644 --- a/archaeological_finds/forms.py +++ b/archaeological_finds/forms.py @@ -604,6 +604,22 @@ class FindBasketAddItemForm(forms.Form): return basket +class TreatmentSelect(TableSelect): + label = forms.CharField(label=_(u"Label")) + other_reference = forms.CharField(label=_(u"Other ref.")) + year = forms.IntegerField(label=_(u"Year")) + index = forms.IntegerField(label=_(u"Index")) + treatment_types = forms.ChoiceField(label=_(u"Treatment type"), choices=[]) + image = forms.NullBooleanField(label=_(u"Has an image?")) + + def __init__(self, *args, **kwargs): + super(TreatmentSelect, self).__init__(*args, **kwargs) + self.fields['treatment_types'].choices = \ + models.TreatmentType.get_types() + self.fields['treatment_types'].help_text = \ + models.TreatmentType.get_help() + + class TreatmentFormSelection(forms.Form): form_label = _("Treatment search") associated_models = {'pk': models.Treatment} @@ -612,7 +628,7 @@ class TreatmentFormSelection(forms.Form): label="", required=False, widget=widgets.JQueryJqGrid( reverse_lazy('get-treatment'), - FindSelect, models.Treatment), + TreatmentSelect, models.Treatment), validators=[valid_id(models.Treatment)]) diff --git a/archaeological_finds/models.py b/archaeological_finds/models.py index 3e0d09ef8..a563a8404 100644 --- a/archaeological_finds/models.py +++ b/archaeological_finds/models.py @@ -794,6 +794,22 @@ post_delete.connect(post_save_cache, sender=TreatmentType) class Treatment(BaseHistorizedItem, ImageModel, OwnPerms): SHOW_URL = 'show-treatment' + TABLE_COLS = ('treatment_types_lbl', 'person', 'start_date', + 'downstream_cached_label', 'upstream_cached_label') + REVERSED_BOOL_FIELDS = ['image__isnull'] + EXTRA_REQUEST_KEYS = { + "label": 'label__icontains', + "other_reference": 'other_reference__icontains', + "treatment_types": "treatment_types__pk", + "downstream_cached_label": "downstream__cached_label", + "upstream_cached_label": "upstream__cached_label", + 'image': 'image__isnull', + } + TABLE_COLS_LBL = { + "downstream_cached_label": _(u"Downstream find"), + "upstream_cached_label": _(u"Upstream find"), + } + IMAGE_PREFIX = 'treatment' label = models.CharField(_(u"Label"), blank=True, null=True, max_length=200) other_reference = models.CharField(_(u"Other ref."), blank=True, null=True, @@ -826,16 +842,6 @@ class Treatment(BaseHistorizedItem, ImageModel, OwnPerms): blank=True, null=True) target_is_basket = models.BooleanField(_("Target a basket"), default=False) history = HistoricalRecords() - TABLE_COLS = ('treatment_type', 'person', 'start_date', - 'downstream_cached_label', 'upstream_cached_label') - EXTRA_REQUEST_KEYS = { - "downstream_cached_label": "downstream__cached_label", - "upstream_cached_label": "upstream__cached_label", - } - TABLE_COLS_LBL = { - "downstream_cached_label": _(u"Downstream find"), - "upstream_cached_label": _(u"Upstream find"), - } class Meta: verbose_name = _(u"Treatment") @@ -855,7 +861,7 @@ class Treatment(BaseHistorizedItem, ImageModel, OwnPerms): lbl += u" %s %s" % (_(u"by"), unicode(self.person)) return lbl - def treatment_type(self): + def treatment_types_lbl(self): """ Treatment types label :return: string diff --git a/archaeological_finds/urls.py b/archaeological_finds/urls.py index 220087d33..add258ed5 100644 --- a/archaeological_finds/urls.py +++ b/archaeological_finds/urls.py @@ -91,6 +91,10 @@ urlpatterns = patterns( url(r'treatment_creation/(?P<step>.+)?$', check_rights(['change_find', 'change_own_find'])( views.treatment_creation_wizard), name='treatment_creation'), + url(r'treatment_modification/(?P<step>.+)?$', + check_rights(['change_find', 'change_own_find'])( + views.treatment_modification_wizard), + name='treatment_modification'), url(r'treatment_search/(?P<step>.+)?$', check_rights(['view_find', 'view_own_find'])( views.treatment_search_wizard), name='treatment_search'), diff --git a/archaeological_finds/views.py b/archaeological_finds/views.py index 29d4f7da9..1be9a9ae7 100644 --- a/archaeological_finds/views.py +++ b/archaeological_finds/views.py @@ -323,6 +323,14 @@ treatment_creation_wizard = TreatmentWizard.as_view( label=_(u"New treatment"), url_name='treatment_creation',) +treatment_modification_wizard = TreatmentModificationWizard.as_view( + [('selec-treatment_modification', TreatmentFormSelection), + ('basetreatment-treatment_modification', BaseTreatmentForm), + ('final-treatment_modification', FinalForm)], + label=_(u"Modify"), + url_name='treatment_modification', +) + """ treatment_source_creation_wizard = TreatmentSourceWizard.as_view([ ('selec-treatment_source_creation', SourceTreatmentFormSelection), diff --git a/archaeological_finds/wizards.py b/archaeological_finds/wizards.py index 962f21e69..42d734526 100644 --- a/archaeological_finds/wizards.py +++ b/archaeological_finds/wizards.py @@ -117,6 +117,10 @@ class TreatmentWizard(Wizard): return dct +class TreatmentModificationWizard(TreatmentWizard): + modification = True + + class FindSourceWizard(SourceWizard): wizard_done_window = reverse_lazy('show-findsource') model = models.FindSource diff --git a/ishtar_common/models.py b/ishtar_common/models.py index ebb9c9588..2bb96d11d 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -664,7 +664,7 @@ class ImageModel(models.Model): null=True, max_length=255) IMAGE_MAX_SIZE = settings.IMAGE_MAX_SIZE THUMB_MAX_SIZE = settings.THUMB_MAX_SIZE - IMAGE_PREFIX = '/' + IMAGE_PREFIX = '' class Meta: abstract = True |