diff options
| -rw-r--r-- | archaeological_finds/models_treatments.py | 6 | ||||
| -rw-r--r-- | archaeological_finds/templates/ishtar/sheet_treatment.html | 2 | ||||
| -rw-r--r-- | archaeological_finds/templates/ishtar/sheet_treatmentfile.html | 2 | ||||
| -rw-r--r-- | archaeological_finds/urls.py | 4 | ||||
| -rw-r--r-- | archaeological_finds/views.py | 19 | ||||
| -rw-r--r-- | archaeological_operations/models.py | 15 | 
6 files changed, 44 insertions, 4 deletions
| diff --git a/archaeological_finds/models_treatments.py b/archaeological_finds/models_treatments.py index e0fb8683c..ec1ebf7a2 100644 --- a/archaeological_finds/models_treatments.py +++ b/archaeological_finds/models_treatments.py @@ -414,6 +414,12 @@ class TreatmentFile(ClosedItem, BaseHistorizedItem, OwnPerms, ValueGetter):      def __unicode__(self):          return self.cached_label +    @property +    def associated_filename(self): +        return "-".join([str(slugify(getattr(self, attr))) +                         for attr in ('year', 'index', 'internal_reference', +                                      'name') if getattr(self, attr)]) +      def _generate_cached_label(self):          items = [unicode(getattr(self, k))                   for k in ['year', 'index', 'internal_reference', 'name'] if diff --git a/archaeological_finds/templates/ishtar/sheet_treatment.html b/archaeological_finds/templates/ishtar/sheet_treatment.html index f1bfd68d2..a18cc9873 100644 --- a/archaeological_finds/templates/ishtar/sheet_treatment.html +++ b/archaeological_finds/templates/ishtar/sheet_treatment.html @@ -4,7 +4,7 @@  {% block head_title %}{% trans "Treatment" %}{% endblock %}  {% block content %} -{% window_nav item window_id 'show-treatment' %} +{% window_nav item window_id 'show-treatment' 'treatment_modify' %}  {% if item.image %}  <a href='{{item.image.url}}' rel="prettyPhoto" title="{{item.label}}" class='photo'><img src='{{item.thumbnail.url}}'/></a> diff --git a/archaeological_finds/templates/ishtar/sheet_treatmentfile.html b/archaeological_finds/templates/ishtar/sheet_treatmentfile.html index d569c5f0f..b142d3516 100644 --- a/archaeological_finds/templates/ishtar/sheet_treatmentfile.html +++ b/archaeological_finds/templates/ishtar/sheet_treatmentfile.html @@ -4,7 +4,7 @@  {% block head_title %}{% trans "Treatment file" %}{% endblock %}  {% block content %} -{% window_nav item window_id 'show-treatmentfile' %} +{% window_nav item window_id 'show-treatmentfile' 'treatmentfile_modify' %}  <p class="window-refs">{{ item.name|default:"" }}</p>  {% if item.internal_reference %} diff --git a/archaeological_finds/urls.py b/archaeological_finds/urls.py index 843cfead9..f1ddb1223 100644 --- a/archaeological_finds/urls.py +++ b/archaeological_finds/urls.py @@ -96,6 +96,8 @@ urlpatterns = patterns(          check_rights(['change_find', 'change_own_find'])(              views.treatment_modification_wizard),          name='treatment_modification'), +    url(r'treatment_modify/(?P<pk>.+)/$', +        views.treatment_modify, name='treatment_modify'),      url(r'^treatment_search/(?P<step>.+)?$',          check_rights(['view_find', 'view_own_find'])(              views.treatment_search_wizard), name='treatment_search'), @@ -209,6 +211,8 @@ urlpatterns = patterns(          check_rights(['change_find', 'change_own_find'])(              views.treatmentfile_modification_wizard),          name='treatmentfile_modification'), +    url(r'^treatmentfile_modify/(?P<pk>.+)/$', +        views.treatmentfile_modify, name='treatmentfile_modify'),      url(r'^treatmentfle_deletion/(?P<step>.+)?$',          check_rights(['change_find', 'change_own_find'])(              views.treatmentfile_deletion_wizard), diff --git a/archaeological_finds/views.py b/archaeological_finds/views.py index 2b5aef79c..01e579566 100644 --- a/archaeological_finds/views.py +++ b/archaeological_finds/views.py @@ -384,6 +384,16 @@ treatment_modification_wizard = TreatmentModificationWizard.as_view(      url_name='treatment_modification',  ) + +def treatment_modify(request, pk): +    treatment_modification_wizard(request) +    TreatmentModificationWizard.session_set_value( +        request, 'selec-treatment_modification', 'pk', pk, reset=True) +    return redirect(reverse( +        'treatment_modification', +        kwargs={'step': 'basetreatment-treatment_modification'})) + +  treatment_deletion_wizard = TreatmentDeletionWizard.as_view([      ('selec-treatment_deletion', TreatmentFormSelection),      ('final-treatment_deletion', TreatmentDeletionForm)], @@ -466,6 +476,15 @@ treatmentfile_modification_wizard = TreatmentFileModificationWizard.as_view(      url_name='treatmentfile_modification',  ) + +def treatmentfile_modify(request, pk): +    treatmentfile_modification_wizard(request) +    TreatmentFileModificationWizard.session_set_value( +        request, 'selec-treatmentfile_modification', 'pk', pk, reset=True) +    return redirect(reverse( +        'treatmentfile_modification', +        kwargs={'step': 'treatmentfile-treatmentfile_modification'})) +  treatmentfile_deletion_wizard = TreatmentFileDeletionWizard.as_view([      ('selec-treatmentfile_deletion', TreatmentFileFormSelection),      ('final-treatmentfile_deletion', TreatmentFileDeletionForm)], diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py index 307d02e97..7507da817 100644 --- a/archaeological_operations/models.py +++ b/archaeological_operations/models.py @@ -1037,7 +1037,7 @@ class AdministrativeAct(BaseHistorizedItem, OwnPerms, ValueGetter):      def __unicode__(self):          return settings.JOINT.join(              [unicode(item) for item in [ -                self.operation, self.associated_file, self.act_object] +                self.related_item, self.act_object]               if item])      full_ref_lbl = _(u"Ref.") @@ -1054,6 +1054,10 @@ class AdministrativeAct(BaseHistorizedItem, OwnPerms, ValueGetter):          return u" ".join(lbl)      @property +    def associated_filename(self): +        return self.get_filename() + +    @property      def towns(self):          if self.associated_file:              return self.associated_file.towns.all() @@ -1081,7 +1085,14 @@ class AdministrativeAct(BaseHistorizedItem, OwnPerms, ValueGetter):      @property      def related_item(self): -        return self.operation if self.operation else self.associated_file +        if self.operation: +            return self.operation +        if self.associated_file: +            return self.associated_file +        if self.treatment: +            return self.treatment +        if self.treatment_file: +            return self.treatment_file      def get_filename(self):          filename = self.related_item.associated_filename | 
