diff options
author | Étienne Loks <etienne.loks@proxience.com> | 2014-12-30 18:08:30 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@proxience.com> | 2015-05-06 15:38:32 +0200 |
commit | 52b1abbc54db98ef848eddf41a3c5c58be2e5b3f (patch) | |
tree | b02128e401468d905459587852d15c6b7216d8d0 /archaeological_files | |
parent | 6242fd2ed8f2df236375f32374a694d886135e58 (diff) | |
download | Ishtar-52b1abbc54db98ef848eddf41a3c5c58be2e5b3f.tar.bz2 Ishtar-52b1abbc54db98ef848eddf41a3c5c58be2e5b3f.zip |
Add a new action to create an associated operation from a file window
Diffstat (limited to 'archaeological_files')
-rw-r--r-- | archaeological_files/models.py | 4 | ||||
-rw-r--r-- | archaeological_files/templates/ishtar/sheet_file.html | 7 | ||||
-rw-r--r-- | archaeological_files/views.py | 11 |
3 files changed, 20 insertions, 2 deletions
diff --git a/archaeological_files/models.py b/archaeological_files/models.py index 289aa4166..d8281d591 100644 --- a/archaeological_files/models.py +++ b/archaeological_files/models.py @@ -270,7 +270,9 @@ class File(BaseHistorizedItem, OwnPerms, ValueGetter, ShortMenuItem, def get_town_label(self): lbl = unicode(_('Intercommunal')) - if self.towns.count() == 1: + if self.main_town: + lbl = self.main_town.name + elif self.towns.count() == 1: lbl = self.towns.all()[0].name return lbl diff --git a/archaeological_files/templates/ishtar/sheet_file.html b/archaeological_files/templates/ishtar/sheet_file.html index 11a90df9e..736f982c5 100644 --- a/archaeological_files/templates/ishtar/sheet_file.html +++ b/archaeological_files/templates/ishtar/sheet_file.html @@ -20,7 +20,14 @@ </div> {% endif %} <div class='tool'>{%trans "Export as:"%} <a href='{% url show-file item.pk "odt" %}'>{%trans "OpenOffice.org file"%}</a>, <a href='{% url show-file item.pk "pdf" %}'>{%trans "PDF file"%}</a></div> +<hr/> <div class='tool modify'><a href='{% url file_modify item.pk %}'>{% trans "Modify" %}</a></div> + +{% if can_add_operation %} +<div class='tool modify'><a href='{% url operation_add item.pk %}'>{%trans "Add an associated archaeological operation"%}</a></div> + +{%endif%} + <h3>{% trans "General"%}</h3> <p><label>{%trans "Year:"%}</label> <span class='value strong'>{{ item.year }}</span></p> {% if item.numeric_reference %}<p><label>{%trans "Numerical reference:"%}</label> <span class='value strong'>{{ item.numeric_reference }}</span></p>{% endif %} diff --git a/archaeological_files/views.py b/archaeological_files/views.py index ba640a785..c414ba858 100644 --- a/archaeological_files/views.py +++ b/archaeological_files/views.py @@ -28,6 +28,7 @@ from django.utils.translation import ugettext_lazy as _ from ishtar_common.views import get_item, show_item, revert_item from ishtar_common.models import Person +from archaeological_operations.models import Operation import models from ishtar_common.wizards import SearchWizard @@ -85,9 +86,17 @@ get_file = get_item(models.File, 'get_file', 'file', 'general_contractor__attached_to':'general_contractor__attached_to__pk', 'history_creator':'history_creator__ishtaruser__person__pk', },) -show_file = show_item(models.File, 'file') revert_file = revert_item(models.File) +def extra_file_dct(request, item): + dct = {} + if (request.user.has_perm('ishtar_common.add_operation', Operation) + or request.user.ishtaruser.has_right('add_operation')): + dct['can_add_operation'] = True + return dct + +show_file = show_item(models.File, 'file', extra_dct=extra_file_dct) + get_administrativeactfile = get_item(AdministrativeAct, 'get_administrativeactfile', 'administrativeactfile', associated_models = [(models.File, 'associated_file'), |