summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@proxience.com>2015-12-29 18:26:54 +0100
committerÉtienne Loks <etienne.loks@proxience.com>2015-12-29 18:28:18 +0100
commit70d050cb7de7c5620cf5992db5a281669cfef958 (patch)
tree648da5accc2a93a9ff5c0c80dd1ddc09f6bc708f
parent535d091d8b2ecacbcc9ae7d32a80596aa60ed62f (diff)
downloadIshtar-70d050cb7de7c5620cf5992db5a281669cfef958.tar.bz2
Ishtar-70d050cb7de7c5620cf5992db5a281669cfef958.zip
Add a template for operation sources
-rw-r--r--archaeological_operations/models.py2
-rw-r--r--archaeological_operations/templates/ishtar/sheet_operationsource.html15
-rw-r--r--archaeological_operations/templates/ishtar/sheet_operationsource_pdf.html18
-rw-r--r--archaeological_operations/templates/ishtar/sheet_operationsource_window.html3
-rw-r--r--archaeological_operations/urls.py5
-rw-r--r--archaeological_operations/views.py1
-rw-r--r--ishtar_common/__init__.py6
-rw-r--r--ishtar_common/models.py9
-rw-r--r--ishtar_common/templates/ishtar/sheet_source.html25
-rw-r--r--ishtar_common/templatetags/window_field.py2
10 files changed, 82 insertions, 4 deletions
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}}
+<h1>{% trans "Operation source"%}</h1>
+{% endblock %}
+
+{% block export %}
+<div class='tool'>{%trans "Export as:"%} <a href='{% url show-operationsource item.pk "odt" %}'>{%trans "OpenOffice.org file"%}</a>, <a href='{% url show-operationsource item.pk "pdf" %}'>{%trans "PDF file"%}</a></div>
+{% 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 %}
+<link rel="stylesheet" href="{{STATIC_URL}}/media/style_basic.css" />
+{% endblock %}
+{% block main_head %}
+{{ block.super }}
+<div id="pdfheader">
+Ishtar &ndash; {{APP_NAME}} &ndash; {{item}}
+</div>
+{% endblock %}
+{%block head_sheet%}{%endblock%}
+{%block main_foot%}
+<div id="pdffooter">
+&ndash; <pdf:pagenumber/> &ndash;
+</div>
+</body>
+</html>
+{%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<pk>.+)/(?P<date>.+)$',
'revert_operation', name='revert-operation'),
url(r'show-operation(?:/(?P<pk>.+))?/(?P<type>.+)?$',
- 'show_operation', name='show-operation'),
+ 'show_operation', name=models.Operation.SHOW_URL),
url(r'show-historized-operation/(?P<pk>.+)?/(?P<date>.+)?$',
'show_operation', name='show-historized-operation'),
url(r'get-administrativeactop/(?P<type>.+)?$',
@@ -125,6 +126,8 @@ urlpatterns += patterns(
url(r'generatedoc-administrativeactop/(?P<pk>.+)?/(?P<template_pk>.+)?$',
'generatedoc_administrativeactop',
name='generatedoc-administrativeactop'),
+ url(r'show-operationsource(?:/(?P<pk>.+))?/(?P<type>.+)?$',
+ 'show_operationsource', name=models.OperationSource.SHOW_URL),
url(r'get-operationsource/(?P<type>.+)?$',
'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 <etienne.loks_AT_peacefrogsDOTnet>
+# Copyright (C) 2014-2015 Étienne Loks <etienne.loks_AT_peacefrogsDOTnet>
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 %}
+<div class='tool'>TO BE DEFINED</div>
+{% 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}