From 6c4c940ec44a9e2984be03fc9a13cf2857bded84 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Fri, 18 Feb 2011 04:55:58 +0100 Subject: Work on sheet mecanism (refs #227) --- ishtar/furnitures/urls.py | 2 + ishtar/furnitures/views.py | 19 ++++- ishtar/furnitures/widgets.py | 3 +- ishtar/templates/base.html | 7 +- ishtar/templates/sheet.html | 7 ++ ishtar/templates/sheet_file.html | 119 +++++++++++++++++++++++++++++++ ishtar/templates/wizard_file_sheet.html | 120 -------------------------------- static/js/ishtar.js | 15 ++++ static/media/style.css | 69 ++++++++++++++++++ 9 files changed, 236 insertions(+), 125 deletions(-) create mode 100644 ishtar/templates/sheet.html create mode 100644 ishtar/templates/sheet_file.html delete mode 100644 ishtar/templates/wizard_file_sheet.html diff --git a/ishtar/furnitures/urls.py b/ishtar/furnitures/urls.py index 7d223df58..deaea4248 100644 --- a/ishtar/furnitures/urls.py +++ b/ishtar/furnitures/urls.py @@ -87,6 +87,8 @@ urlpatterns += patterns('ishtar.furnitures.views', name='autocomplete-file'), url(BASE_URL + r'get-file/(?P.+)?$', 'get_file', name='get-file'), + url(BASE_URL + r'show-file/(?P.+)?$', 'show_file', + name='show-file'), url(BASE_URL + r'autocomplete-operation/$', 'autocomplete_operation', name='autocomplete-operation'), url(BASE_URL + r'get-operation/(?P.+)?$', 'get_operation', diff --git a/ishtar/furnitures/views.py b/ishtar/furnitures/views.py index c4dd517fb..4e0001287 100644 --- a/ishtar/furnitures/views.py +++ b/ishtar/furnitures/views.py @@ -30,6 +30,7 @@ from django.template import RequestContext from django.shortcuts import render_to_response, redirect from django.utils.translation import ugettext, ugettext_lazy as _ from django.core.exceptions import ObjectDoesNotExist +from django.core.urlresolvers import reverse from django.db.models import Q from django.core import serializers @@ -182,10 +183,14 @@ def get_item(model, func_name, default_name, extra_request_keys=[]): else: data.append(val and unicode(val) or u"") datas.append(data) + link_template = "%s" % \ + (unicode(_("Details"))) if data_type == "json": rows = [] for data in datas: - res = {'id':data[0]} + res = {'id':data[0], + 'link':link_template % reverse('show-'+default_name, + args=[data[0]])} for idx, value in enumerate(data[1:]): if value: res[model.TABLE_COLS[idx].split('.')[-1]] = value @@ -218,7 +223,19 @@ def get_item(model, func_name, default_name, extra_request_keys=[]): return func +def show_item(model, name): + def func(request, pk, **dct): + try: + item = model.objects.get(pk=pk) + except ObjectDoesNotExist: + return HttpResponse(None) + dct['item'] = item + return render_to_response('sheet_%s.html' % name, dct, + context_instance=RequestContext(request)) + return func + get_file = get_item(models.File, 'get_file', 'file') +show_file = show_item(models.File, 'file') def autocomplete_operation(request, non_closed=True): if not request.user.has_perm('furnitures.view_operation', models.Operation)\ diff --git a/ishtar/furnitures/widgets.py b/ishtar/furnitures/widgets.py index 34fa24357..5d184f123 100644 --- a/ishtar/furnitures/widgets.py +++ b/ishtar/furnitures/widgets.py @@ -204,9 +204,10 @@ jQuery("#grid_%(name)s").jqGrid({ url:'%(source)s', datatype: "json", mtype: 'GET', - colNames:['id', %(col_names)s], + colNames:['id', '', %(col_names)s], colModel:[ {name:'id', index:'id', hidden:true}, +{name:'link', index:'link', width:80}, %(extra_cols)s ], sortname: 'value', diff --git a/ishtar/templates/base.html b/ishtar/templates/base.html index e7570e6c3..7bfc579bb 100644 --- a/ishtar/templates/base.html +++ b/ishtar/templates/base.html @@ -4,7 +4,6 @@ - {% block title %}Ishtar{% if APP_NAME %} - {{APP_NAME}}{%endif%}{% endblock %} @@ -16,6 +15,7 @@ + {% block extra_head %} {% endblock %} @@ -23,14 +23,15 @@ +
diff --git a/ishtar/templates/sheet.html b/ishtar/templates/sheet.html new file mode 100644 index 000000000..9d1305c1d --- /dev/null +++ b/ishtar/templates/sheet.html @@ -0,0 +1,7 @@ +{% load i18n %} +
+ +
+{% block content %}{% endblock %} +
+
diff --git a/ishtar/templates/sheet_file.html b/ishtar/templates/sheet_file.html new file mode 100644 index 000000000..67b48d26b --- /dev/null +++ b/ishtar/templates/sheet_file.html @@ -0,0 +1,119 @@ +{% extends "sheet.html" %} +{% load i18n %} +{% block content %} +

{{ item.year }}

+

{{ item.numeric_reference }}

+ +

{{ item.internal_reference }}

+ +

{{ item.history.all.0.history_date }}

+{% if item.reception_date %}

{%trans "Reception date"%} : {{ item.reception_date }}

{% endif %} +{% comment %} +

{%trans "Creation date"%} : {% item.creation_date %}

+{% if item.deadline_date and not item.acts %} +

{%trans "Deadline"%} : {% item.deadline_date %}

+{% endif %} + +

{%trans "Responsible"%} : {% item.responsible %}

+ +{% if item.is_active %} +

{%trans "Active file"%}

+{% endif %} +{% if item.is_inactive %} +

{%trans "Closed file"%}

+

{%trans "Closure date" %} : {% item.closure_date %} {%trans "by" %} {% item.closer_user%}

+{% endif %} + +

{%trans "Type"%} : {% item.type %}

+ +{% if item.related %}

{%trans "Related file"%} : {% item.related %}

{% endif %} + + +

{%trans "Communes"%} : {% item.communes %}

+ +

{%trans "Principal adress"%} : {% item.princ_adress %}

+

{%trans "Complementary adress"%} : {% item.complem_adress %}

+

{%trans "Postal code"%} : {% item.postal_code %}

+ + + +

{%trans "Surface"%} : {% item.surface %} ({% item.surface_ha %) ha)

+ + + + +{% if item.is_preventive %} +

{%trans "Planed surface"%} : {% item.planed_surface %} ({% item.planed_surface_ha %) ha)

+

{%trans "Saisine type"%} : {% item.saisine_type %}

+ {% if item.service %}

{%trans "Service"%} : {% item.service %}

{% endif %} + {% if item.permit_type %}

{%trans "Permit type"%} : {% item.permit_type %}

{% endif %} + {% if item.permit_ref %}

{%trans "Permit reference"%} : {% item.permit_ref %}

{% endif %} + {% if item.contractor_org %}

{%trans "Contractor organisation"%} : {% item.contractor_org %}

{% endif %} + {% if item.contractor %}

{%trans "Contractor"%} : {% item.contractor %}

{% endif %} +

{%trans "Numerical reference"%} : {% item.index %}

+{% endif %} + +

{%trans "Comments"%} : {% item.comments %}

+ + + + + + + {% for label, in item.data_acts %} + + {% endfor %} + + {% for data, in item.data_acts %} + + + + + + + {% endfor %} +
{%trans "Admninistrative acts"%}
{{label}}
{{year}}{{reference}}{{type}}{{date}}
+ + + + + + + {% for label, in item.data_ope %} + + {% endfor %} + + {% for data, in item.data_ope %} + + + + + + + + + + + {% endfor %} +
{%trans "Associated operations"%}
{{label}}
{{year}}{{reference}}{{patriarche}}{{type}}{{head_scientist}}{{date_debut}}{{date_fin}}{{link_to_ope_sheet}}
+ + + + + + + {% for label, in item.ope.data_acts %} + + {% endfor %} + + {% for data, in item.ope.data_acts %} + + + + + + + {% endfor %} +
{%trans "Admninistrative acts linked to associated operations"%}
{{label}}
{{year}}{{reference}}{{type}}{{date}}
+{% endcomment %} +{% endblock %} diff --git a/ishtar/templates/wizard_file_sheet.html b/ishtar/templates/wizard_file_sheet.html deleted file mode 100644 index b6a530a3b..000000000 --- a/ishtar/templates/wizard_file_sheet.html +++ /dev/null @@ -1,120 +0,0 @@ -{% extends "base.html" %} -{% load i18n %} -{% block content %} - -

{%trans "File description sheet"%}

-

{%trans "Year"%} : {% file.year %}

-

{%trans "Numerical reference"%} : {% file.index %}

- -

{%trans "File's name"%} : {% file.internal_ref %}

- -

{%trans "Edition date"%} : {% date %}

-

{%trans "Reception date"%} : {% file.recept_date %}

-

{%trans "Creation date"%} : {% file.crea_date %}

-{% if file.deadline_date and not file.acts %} -

{%trans "Deadline"%} : {% file.deadline_date %}

-{% endif %} - -

{%trans "Responsible"%} : {% file.responsible %}

- -{% if file.is_active %} -

{%trans "Active file"%}

-{% endif %} -{% if file.is_inactive %} -

{%trans "Closed file"%}

-

{%trans "Closure date" %} : {% file.closure_date %} {%trans "by" %} {% file.closer_user%}

-{% endif %} - -

{%trans "Type"%} : {% file.type %}

- -{% if file.related %}

{%trans "Related file"%} : {% file.related %}

{% endif %} - - -

{%trans "Communes"%} : {% file.communes %}

- -

{%trans "Principal adress"%} : {% file.princ_adress %}

-

{%trans "Complementary adress"%} : {% file.complem_adress %}

-

{%trans "Postal code"%} : {% file.postal_code %}

- - - -

{%trans "Surface"%} : {% file.surface %} ({% file.surface_ha %) ha)

- - - - -{% if file.is_preventive %} -

{%trans "Planed surface"%} : {% file.planed_surface %} ({% file.planed_surface_ha %) ha)

-

{%trans "Saisine type"%} : {% file.saisine_type %}

- {% if file.service %}

{%trans "Service"%} : {% file.service %}

{% endif %} - {% if file.permit_type %}

{%trans "Permit type"%} : {% file.permit_type %}

{% endif %} - {% if file.permit_ref %}

{%trans "Permit reference"%} : {% file.permit_ref %}

{% endif %} - {% if file.contractor_org %}

{%trans "Contractor organisation"%} : {% file.contractor_org %}

{% endif %} - {% if file.contractor %}

{%trans "Contractor"%} : {% file.contractor %}

{% endif %} -

{%trans "Numerical reference"%} : {% file.index %}

-{% endif %} - -

{%trans "Comments"%} : {% file.comments %}

- - - - - - - {% for label, in file.data_acts %} - - {% endfor %} - - {% for data, in file.data_acts %} - - - - - - - {% endfor %} -
{%trans "Admninistrative acts"%}
{{label}}
{{year}}{{reference}}{{type}}{{date}}
- - - - - - - {% for label, in file.data_ope %} - - {% endfor %} - - {% for data, in file.data_ope %} - - - - - - - - - - - {% endfor %} -
{%trans "Associated operations"%}
{{label}}
{{year}}{{reference}}{{patriarche}}{{type}}{{head_scientist}}{{date_debut}}{{date_fin}}{{link_to_ope_sheet}}
- - - - - - - {% for label, in file.ope.data_acts %} - - {% endfor %} - - {% for data, in file.ope.data_acts %} - - - - - - - {% endfor %} -
{%trans "Admninistrative acts linked to associated operations"%}
{{label}}
{{year}}{{reference}}{{type}}{{date}}
- -{% endblock %} diff --git a/static/js/ishtar.js b/static/js/ishtar.js index 131a220c9..7dc1be345 100644 --- a/static/js/ishtar.js +++ b/static/js/ishtar.js @@ -45,3 +45,18 @@ $("#main_menu ul li").live('click', function(){ $(this).find('ul').show('slow'); }); +function load_window(url){ + $.ajax({ + url: url, + cache: false, + success:function(html){ + $("#window").html(html); + $("#window").show('slow'); + }, + error:function(XMLHttpRequest, textStatus, errorThrows){ + } + }); + + + +} diff --git a/static/media/style.css b/static/media/style.css index 8b2b9576a..f559ac827 100644 --- a/static/media/style.css +++ b/static/media/style.css @@ -233,3 +233,72 @@ table.confirm tr.spacer td:last-child{ .jqgrid{ cursor:pointer; } + +.ui-jqgrid a{ + color:red; + text-decoration:underline; + color:#D14; +} + +#window{ + position: absolute; + top: 50px; + width:600px; + background: #FFF; + z-index: 2000; + left: 50%; + margin-left: -300px; + border: 1px solid #AAA; + -webkit-box-shadow: 0px 0px 20px #444; + -moz-box-shadow: 0px 0px 20px #444; + text-align: left; + display:none; +} + +#window{ + width:760px; + height:90%; + position: absolute; + top: 5%; + background: #FFF; + z-index: 2000; + left: 50%; + margin-left: -380px; + -webkit-box-shadow: 0px 0px 20px #444; + -moz-box-shadow: 0px 0px 20px #444; + text-align: left; + display:none; + -moz-border-radius:8px; + -webkit-border-radius:8px; + border-radius:8px; +} + +#window .sheet{ +} + + +#window .head{ + text-align:center; + background-color:#EEE; + -webkit-border-top-left-radius: 8px; + -webkit-border-top-right-radius: 8px; + -moz-border-radius-topleft: 8px; + -moz-border-radius-topright: 8px; + border-top-left-radius: 8px; + border-top-right-radius: 8px; +} + +#window .body{ + padding:10px; +} + +#window label{ + display:inline-table; + font-weight:bold; + width:160px; +} + +#window p{ + margin:0.3em; +} + -- cgit v1.2.3