--- a/src/p4l/models/data.py Fri Sep 13 10:31:33 2013 +0200
+++ b/src/p4l/models/data.py Fri Sep 13 10:36:03 2013 +0200
@@ -171,6 +171,9 @@
isDocumentPart = models.BooleanField() #iiep:isDocumentPart
isMultilingual = models.BooleanField() #iiep:isMultilingual
+
+ def get_imprints_years(self):
+ return sorted(set([i.imprintDate for i in self.imprints.all() if i.imprintDate]))
def __unicode__(self):
return "Record id %s { identifier: %s, uri: %s, editionStatement: %s, recordType: %s, isDocumentPart: %s, notes: %s, language : %s}" \
--- a/src/p4l/settings.py Fri Sep 13 10:31:33 2013 +0200
+++ b/src/p4l/settings.py Fri Sep 13 10:36:03 2013 +0200
@@ -141,6 +141,7 @@
TEMPLATE_CONTEXT_PROCESSORS = global_settings.TEMPLATE_CONTEXT_PROCESSORS + (
'django.core.context_processors.i18n',
+ 'django.core.context_processors.request',
)
# A sample logging configuration. The only tangible logging
--- a/src/p4l/static/p4l/js/p4l.js Fri Sep 13 10:31:33 2013 +0200
+++ b/src/p4l/static/p4l/js/p4l.js Fri Sep 13 10:36:03 2013 +0200
@@ -267,9 +267,15 @@
$scope.submitRecord = function() {
$scope.saving = true;
- $scope.record.$save({recordId: context.record_id}).then(function(response) { $scope.saving=false;});
+ $scope.record.$save({recordId: context.record_id})
+ .then(function(response) {
+ $scope.saving=false;
+ });
}
+ $scope.getPreviousUrl = function() {
+ return context.urls.previous || context.urls.home;
+ }
});
--- a/src/p4l/templates/p4l/p4l_home.html Fri Sep 13 10:31:33 2013 +0200
+++ b/src/p4l/templates/p4l/p4l_home.html Fri Sep 13 10:36:03 2013 +0200
@@ -36,7 +36,7 @@
{% endif %}
<table class="table">
<thead>
- <tr><td>{% trans 'identifier' %}</td><td>{% trans 'titles' %}</td><td>{% trans 'dates' %} (années imprint)</td><td class="two_buttons">{% trans 'actions' %}</td></tr>
+ <tr><td>{% trans 'identifier' %}</td><td>{% trans 'titles' %}</td><td>{% trans 'dates' %}</td><td class="two_buttons">{% trans 'actions' %}</td></tr>
</thead>
<tbody>
{% for record in object_list %}
@@ -45,10 +45,10 @@
<td><ul>{% for t in record.titles.all %}
<li>{{ t.title }}</li>
{% endfor %}</ul></td>
- <td> </td>
+ <td>{{ record.get_imprints_years|join:", "}}</td>
<td>
<a class="btn btn-default" href="{% url 'p4l_record_view' slug=record.identifier %}"><i class="glyphicon glyphicon-eye-open"></i></a>
- <a class="btn btn-default" href="{% url 'p4l_record_edit' slug=record.identifier %}"><i class="glyphicon glyphicon-pencil"></i></a>
+ <a class="btn btn-default" href="{% url 'p4l_record_edit' slug=record.identifier %}?previous={{request.get_full_path|urlencode}}"><i class="glyphicon glyphicon-pencil"></i></a>
</td>
</tr>
{% empty %}
--- a/src/p4l/templates/p4l/record_update_form.html Fri Sep 13 10:31:33 2013 +0200
+++ b/src/p4l/templates/p4l/record_update_form.html Fri Sep 13 10:36:03 2013 +0200
@@ -28,7 +28,9 @@
csrf_token: "{{ csrf_token }}",
urls: {
base_static: "{% get_static_prefix %}",
- record_api: "{% url 'record-detail' identifier=':recordId' %}".replace("\%3A",":"),
+ record_api: "{% url 'record-detail' identifier=':recordId' %}".replace("\%3A",":"),
+ previous: "{{request.GET.previous}}",
+ home: "{% url 'p4l_home' %}"
},
query_dicts: angular.fromJson('{{ query_dicts | safe | addslashes}}'),
languages_list: angular.fromJson('{{ languages_list | safe | addslashes}}'),
@@ -43,6 +45,7 @@
{% block content %}
{% verbatim %}
<div ng-app="recordApp" ng-controller="RecordCtrl" ng-cloak>
+<form name="recordForm">
<table class="table record-table">
<thead>
<tr><td>{{'property' | translate}}</td><td>{{'value' | translate }}</td></tr>
@@ -184,10 +187,15 @@
</tr>
</tbody>
</table>
-<button type="button" class="btn btn-primary" ng-click="submitRecord()" id="record-submit">
+<button type="submit" class="btn btn-primary" id="record-submit" ng-click="submitRecord()">
<span ng-class="['glyphicon', saving?'spinner':'glyphicon-save']"></span>
<span>{{ 'Save' | translate }}</span>
</button>
+<a class="btn btn-primary" id="record-back" href="{{getPreviousUrl()}}">
+ <span class="glyphicon glyphicon-arrow-left"></span>
+ <span>{{ 'Cancel' | translate }}</span>
+</a>
+</form>
</div>
{% endverbatim %}
{% endblock %}
\ No newline at end of file
--- a/src/p4l/views.py Fri Sep 13 10:31:33 2013 +0200
+++ b/src/p4l/views.py Fri Sep 13 10:36:03 2013 +0200
@@ -6,7 +6,6 @@
'''
from django.conf import settings
-from django.utils.decorators import method_decorator
from django.views.generic import ListView, DetailView
from p4l.forms import RecordFilterForm
from p4l.models import Record
@@ -19,7 +18,7 @@
class RecordListView(ListView):
- queryset = Record.objects.select_related("language").prefetch_related('titles').distinct() # @UndefinedVariable
+ queryset = Record.objects.select_related("language").prefetch_related('titles', 'imprints').order_by('identifier') # @UndefinedVariable
paginate_by = settings.NB_RECORDS_BY_PAGE
template_name = "p4l/p4l_home.html"
form_class = RecordFilterForm
@@ -182,7 +181,7 @@
# Languages list used in drop down list
context['languages_list'] = json.dumps(settings.LANGUAGES_LIST)
-
+
return context
\ No newline at end of file