From a296bd385e704b1e76a774341f8ad126c892ccab Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Tue, 29 Dec 2015 18:26:54 +0100 Subject: Add a template for operation sources --- archaeological_operations/models.py | 2 ++ .../templates/ishtar/sheet_operationsource.html | 15 +++++++++++++ .../ishtar/sheet_operationsource_pdf.html | 18 ++++++++++++++++ .../ishtar/sheet_operationsource_window.html | 3 +++ archaeological_operations/urls.py | 5 ++++- archaeological_operations/views.py | 1 + ishtar_common/__init__.py | 6 ++++-- ishtar_common/models.py | 9 +++++++- ishtar_common/templates/ishtar/sheet_source.html | 25 ++++++++++++++++++++++ ishtar_common/templatetags/window_field.py | 2 ++ 10 files changed, 82 insertions(+), 4 deletions(-) create mode 100644 archaeological_operations/templates/ishtar/sheet_operationsource.html create mode 100644 archaeological_operations/templates/ishtar/sheet_operationsource_pdf.html create mode 100644 archaeological_operations/templates/ishtar/sheet_operationsource_window.html create mode 100644 ishtar_common/templates/ishtar/sheet_source.html diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py index d0059da9e..795c1a805 100644 --- a/archaeological_operations/models.py +++ b/archaeological_operations/models.py @@ -134,6 +134,7 @@ QUALITY = (('ND', _(u"Not documented")), class Operation(BaseHistorizedItem, OwnPerms, ValueGetter, ShortMenuItem, DashboardFormItem): QUALITY_DICT = dict(QUALITY) + SHOW_URL = 'show-operation' TABLE_COLS = ['year_index', 'operation_type', 'remains', 'towns', 'start_date', 'excavation_end_date'] if FILES_AVAILABLE: @@ -522,6 +523,7 @@ class OperationSource(Source): null=True) TABLE_COLS = ['operation.year', 'operation.operation_code'] + \ Source.TABLE_COLS + SHOW_URL = 'show-operationsource' @property def owner(self): diff --git a/archaeological_operations/templates/ishtar/sheet_operationsource.html b/archaeological_operations/templates/ishtar/sheet_operationsource.html new file mode 100644 index 000000000..5e2a39826 --- /dev/null +++ b/archaeological_operations/templates/ishtar/sheet_operationsource.html @@ -0,0 +1,15 @@ +{% extends "ishtar/sheet_source.html" %} +{% load i18n window_field link_to_window %} + +{% block head_sheet %} +{{block.super}} +

{% trans "Operation source"%}

+{% endblock %} + +{% block export %} +
{%trans "Export as:"%} {%trans "OpenOffice.org file"%}, {%trans "PDF file"%}
+{% endblock %} + +{% block related %} +{% field "Related operation" item.owner '' item.owner|link_to_window %} +{% endblock %} diff --git a/archaeological_operations/templates/ishtar/sheet_operationsource_pdf.html b/archaeological_operations/templates/ishtar/sheet_operationsource_pdf.html new file mode 100644 index 000000000..32362d4c2 --- /dev/null +++ b/archaeological_operations/templates/ishtar/sheet_operationsource_pdf.html @@ -0,0 +1,18 @@ +{% extends "ishtar/sheet_operationsource.html" %} +{% block header %} + +{% endblock %} +{% block main_head %} +{{ block.super }} +
+Ishtar – {{APP_NAME}} – {{item}} +
+{% endblock %} +{%block head_sheet%}{%endblock%} +{%block main_foot%} +
+– – +
+ + +{%endblock%} diff --git a/archaeological_operations/templates/ishtar/sheet_operationsource_window.html b/archaeological_operations/templates/ishtar/sheet_operationsource_window.html new file mode 100644 index 000000000..8cd2c7fa1 --- /dev/null +++ b/archaeological_operations/templates/ishtar/sheet_operationsource_window.html @@ -0,0 +1,3 @@ +{% extends "ishtar/sheet_operationsource.html" %} +{% block main_head %}{%endblock%} +{% block main_foot %}{%endblock%} diff --git a/archaeological_operations/urls.py b/archaeological_operations/urls.py index 68ac0bad0..76723deab 100644 --- a/archaeological_operations/urls.py +++ b/archaeological_operations/urls.py @@ -21,6 +21,7 @@ from django.conf.urls.defaults import * from ishtar_common.wizards import check_rights import views +import models # be carreful: each check_rights must be relevant with ishtar_menu @@ -104,7 +105,7 @@ urlpatterns += patterns( url(r'revert-operation/(?P.+)/(?P.+)$', 'revert_operation', name='revert-operation'), url(r'show-operation(?:/(?P.+))?/(?P.+)?$', - 'show_operation', name='show-operation'), + 'show_operation', name=models.Operation.SHOW_URL), url(r'show-historized-operation/(?P.+)?/(?P.+)?$', 'show_operation', name='show-historized-operation'), url(r'get-administrativeactop/(?P.+)?$', @@ -125,6 +126,8 @@ urlpatterns += patterns( url(r'generatedoc-administrativeactop/(?P.+)?/(?P.+)?$', 'generatedoc_administrativeactop', name='generatedoc-administrativeactop'), + url(r'show-operationsource(?:/(?P.+))?/(?P.+)?$', + 'show_operationsource', name=models.OperationSource.SHOW_URL), url(r'get-operationsource/(?P.+)?$', 'get_operationsource', name='get-operationsource'), url(r'dashboard_operation/$', 'dashboard_operation', diff --git a/archaeological_operations/views.py b/archaeological_operations/views.py index 8d15c80ee..e8f458bc9 100644 --- a/archaeological_operations/views.py +++ b/archaeological_operations/views.py @@ -151,6 +151,7 @@ get_operation = get_item( show_operation = show_item(models.Operation, 'operation') revert_operation = revert_item(models.Operation) +show_operationsource = show_item(models.OperationSource, 'operationsource') get_operationsource = get_item( models.OperationSource, 'get_operationsource', 'operationsource', diff --git a/ishtar_common/__init__.py b/ishtar_common/__init__.py index 7b8a90c36..84ec7c204 100644 --- a/ishtar_common/__init__.py +++ b/ishtar_common/__init__.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -# Copyright (C) 2014 Étienne Loks +# Copyright (C) 2014-2015 Étienne Loks from django.utils.translation import ugettext as _ @@ -10,8 +10,10 @@ _(u"email address") VERSION = (0, 9) +_(u"Related item") + + def get_version(): return u'.'.join((unicode(num) for num in VERSION)) __version__ = get_version() - diff --git a/ishtar_common/models.py b/ishtar_common/models.py index f720dc5ab..ec3d2e2a6 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -2153,7 +2153,7 @@ class Source(models.Model): item_number = models.IntegerField(_(u"Item number"), default=1) reference = models.CharField(_(u"Ref."), max_length=25, null=True, blank=True) - internal_reference = models.CharField(_(u"Internal reference"), + internal_reference = models.CharField(_(u"Internal ref."), max_length=25, null=True, blank=True) description = models.TextField(_(u"Description"), blank=True, null=True) comment = models.TextField(_(u"Comment"), blank=True, null=True) @@ -2167,6 +2167,13 @@ class Source(models.Model): def __unicode__(self): return self.title + @property + def associated_filename(self): + values = [unicode(getattr(self, attr)) + for attr in ('source_type', 'title') + if getattr(self, attr)] + return slugify(u"-".join(values)) + if settings.COUNTRY == 'fr': class Arrondissement(models.Model): name = models.CharField(u"Nom", max_length=30) diff --git a/ishtar_common/templates/ishtar/sheet_source.html b/ishtar_common/templates/ishtar/sheet_source.html new file mode 100644 index 000000000..044d1b89d --- /dev/null +++ b/ishtar_common/templates/ishtar/sheet_source.html @@ -0,0 +1,25 @@ +{% extends "ishtar/sheet.html" %} +{% load i18n window_field window_link %} +{% block content %} +{% block export %} +
TO BE DEFINED
+{% endblock %} +{% block general %} +{% field "Title" item.title %} +{% field "Source type" item.source_type %} +{% field "Format type" item.format_type %} +{% field "Scale" item.scale %} +{% field_url "Web link" item.associated_url %} +{% field_multiple "Authors" item.authors %} +{% field "Item number" item.item_number %} +{% field "Ref." item.reference %} +{% field "Internal ref." item.internal_reference %} +{% field "Description" item.description %} +{% field "Comment" item.comment %} +{% field "Additional information" item.additional_information %} +{% endblock %} +{% block related %} +{% field "Related item" item.owner %} +{% endblock %} +{% endblock %} + diff --git a/ishtar_common/templatetags/window_field.py b/ishtar_common/templatetags/window_field.py index 21828c5bd..11d00d7c9 100644 --- a/ishtar_common/templatetags/window_field.py +++ b/ishtar_common/templatetags/window_field.py @@ -11,6 +11,8 @@ def field(caption, data, pre_data='', post_data=''): @register.inclusion_tag('ishtar/blocks/window_field_url.html') def field_url(caption, link, link_name=''): + if not link.startswith('http://'): + link = 'http://' + link return {'caption': caption, 'link': link, "link_name": link_name} -- cgit v1.2.3