diff options
Diffstat (limited to 'ishtar_common')
| -rw-r--r-- | ishtar_common/forms_common.py | 10 | ||||
| -rw-r--r-- | ishtar_common/locale/django.pot | 36 | ||||
| -rw-r--r-- | ishtar_common/static/js/ishtar.js | 18 | ||||
| -rw-r--r-- | ishtar_common/static/media/style.css | 18 | ||||
| -rw-r--r-- | ishtar_common/static/template.odt | bin | 7013 -> 8034 bytes | |||
| -rw-r--r-- | ishtar_common/templates/blocks/JQueryJqGrid.html | 2 | ||||
| -rw-r--r-- | ishtar_common/templates/blocks/form_flex_snippet.html | 21 | ||||
| -rw-r--r-- | ishtar_common/templates/ishtar/blocks/window_tables/dynamic_documents.html | 8 | ||||
| -rw-r--r-- | ishtar_common/templatetags/window_tables.py | 58 | ||||
| -rw-r--r-- | ishtar_common/views.py | 5 | ||||
| -rw-r--r-- | ishtar_common/widgets.py | 2 |
11 files changed, 108 insertions, 70 deletions
diff --git a/ishtar_common/forms_common.py b/ishtar_common/forms_common.py index 5863baab2..ae72d173f 100644 --- a/ishtar_common/forms_common.py +++ b/ishtar_common/forms_common.py @@ -223,8 +223,8 @@ class BaseOrganizationForm(forms.ModelForm): class PersonSelect(TableSelect): - name = forms.CharField(label=_(u"Name"), max_length=30) - surname = forms.CharField(label=_(u"Surname"), max_length=20) + name = forms.CharField(label=_(u"Name"), max_length=200) + surname = forms.CharField(label=_(u"Surname"), max_length=50) email = forms.CharField(label=_(u"Email"), max_length=75) person_types = forms.ChoiceField(label=_(u"Type"), choices=[]) attached_to = forms.IntegerField( @@ -254,11 +254,11 @@ class SimplePersonForm(NewItemForm): form_label = _("Identity") associated_models = {'attached_to': models.Organization} title = forms.ChoiceField(label=_("Title"), choices=models.Person.TYPE) - surname = forms.CharField(label=_(u"Surname"), max_length=20, + surname = forms.CharField(label=_(u"Surname"), max_length=50, validators=[name_validator]) - name = forms.CharField(label=_(u"Name"), max_length=30, + name = forms.CharField(label=_(u"Name"), max_length=200, validators=[name_validator]) - raw_name = forms.CharField(label=_(u"Raw name"), max_length=255, + raw_name = forms.CharField(label=_(u"Raw name"), max_length=300, required=False) address = forms.CharField(label=_(u"Address"), widget=forms.Textarea, required=False) diff --git a/ishtar_common/locale/django.pot b/ishtar_common/locale/django.pot index 6f2d58879..0610c5e95 100644 --- a/ishtar_common/locale/django.pot +++ b/ishtar_common/locale/django.pot @@ -422,7 +422,7 @@ msgstr "" msgid "Account management" msgstr "" -#: ishtar_menu.py:34 models.py:853 views.py:1115 +#: ishtar_menu.py:34 models.py:853 views.py:1120 msgid "Global variables" msgstr "" @@ -454,11 +454,11 @@ msgstr "" msgid "Imports" msgstr "" -#: ishtar_menu.py:99 views.py:1123 +#: ishtar_menu.py:99 views.py:1128 msgid "New import" msgstr "" -#: ishtar_menu.py:103 views.py:1137 +#: ishtar_menu.py:103 views.py:1142 msgid "Current imports" msgstr "" @@ -644,15 +644,15 @@ msgstr "" msgid "Operation source" msgstr "" -#: models.py:1259 views.py:940 views.py:991 +#: models.py:1259 views.py:945 views.py:996 msgid "Archaeological files" msgstr "" -#: models.py:1261 views.py:943 views.py:999 +#: models.py:1261 views.py:948 views.py:1004 msgid "Context records" msgstr "" -#: models.py:1263 views.py:945 views.py:1002 +#: models.py:1263 views.py:950 views.py:1007 msgid "Finds" msgstr "" @@ -1163,34 +1163,34 @@ msgstr "" msgid "Organization deletion" msgstr "" -#: views.py:637 templates/base.html:80 +#: views.py:642 templates/base.html:80 #: templates/ishtar/sheet_organization.html:35 #: templatetags/link_to_window.py:16 msgid "Details" msgstr "" -#: views.py:868 views.py:922 +#: views.py:873 views.py:927 msgid "Operation not permitted." msgstr "" -#: views.py:870 +#: views.py:875 #, python-format msgid "New %s" msgstr "" -#: views.py:941 views.py:995 +#: views.py:946 views.py:1000 msgid "Operations" msgstr "" -#: views.py:1184 templates/ishtar/import_list.html:43 +#: views.py:1189 templates/ishtar/import_list.html:43 msgid "Link unmatched items" msgstr "" -#: views.py:1199 +#: views.py:1204 msgid "Delete import" msgstr "" -#: views.py:1258 views.py:1274 +#: views.py:1263 views.py:1279 msgid "Corporation manager" msgstr "" @@ -1198,11 +1198,11 @@ msgstr "" msgid "Search..." msgstr "" -#: widgets.py:602 templatetags/window_tables.py:80 +#: widgets.py:602 templatetags/window_tables.py:68 msgid "No results" msgstr "" -#: widgets.py:603 templatetags/window_tables.py:81 +#: widgets.py:603 templatetags/window_tables.py:69 msgid "Loading..." msgstr "" @@ -1571,7 +1571,11 @@ msgstr "" msgid "." msgstr "" -#: templates/blocks/form_flex_snippet.html:10 +#: templates/blocks/form_flex_snippet.html:12 +msgid "Show / hide advanced search" +msgstr "" + +#: templates/blocks/form_flex_snippet.html:18 #: templates/blocks/form_snippet.html:9 msgid "Help" msgstr "" diff --git a/ishtar_common/static/js/ishtar.js b/ishtar_common/static/js/ishtar.js index c50d050ef..9af5cf2b0 100644 --- a/ishtar_common/static/js/ishtar.js +++ b/ishtar_common/static/js/ishtar.js @@ -41,6 +41,16 @@ $(document).ready(function(){ {item:'operation', value:$("#current_operation").val()} ); }); + $("#current_contextrecord").change(function(){ + $.post('/' + url_path + 'update-current-item/', + {item:'contextrecord', value:$("#current_contextrecord").val()} + ); + }); + $("#current_find").change(function(){ + $.post('/' + url_path + 'update-current-item/', + {item:'find', value:$("#current_find").val()} + ); + }); if ($(document).height() < 1.5*$(window).height()){ $('#to_bottom_arrow').hide(); $('#to_top_arrow').hide(); @@ -177,3 +187,11 @@ function closeAllWindows(){ jQuery("#window > div").hide("slow"); jQuery("#window").html(""); } + +function show_hide_flex(id){ + if ($(id).is(':hidden')){ + $(id).css('display', 'flex'); + } else { + $(id).hide(); + } +} diff --git a/ishtar_common/static/media/style.css b/ishtar_common/static/media/style.css index 2a0079706..4467a0639 100644 --- a/ishtar_common/static/media/style.css +++ b/ishtar_common/static/media/style.css @@ -167,7 +167,7 @@ button, input[type=submit], button.submit{ border:1px solid #FFF; margin:6px; font-size:0.9em; - padding:4px 3px; + padding:4px 8px; border-radius:4px; -moz-border-radius:4px; -webkit-border-radius:4px; @@ -179,6 +179,18 @@ button:hover, input[type=submit]:hover{ border:1px solid #922; } +button.ui-widget-header { + font-weight: normal; + border:1px solid #f8b950; + background: #f8b950; +} + +button.ui-widget-header:hover { + color:#fff; + border:1px solid #f8b950; + background: #f8b950; +} + textarea, input[type=text], input[type=password], @@ -204,7 +216,7 @@ input[role=textbox]:focus{ border:1px solid #D14; } -.hidden{ +ul.form-flex.hidden, .hidden{ display:none; } @@ -266,7 +278,7 @@ div#validation-bar.big{ } a.button{ - padding:0.5em; + padding: 8px; } #reset_wizards{ diff --git a/ishtar_common/static/template.odt b/ishtar_common/static/template.odt Binary files differindex d1d0515bf..87b578800 100644 --- a/ishtar_common/static/template.odt +++ b/ishtar_common/static/template.odt diff --git a/ishtar_common/templates/blocks/JQueryJqGrid.html b/ishtar_common/templates/blocks/JQueryJqGrid.html index 1639c70f2..063a3c1da 100644 --- a/ishtar_common/templates/blocks/JQueryJqGrid.html +++ b/ishtar_common/templates/blocks/JQueryJqGrid.html @@ -1,6 +1,6 @@ {% load i18n %} -<button id='search_{{name}}' class='submit'>{% trans "Search" %}</button> +<button id='search_{{name}}' class='submit ui-widget-header'>{% trans "Search" %}</button> {% if url_new %} <p><a href="#" onclick="open_window('{{url_new}}');">{{new_message}}</a></p> diff --git a/ishtar_common/templates/blocks/form_flex_snippet.html b/ishtar_common/templates/blocks/form_flex_snippet.html index 03d8b15f0..97ac37b44 100644 --- a/ishtar_common/templates/blocks/form_flex_snippet.html +++ b/ishtar_common/templates/blocks/form_flex_snippet.html @@ -1,14 +1,25 @@ {% load i18n %} -<ul class='form-flex'> - {% if form.non_field_errors %}<li class='errors'> + {% if form.non_field_errors %}<p class='errors'> {{form.non_field_errors}} - </li>{%endif%} - {% for field in form %}{% if not field.is_hidden %} + </p>{%endif%} + {% for hidden in form.hidden_fields %}{{ hidden }}{% endfor %} + {% for field in form.visible_fields %} +{% if forloop.counter0 == 0 %} +<ul class='form-flex head-form'> +{% endif %} +{% if forloop.counter0 == 6 %} +</ul> +<p class='center'><a href='#' onclick='show_hide_flex(".tail-form");return false'>{% trans "Show / hide advanced search" %}</a></p> +<ul class='form-flex tail-form hidden'> +{% endif %} <li{% if field.field.required %} class='required'{% endif %}> {{ field.label_tag }} <p class='input'>{{ field.errors }}{{field|safe}}</p>{% if field.help_text %} <a href="#{{field.auto_id}}" class="help_display" title="{% trans "Help"%}">?</a> <div class="help_text" id="{{field.auto_id}}_help"> {{field.help_text}}</div> - {%endif%}</li>{% else %}{{field}}{% endif %}{% endfor %} + {%endif%}</li> +{% if forloop.last %} </ul> +{% endif %} +{% endfor %} diff --git a/ishtar_common/templates/ishtar/blocks/window_tables/dynamic_documents.html b/ishtar_common/templates/ishtar/blocks/window_tables/dynamic_documents.html index 76172d3ac..7239b64fc 100644 --- a/ishtar_common/templates/ishtar/blocks/window_tables/dynamic_documents.html +++ b/ishtar_common/templates/ishtar/blocks/window_tables/dynamic_documents.html @@ -7,10 +7,10 @@ <div id='foot_{{name}}' class='gridfooter'> {% if source_full %} {% trans "Export as CSV" %} ({{encoding}}) -<a href='{{simple_source}}csv{{ source_attrs }}' target='_blank'>{% trans "simple" %}</a> - -<a href='{{source_full}}csv{{ source_attrs }}' target='_blank'>{% trans "full" %}</a> +<a href='{{simple_source}}csv{{ source_attrs|safe }}' target='_blank'>{% trans "simple" %}</a> - +<a href='{{source_full}}csv{{ source_attrs|safe }}' target='_blank'>{% trans "full" %}</a> {% else %} -<a href="{{simple_source}}csv{{ source_attrs }}" target="_blank">{% trans "Export as CSV" %} ({{encoding}})</a> +<a href="{{simple_source}}csv{{ source_attrs|safe }}" target="_blank">{% trans "Export as CSV" %} ({{encoding}})</a> {% endif %} </div> @@ -19,7 +19,7 @@ setTimeout( function(){ $("#grid_{{name}}").jqGrid({ - url:'{{source}}', + url:'{{source|safe}}', datatype: "json", mtype: 'GET', colNames:['id', '', {{col_names|safe}}], diff --git a/ishtar_common/templatetags/window_tables.py b/ishtar_common/templatetags/window_tables.py index 687b2cf49..cdd681b52 100644 --- a/ishtar_common/templatetags/window_tables.py +++ b/ishtar_common/templatetags/window_tables.py @@ -6,11 +6,18 @@ from django.conf import settings from django.core.urlresolvers import resolve from django.template.defaultfilters import slugify from django.template.loader import get_template +from django.utils.safestring import mark_safe from django.utils.translation import ugettext_lazy as _ from ishtar_common.forms import reverse_lazy from ishtar_common.widgets import JQueryJqGrid +from archaeological_files.models import File +from archaeological_operations.models import OperationSource, Operation +from archaeological_context_records.models import ContextRecord, \ + ContextRecordSource +from archaeological_finds.models import Find, FindSource + register = template.Library() @@ -19,40 +26,21 @@ def table_document(caption, data): return {'caption': caption, 'data': data} ASSOCIATED_MODELS = {} -try: - from archaeological_files.models import File - ASSOCIATED_MODELS['files'] = (File, 'get-file', '') -except: - pass - -try: - from archaeological_operations.models import OperationSource, Operation - ASSOCIATED_MODELS['operation_docs'] = (OperationSource, - 'get-operationsource', '') - ASSOCIATED_MODELS['operations'] = (Operation, 'get-operation', '') -except: - pass - -try: - from archaeological_context_records.models import ContextRecord, \ - ContextRecordSource - ASSOCIATED_MODELS['context_records'] = (ContextRecord, 'get-contextrecord', - 'get-contextrecord-full') - ASSOCIATED_MODELS['context_records_for_ope'] = ( - ContextRecord, - 'get-contextrecord-for-ope', 'get-contextrecord-full') - ASSOCIATED_MODELS['context_records_docs'] = (ContextRecordSource, - 'get-contextrecordsource', '') -except: - pass - -try: - from archaeological_finds.models import Find - ASSOCIATED_MODELS['finds'] = (Find, 'get-find', 'get-find-full') - ASSOCIATED_MODELS['finds_for_ope'] = ( - Find, 'get-find-for-ope', 'get-find-full') -except: - pass +ASSOCIATED_MODELS['files'] = (File, 'get-file', '') +ASSOCIATED_MODELS['operation_docs'] = (OperationSource, + 'get-operationsource', '') +ASSOCIATED_MODELS['operations'] = (Operation, 'get-operation', '') +ASSOCIATED_MODELS['context_records'] = (ContextRecord, 'get-contextrecord', + 'get-contextrecord-full') +ASSOCIATED_MODELS['context_records_for_ope'] = ( + ContextRecord, + 'get-contextrecord-for-ope', 'get-contextrecord-full') +ASSOCIATED_MODELS['context_records_docs'] = (ContextRecordSource, + 'get-contextrecordsource', '') +ASSOCIATED_MODELS['finds'] = (Find, 'get-find', 'get-find-full') +ASSOCIATED_MODELS['finds_for_ope'] = ( + Find, 'get-find-for-ope', 'get-find-full') +ASSOCIATED_MODELS['finds_docs'] = (FindSource, 'get-findsource', '') @register.simple_tag(takes_context=True) @@ -64,7 +52,7 @@ def dynamic_table_document(context, caption, associated_model, key, value, grid = JQueryJqGrid(None, None, model, table_cols=table_cols) source = unicode(reverse_lazy(url)) source_full = unicode(reverse_lazy(url_full)) if url_full else '' - source_attrs = '?{}={}'.format(key, value) + source_attrs = mark_safe('?submited=1&{}={}'.format(key, value)) if output == 'html': col_names, extra_cols = grid.get_cols() t = get_template('ishtar/blocks/window_tables/dynamic_documents.html') diff --git a/ishtar_common/views.py b/ishtar_common/views.py index 5ea53374d..54eb9164f 100644 --- a/ishtar_common/views.py +++ b/ishtar_common/views.py @@ -572,7 +572,12 @@ def get_item(model, func_name, default_name, extra_request_keys=[], datas = [] if old: items = [item.get_previous(old) for item in items] + c_ids = [] for item in items: + # manual deduplicate when distinct is not enough + if item.pk in c_ids: + continue + c_ids.append(item.pk) data = [item.pk] for keys in table_cols: if type(keys) not in (list, tuple): diff --git a/ishtar_common/widgets.py b/ishtar_common/widgets.py index 57aa8cf69..b8b104a61 100644 --- a/ishtar_common/widgets.py +++ b/ishtar_common/widgets.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -# Copyright (C) 2010-2015 Étienne Loks <etienne.loks_AT_peacefrogsDOTnet> +# Copyright (C) 2010-2016 Étienne Loks <etienne.loks_AT_peacefrogsDOTnet> # Copyright (C) 2007 skam <massimo dot scamarcia at gmail.com> # (http://djangosnippets.org/snippets/233/) |
