From 4473e91231794ba9082795df9441d49e461b10db Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Thu, 22 Sep 2016 09:46:06 +0200 Subject: WIP: ajaxify shortcut menu --- ishtar_common/static/js/ishtar.js | 76 +++++++++++++++++++++++++++++++++--- ishtar_common/static/media/style.css | 18 ++++++++- 2 files changed, 87 insertions(+), 7 deletions(-) (limited to 'ishtar_common/static') diff --git a/ishtar_common/static/js/ishtar.js b/ishtar_common/static/js/ishtar.js index fecefe0a9..70b056c63 100644 --- a/ishtar_common/static/js/ishtar.js +++ b/ishtar_common/static/js/ishtar.js @@ -38,22 +38,25 @@ function manage_async_link(event){ function get_next_table_id(){} function get_previous_table_id(){} +var current_operation_change = function(){ + $.post('/' + url_path + 'update-current-item/', + {item:'operation', value:$("#current_operation").val()}, + load_shortcut_menu + ); +}; + function init_shortcut_menu(html){ $("#progress").hide(); $("#context_menu").html(html); $(".chosen-select").chosen(); + chosen_ajaxify("current_operation", '/get-operation-cached/?cached_label=', + current_operation_change); $("#current_file").change(function(){ $.post('/' + url_path + 'update-current-item/', {item:'file', value:$("#current_file").val()}, load_shortcut_menu ); }); - $("#current_operation").change(function(){ - $.post('/' + url_path + 'update-current-item/', - {item:'operation', value:$("#current_operation").val()}, - load_shortcut_menu - ); - }); $("#current_contextrecord").change(function(){ $.post('/' + url_path + 'update-current-item/', {item:'contextrecord', value:$("#current_contextrecord").val()}, @@ -267,3 +270,64 @@ function show_hide_flex(id){ $(id).hide(); } } + +var delay = (function(){ + var timer = 0; + return function(callback, ms){ + clearTimeout (timer); + timer = setTimeout(callback, ms); + }; +})(); + + +function chosen_ajaxify(id, ajax_url, current_change_callback){ + $('div#' + id + '_chosen .chosen-search input').keyup(function(){ + var keyword = $('div#' + id + '_chosen .chosen-search input').val(); + var keyword_pattern = new RegExp(keyword, 'gi'); + $('div#' + id + '_chosen ul.chosen-results').empty(); + $("#"+id).empty(); + delay(function(){ + $.ajax({ + url: ajax_url + keyword, + dataType: "json", + success: function(response){ + $('#'+id).append(''); + $.map(response['rows'], function(item){ + $('#'+id).append(''); + }); + $("#"+id).trigger("chosen:updated"); + $('div#' + id + '_chosen .chosen-search input').val(keyword); + $('div#' + id + '_chosen').removeClass('chosen-container-single-nosearch'); + $('div#' + id + '_chosen .chosen-search input').removeAttr('readonly'); + $('div#' + id + '_chosen .chosen-search input').focus(); + /* + $('div#' + id + '_chosen .active-result').each(function(){ + var html = $('div#' + id + '_chosen ul.chosen-results').html(); + $('div#' + id + '_chosen ul.chosen-results').html(html.replace(keyword_pattern, function(matched){ + return '' + matched + ''; + })); + });*/ + $("#" + id).change(current_change_callback); + } + }); + }, 1000); + }); +} + + +var activate_all_search_msg = "Searches in the shortcut menu deals with all items."; +var activate_own_search_msg = "Searches in the shortcut menu deals with only your items."; + +function activate_all_search(){ + $('.activate_all_search').removeClass('disabled'); + $('.activate_own_search').addClass('disabled'); + display_info(activate_all_search_msg); + return false; +} + +function activate_own_search(){ + $('.activate_own_search').removeClass('disabled'); + $('.activate_all_search').addClass('disabled'); + display_info(activate_own_search_msg); + return false; +} diff --git a/ishtar_common/static/media/style.css b/ishtar_common/static/media/style.css index aab5063e4..2ef0ab8ac 100644 --- a/ishtar_common/static/media/style.css +++ b/ishtar_common/static/media/style.css @@ -29,6 +29,10 @@ a, a.remove { color:#D14; } +a.disabled { + color:#ccc; +} + .badge, a.add-button, #reset_wizards, @@ -425,13 +429,25 @@ div#context_menu fieldset{ border-radius: 0; } +div#action_current_items{ + display: inline-block; + vertical-align: top; + width: 70px; +} + +div#action_current_items p{ + padding: 0; + margin: 0; + text-align: center; +} + div#context_menu table{ display: inline; vertical-align: top; } div#context_menu .icon{ - padding: 0.6em 0.5em; + padding: 0.2em 0.3em; } div#context_menu ul{ -- cgit v1.2.3 From df6ea17f4b8bb1d45fe480044af80bd19742bf80 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Thu, 22 Sep 2016 19:10:49 +0200 Subject: WIP: ajaxify shortcut menu - 2 --- archaeological_context_records/urls.py | 6 ++ archaeological_context_records/views.py | 1 + archaeological_files/urls.py | 6 ++ archaeological_files/views.py | 1 + archaeological_finds/urls.py | 6 ++ archaeological_finds/views.py | 1 + archaeological_operations/urls.py | 16 ++-- ishtar_common/static/js/ishtar.js | 90 +++++++++++++++------- ishtar_common/static/media/style.css | 4 + ishtar_common/templates/base.html | 10 ++- .../templates/ishtar/blocks/shortcut_menu.html | 2 +- ishtar_common/views.py | 35 +++++---- 12 files changed, 126 insertions(+), 52 deletions(-) (limited to 'ishtar_common/static') diff --git a/archaeological_context_records/urls.py b/archaeological_context_records/urls.py index 8e218102d..368fd6d98 100644 --- a/archaeological_context_records/urls.py +++ b/archaeological_context_records/urls.py @@ -89,6 +89,12 @@ urlpatterns += patterns( url(r'get-contextrecord-full/(?P.+)?$', 'get_contextrecord', name='get-contextrecord-full', kwargs={'full': True}), + url(r'get-contextrecord-shortcut/own/(?P.+)?$', + 'get_contextrecord', name='get-own-contextrecord-shortcut', + kwargs={'full': 'shortcut', 'force_own': True}), + url(r'get-contextrecord-shortcut/(?P.+)?$', + 'get_contextrecord', name='get-contextrecord-shortcut', + kwargs={'full': 'shortcut'}), url(r'show-contextrecordsource(?:/(?P.+))?/(?P.+)?$', 'show_contextrecordsource', name=models.ContextRecordSource.SHOW_URL), url(r'get-contexrecordsource/(?P.+)?$', diff --git a/archaeological_context_records/views.py b/archaeological_context_records/views.py index 5c8bb63cc..bc95473e6 100644 --- a/archaeological_context_records/views.py +++ b/archaeological_context_records/views.py @@ -46,6 +46,7 @@ contextrecord_extra_keys = { 'parcel_2': 'operation__parcels__public_domain', 'label': 'label__icontains', 'archaeological_sites': 'operation__archaeological_sites__pk', + 'cached_label': 'cached_label__icontains', } diff --git a/archaeological_files/urls.py b/archaeological_files/urls.py index c6b932fec..914872a1f 100644 --- a/archaeological_files/urls.py +++ b/archaeological_files/urls.py @@ -75,6 +75,12 @@ urlpatterns += patterns( name='get-file'), url(r'get-file-full/(?P.+)?$', 'get_file', name='get-file-full', kwargs={'full': True}), + url(r'get-file-shortcut/own/(?P.+)?$', + 'get_file', name='get-own-file-shortcut', + kwargs={'full': 'shortcut', 'force_own': True}), + url(r'get-file-shortcut/(?P.+)?$', + 'get_file', name='get-file-shortcut', + kwargs={'full': 'shortcut'}), url(r'get-administrativeactfile/(?P.+)?$', 'get_administrativeactfile', name='get-administrativeactfile'), url(r'show-file(?:/(?P.+))?/(?P.+)?$', 'show_file', diff --git a/archaeological_files/views.py b/archaeological_files/views.py index e457c2ce7..a8053214f 100644 --- a/archaeological_files/views.py +++ b/archaeological_files/views.py @@ -91,6 +91,7 @@ get_file = get_item( 'towns__numero_insee__startswith': 'towns__numero_insee__startswith', 'name': 'name__icontains', + 'cached_label': 'cached_label__icontains', 'comment': 'comment__icontains', 'permit_reference': 'permit_reference__icontains', 'general_contractor__attached_to': diff --git a/archaeological_finds/urls.py b/archaeological_finds/urls.py index 63bc01bed..7cd261516 100644 --- a/archaeological_finds/urls.py +++ b/archaeological_finds/urls.py @@ -119,6 +119,12 @@ urlpatterns += patterns( name='get-own-find-full', kwargs={'full': True, 'force_own': True}), url(r'get-find-full/(?P.+)?$', 'get_find', name='get-find-full', kwargs={'full': True}), + url(r'get-find-shortcut/own/(?P.+)?$', + 'get_find', name='get-own-find-shortcut', + kwargs={'full': 'shortcut', 'force_own': True}), + url(r'get-find-shortcut/(?P.+)?$', + 'get_find', name='get-find-shortcut', + kwargs={'full': 'shortcut'}), url(r'get-findsource/(?P.+)?$', 'get_findsource', name='get-findsource'), url(r'get-findsource-full/(?P.+)?$', diff --git a/archaeological_finds/views.py b/archaeological_finds/views.py index 80cc6fd8c..d441559cc 100644 --- a/archaeological_finds/views.py +++ b/archaeological_finds/views.py @@ -64,6 +64,7 @@ find_extra_keys = { 'base_finds__find__description__icontains', 'base_finds__batch': 'base_finds__batch', 'basket': 'basket', + 'cached_label': 'cached_label__icontains', 'image': 'image__isnull'} get_find = get_item( diff --git a/archaeological_operations/urls.py b/archaeological_operations/urls.py index a20eccfe5..f637fd23b 100644 --- a/archaeological_operations/urls.py +++ b/archaeological_operations/urls.py @@ -100,17 +100,17 @@ urlpatterns += patterns( kwargs={'force_own': True}), url(r'get-operation/(?P.+)?$', 'get_operation', name='get-operation'), - url(r'get-operation-full/(?P.+)?$', 'get_operation', - name='get-operation-full', kwargs={'full': True}), url(r'get-operation-full/own/(?P.+)?$', 'get_operation', name='get-own-operation-full', kwargs={'full': True, 'force_own': True}), - url(r'get-operation-cached/(?P.+)?$', - 'get_operation', name='get-own-operation-cached', - kwargs={'full': 'cached'}), - url(r'get-operation-cached/own/(?P.+)?$', - 'get_operation', name='get-own-operation-cached', - kwargs={'full': 'cached', 'force_own': True}), + url(r'get-operation-full/(?P.+)?$', 'get_operation', + name='get-operation-full', kwargs={'full': True}), + url(r'get-operation-shortcut/own/(?P.+)?$', + 'get_operation', name='get-own-operation-shortcut', + kwargs={'full': 'shortcut', 'force_own': True}), + url(r'get-operation-shortcut/(?P.+)?$', + 'get_operation', name='get-operation-shortcut', + kwargs={'full': 'shortcut'}), url(r'get-available-operation-code/(?P.+)?$', 'get_available_operation_code', name='get_available_operation_code'), url(r'revert-operation/(?P.+)/(?P.+)$', diff --git a/ishtar_common/static/js/ishtar.js b/ishtar_common/static/js/ishtar.js index 70b056c63..393603b6c 100644 --- a/ishtar_common/static/js/ishtar.js +++ b/ishtar_common/static/js/ishtar.js @@ -23,8 +23,6 @@ beforeSend: function(xhr, settings) { } }}); -var shortcut_url = ''; - function manage_async_link(event){ event.preventDefault(); var url = $(this).attr('href'); @@ -38,6 +36,24 @@ function manage_async_link(event){ function get_next_table_id(){} function get_previous_table_id(){} +var shortcut_url = ''; +var get_file_url = '/get-file-shortcut/'; +var get_own_file_url = '/get-file-shortcut/own/'; +var get_operation_url = '/get-operation-shortcut/'; +var get_own_operation_url = '/get-operation-shortcut/own/'; +var get_contextrecord_url = '/get-contextrecord-shortcut/'; +var get_own_contextrecord_url = '/get-contextrecord-shortcut/own/'; +var get_find_url = '/get-find-shortcut/'; +var get_own_find_url = '/get-find-shortcut/own/'; +var shortcut_get_attr = '?submited=1&page=1&rows=10&cached_label='; + +var current_file_change = function(){ + $.post('/' + url_path + 'update-current-item/', + {item:'file', value:$("#current_file").val()}, + load_shortcut_menu + ); +}; + var current_operation_change = function(){ $.post('/' + url_path + 'update-current-item/', {item:'operation', value:$("#current_operation").val()}, @@ -45,30 +61,45 @@ var current_operation_change = function(){ ); }; +var current_contextrecord_change = function(){ + $.post('/' + url_path + 'update-current-item/', + {item:'contextrecord', value:$("#current_contextrecord").val()}, + load_shortcut_menu + ); +}; + +var current_find_change = function(){ + $.post('/' + url_path + 'update-current-item/', + {item:'find', value:$("#current_find").val()}, + load_shortcut_menu + ); +}; + +function init_shortcut_fields(){ + var is_own = $('.activate_all_search').hasClass('disabled'); + var file_url = get_file_url; + if (is_own) file_url = get_own_file_url; + chosen_ajaxify("current_file", file_url + shortcut_get_attr, + current_file_change); + var operation_url = get_operation_url; + if (is_own) operation_url = get_own_operation_url; + chosen_ajaxify("current_operation", operation_url + shortcut_get_attr, + current_operation_change); + var contextrecord_url = get_contextrecord_url; + if (is_own) contextrecord_url = get_own_contextrecord_url; + chosen_ajaxify("current_contextrecord", contextrecord_url + shortcut_get_attr, + current_contextrecord_change); + var find_url = get_find_url; + if (is_own) find_url = get_own_find_url; + chosen_ajaxify("current_find", find_url + shortcut_get_attr, + current_find_change); +} + function init_shortcut_menu(html){ $("#progress").hide(); $("#context_menu").html(html); $(".chosen-select").chosen(); - chosen_ajaxify("current_operation", '/get-operation-cached/?cached_label=', - current_operation_change); - $("#current_file").change(function(){ - $.post('/' + url_path + 'update-current-item/', - {item:'file', value:$("#current_file").val()}, - load_shortcut_menu - ); - }); - $("#current_contextrecord").change(function(){ - $.post('/' + url_path + 'update-current-item/', - {item:'contextrecord', value:$("#current_contextrecord").val()}, - load_shortcut_menu - ); - }); - $("#current_find").change(function(){ - $.post('/' + url_path + 'update-current-item/', - {item:'find', value:$("#current_find").val()}, - load_shortcut_menu - ); - }); + init_shortcut_fields(); } function display_info(msg){ @@ -291,22 +322,23 @@ function chosen_ajaxify(id, ajax_url, current_change_callback){ url: ajax_url + keyword, dataType: "json", success: function(response){ - $('#'+id).append(''); - $.map(response['rows'], function(item){ - $('#'+id).append(''); - }); + $('#'+id).append(''); + if ('rows' in response){ + $.map(response['rows'], function(item){ + $('#'+id).append(''); + }); + } $("#"+id).trigger("chosen:updated"); $('div#' + id + '_chosen .chosen-search input').val(keyword); $('div#' + id + '_chosen').removeClass('chosen-container-single-nosearch'); $('div#' + id + '_chosen .chosen-search input').removeAttr('readonly'); $('div#' + id + '_chosen .chosen-search input').focus(); - /* $('div#' + id + '_chosen .active-result').each(function(){ var html = $('div#' + id + '_chosen ul.chosen-results').html(); $('div#' + id + '_chosen ul.chosen-results').html(html.replace(keyword_pattern, function(matched){ return '' + matched + ''; })); - });*/ + }); $("#" + id).change(current_change_callback); } }); @@ -321,6 +353,7 @@ var activate_own_search_msg = "Searches in the shortcut menu deals with only you function activate_all_search(){ $('.activate_all_search').removeClass('disabled'); $('.activate_own_search').addClass('disabled'); + init_shortcut_fields(); display_info(activate_all_search_msg); return false; } @@ -328,6 +361,7 @@ function activate_all_search(){ function activate_own_search(){ $('.activate_own_search').removeClass('disabled'); $('.activate_all_search').addClass('disabled'); + init_shortcut_fields(); display_info(activate_own_search_msg); return false; } diff --git a/ishtar_common/static/media/style.css b/ishtar_common/static/media/style.css index 2ef0ab8ac..d74e0aaa2 100644 --- a/ishtar_common/static/media/style.css +++ b/ishtar_common/static/media/style.css @@ -60,6 +60,10 @@ a.add-button, font-family: 'FontAwesome', Arial, Helvetica, sans-serif; } +#context_menu .chosen-select{ + width: 400px; +} + #context_menu option.basket{ color:#000; } diff --git a/ishtar_common/templates/base.html b/ishtar_common/templates/base.html index a0cf154ac..cd7b00457 100644 --- a/ishtar_common/templates/base.html +++ b/ishtar_common/templates/base.html @@ -32,6 +32,14 @@ {% endblock %} @@ -52,7 +60,7 @@ {% csrf_token %} - + {% for val, label, selected, cls in items %}{% ifequal cls 'basket' %} {% endifequal %}{% ifequal cls 'green' %} {% endifequal %}{% ifequal cls 'orange' %} {% endifequal %}{% ifequal cls 'red' %} {% endifequal %}{{label}} {% endfor %} {% with 'show-'|add:model_name as model_url%} diff --git a/ishtar_common/views.py b/ishtar_common/views.py index eb557bb51..27b192e74 100644 --- a/ishtar_common/views.py +++ b/ishtar_common/views.py @@ -55,6 +55,7 @@ from xhtml2odt import xhtml2odt from menus import menu from archaeological_files.models import File +from archaeological_operations.models import Operation from archaeological_context_records.models import ContextRecord from archaeological_finds.models import Find @@ -199,11 +200,6 @@ def get_autocomplete_generic(model, extra={'available': True}): def shortcut_menu(request): - from archaeological_operations.models import Operation - from archaeological_files.models import File - from archaeological_context_records.models import ContextRecord - from archaeological_finds.models import Find - profile = get_current_profile() CURRENT_ITEMS = [] if profile.files: @@ -230,8 +226,8 @@ def shortcut_menu(request): if selected: cls = item.get_short_menu_class() new_selected_item = item - items.append((pk, shortify(unicode(item), 60), - selected, item.get_short_menu_class())) + items.append((pk, shortify(unicode(item), 60), + selected, item.get_short_menu_class())) # selected is not in owns - add it to the list if not new_selected_item and current: try: @@ -241,18 +237,13 @@ def shortcut_menu(request): True, item.get_short_menu_class())) except (model.DoesNotExist, ValueError): pass - if items: - dct['current_menu'].append((lbl, model_name, cls, items)) + dct['current_menu'].append((lbl, model_name, cls, items)) current_selected_item = new_selected_item return render_to_response('ishtar/blocks/shortcut_menu.html', dct, context_instance=RequestContext(request)) def get_current_items(request): - from archaeological_files.models import File - from archaeological_operations.models import Operation - from archaeological_context_records.models import ContextRecord - from archaeological_finds.models import Find currents = {} for key, model in (('file', File), ('operation', Operation), @@ -706,6 +697,22 @@ def get_item(model, func_name, default_name, extra_request_keys=[], for and_req in and_reqs: query = query & and_req + # manage hierarchic in shortcut menu + if full == 'shortcut': + ASSOCIATED_ITEMS = { + Operation: (File, 'associated_file__pk'), + ContextRecord: (Operation, 'operation__pk'), + Find: (ContextRecord, 'base_finds__context_record__pk'), + } + if model in ASSOCIATED_ITEMS: + upper_model, upper_key = ASSOCIATED_ITEMS[model] + model_name = upper_model.SLUG + current = model_name in request.session \ + and request.session[model_name] + if current: + dct = {upper_key: current} + query = query & Q(**dct) + items = model.objects.filter(query).distinct() # print(items.query) q = request_items.get('sidx') @@ -731,7 +738,7 @@ def get_item(model, func_name, default_name, extra_request_keys=[], for idx, col in enumerate(table_cols): if col in model.CONTEXTUAL_TABLE_COLS[contxt]: table_cols[idx] = model.CONTEXTUAL_TABLE_COLS[contxt][col] - if full == 'cached': + if full == 'shortcut': table_cols = ['cached_label'] # manage sort tables -- cgit v1.2.3 From f60470064e73bf874c96db8f4217c4c8ba603c39 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Sat, 24 Sep 2016 16:13:16 +0200 Subject: WIP: ajaxify shortcut menu - 3 --- archaeological_context_records/urls.py | 3 - archaeological_files/urls.py | 3 - archaeological_finds/urls.py | 3 - archaeological_operations/urls.py | 3 - ishtar_common/static/js/ishtar.js | 144 ++++++--------------- ishtar_common/static/media/style.css | 10 +- ishtar_common/templates/base.html | 6 +- .../templates/ishtar/blocks/shortcut_menu.html | 20 +-- ishtar_common/urls.py | 4 + ishtar_common/views.py | 78 ++++++----- 10 files changed, 109 insertions(+), 165 deletions(-) (limited to 'ishtar_common/static') diff --git a/archaeological_context_records/urls.py b/archaeological_context_records/urls.py index 368fd6d98..a25559e29 100644 --- a/archaeological_context_records/urls.py +++ b/archaeological_context_records/urls.py @@ -89,9 +89,6 @@ urlpatterns += patterns( url(r'get-contextrecord-full/(?P.+)?$', 'get_contextrecord', name='get-contextrecord-full', kwargs={'full': True}), - url(r'get-contextrecord-shortcut/own/(?P.+)?$', - 'get_contextrecord', name='get-own-contextrecord-shortcut', - kwargs={'full': 'shortcut', 'force_own': True}), url(r'get-contextrecord-shortcut/(?P.+)?$', 'get_contextrecord', name='get-contextrecord-shortcut', kwargs={'full': 'shortcut'}), diff --git a/archaeological_files/urls.py b/archaeological_files/urls.py index 914872a1f..b762a54b3 100644 --- a/archaeological_files/urls.py +++ b/archaeological_files/urls.py @@ -75,9 +75,6 @@ urlpatterns += patterns( name='get-file'), url(r'get-file-full/(?P.+)?$', 'get_file', name='get-file-full', kwargs={'full': True}), - url(r'get-file-shortcut/own/(?P.+)?$', - 'get_file', name='get-own-file-shortcut', - kwargs={'full': 'shortcut', 'force_own': True}), url(r'get-file-shortcut/(?P.+)?$', 'get_file', name='get-file-shortcut', kwargs={'full': 'shortcut'}), diff --git a/archaeological_finds/urls.py b/archaeological_finds/urls.py index 7cd261516..17cc4028f 100644 --- a/archaeological_finds/urls.py +++ b/archaeological_finds/urls.py @@ -119,9 +119,6 @@ urlpatterns += patterns( name='get-own-find-full', kwargs={'full': True, 'force_own': True}), url(r'get-find-full/(?P.+)?$', 'get_find', name='get-find-full', kwargs={'full': True}), - url(r'get-find-shortcut/own/(?P.+)?$', - 'get_find', name='get-own-find-shortcut', - kwargs={'full': 'shortcut', 'force_own': True}), url(r'get-find-shortcut/(?P.+)?$', 'get_find', name='get-find-shortcut', kwargs={'full': 'shortcut'}), diff --git a/archaeological_operations/urls.py b/archaeological_operations/urls.py index f637fd23b..aca98d4c4 100644 --- a/archaeological_operations/urls.py +++ b/archaeological_operations/urls.py @@ -105,9 +105,6 @@ urlpatterns += patterns( kwargs={'full': True, 'force_own': True}), url(r'get-operation-full/(?P.+)?$', 'get_operation', name='get-operation-full', kwargs={'full': True}), - url(r'get-operation-shortcut/own/(?P.+)?$', - 'get_operation', name='get-own-operation-shortcut', - kwargs={'full': 'shortcut', 'force_own': True}), url(r'get-operation-shortcut/(?P.+)?$', 'get_operation', name='get-operation-shortcut', kwargs={'full': 'shortcut'}), diff --git a/ishtar_common/static/js/ishtar.js b/ishtar_common/static/js/ishtar.js index 393603b6c..9021dc4f5 100644 --- a/ishtar_common/static/js/ishtar.js +++ b/ishtar_common/static/js/ishtar.js @@ -37,62 +37,43 @@ function get_next_table_id(){} function get_previous_table_id(){} var shortcut_url = ''; -var get_file_url = '/get-file-shortcut/'; -var get_own_file_url = '/get-file-shortcut/own/'; -var get_operation_url = '/get-operation-shortcut/'; -var get_own_operation_url = '/get-operation-shortcut/own/'; -var get_contextrecord_url = '/get-contextrecord-shortcut/'; -var get_own_contextrecord_url = '/get-contextrecord-shortcut/own/'; -var get_find_url = '/get-find-shortcut/'; -var get_own_find_url = '/get-find-shortcut/own/'; -var shortcut_get_attr = '?submited=1&page=1&rows=10&cached_label='; +var activate_all_search_url = '/activate-all-search/'; +var activate_own_search_url = '/activate-own-search/'; -var current_file_change = function(){ - $.post('/' + url_path + 'update-current-item/', - {item:'file', value:$("#current_file").val()}, - load_shortcut_menu - ); -}; - -var current_operation_change = function(){ - $.post('/' + url_path + 'update-current-item/', - {item:'operation', value:$("#current_operation").val()}, - load_shortcut_menu - ); -}; - -var current_contextrecord_change = function(){ - $.post('/' + url_path + 'update-current-item/', - {item:'contextrecord', value:$("#current_contextrecord").val()}, - load_shortcut_menu - ); -}; - -var current_find_change = function(){ - $.post('/' + url_path + 'update-current-item/', - {item:'find', value:$("#current_find").val()}, - load_shortcut_menu - ); -}; function init_shortcut_fields(){ - var is_own = $('.activate_all_search').hasClass('disabled'); - var file_url = get_file_url; - if (is_own) file_url = get_own_file_url; - chosen_ajaxify("current_file", file_url + shortcut_get_attr, - current_file_change); - var operation_url = get_operation_url; - if (is_own) operation_url = get_own_operation_url; - chosen_ajaxify("current_operation", operation_url + shortcut_get_attr, - current_operation_change); - var contextrecord_url = get_contextrecord_url; - if (is_own) contextrecord_url = get_own_contextrecord_url; - chosen_ajaxify("current_contextrecord", contextrecord_url + shortcut_get_attr, - current_contextrecord_change); - var find_url = get_find_url; - if (is_own) find_url = get_own_find_url; - chosen_ajaxify("current_find", find_url + shortcut_get_attr, - current_find_change); + $('#id_file-shortcut').change(function(){ + $("#id_select_file-shortcut").attr( + 'title', $('#id_select_file-shortcut').val()); + $.post('/' + url_path + 'update-current-item/', + {item: "file", value:$("#id_file-shortcut").val()}, + load_shortcut_menu + ); + }); + $('#id_operation-shortcut').change(function(){ + $("#id_select_operation-shortcut").attr( + 'title', $('#id_select_operation-shortcut').val()); + $.post('/' + url_path + 'update-current-item/', + {item: "operation", value:$("#id_operation-shortcut").val()}, + load_shortcut_menu + ); + }); + $('#id_contextrecord-shortcut').change(function(){ + $("#id_select_contextrecord-shortcut").attr( + 'title', $('#id_select_contextrecord-shortcut').val()); + $.post('/' + url_path + 'update-current-item/', + {item: "contextrecord", value:$("#id_contextrecord-shortcut").val()}, + load_shortcut_menu + ); + }); + $('#id_find-shortcut').change(function(){ + $("#id_select_find-shortcut").attr( + 'title', $('#id_select_find-shortcut').val()); + $.post('/' + url_path + 'update-current-item/', + {item: "find", value:$("#id_find-shortcut").val()}, + load_shortcut_menu + ); + }); } function init_shortcut_menu(html){ @@ -225,7 +206,7 @@ function load_window(url, speed, on_success){ } function load_current_window(url, model_name){ - var id = $("#current_" + model_name).val(); + var id = $("#id_" + model_name + "-shortcut").val(); if (!id) return; url = url.split('/'); url[url.length - 1] = id; @@ -302,66 +283,23 @@ function show_hide_flex(id){ } } -var delay = (function(){ - var timer = 0; - return function(callback, ms){ - clearTimeout (timer); - timer = setTimeout(callback, ms); - }; -})(); - - -function chosen_ajaxify(id, ajax_url, current_change_callback){ - $('div#' + id + '_chosen .chosen-search input').keyup(function(){ - var keyword = $('div#' + id + '_chosen .chosen-search input').val(); - var keyword_pattern = new RegExp(keyword, 'gi'); - $('div#' + id + '_chosen ul.chosen-results').empty(); - $("#"+id).empty(); - delay(function(){ - $.ajax({ - url: ajax_url + keyword, - dataType: "json", - success: function(response){ - $('#'+id).append(''); - if ('rows' in response){ - $.map(response['rows'], function(item){ - $('#'+id).append(''); - }); - } - $("#"+id).trigger("chosen:updated"); - $('div#' + id + '_chosen .chosen-search input').val(keyword); - $('div#' + id + '_chosen').removeClass('chosen-container-single-nosearch'); - $('div#' + id + '_chosen .chosen-search input').removeAttr('readonly'); - $('div#' + id + '_chosen .chosen-search input').focus(); - $('div#' + id + '_chosen .active-result').each(function(){ - var html = $('div#' + id + '_chosen ul.chosen-results').html(); - $('div#' + id + '_chosen ul.chosen-results').html(html.replace(keyword_pattern, function(matched){ - return '' + matched + ''; - })); - }); - $("#" + id).change(current_change_callback); - } - }); - }, 1000); - }); -} - - var activate_all_search_msg = "Searches in the shortcut menu deals with all items."; var activate_own_search_msg = "Searches in the shortcut menu deals with only your items."; function activate_all_search(){ $('.activate_all_search').removeClass('disabled'); $('.activate_own_search').addClass('disabled'); - init_shortcut_fields(); - display_info(activate_all_search_msg); + $.get(activate_all_search_url, function(data) { + display_info(activate_all_search_msg); + }); return false; } function activate_own_search(){ $('.activate_own_search').removeClass('disabled'); $('.activate_all_search').addClass('disabled'); - init_shortcut_fields(); - display_info(activate_own_search_msg); + $.get(activate_own_search_url, function(data) { + display_info(activate_own_search_msg); + }); return false; } diff --git a/ishtar_common/static/media/style.css b/ishtar_common/static/media/style.css index d74e0aaa2..fff2fad78 100644 --- a/ishtar_common/static/media/style.css +++ b/ishtar_common/static/media/style.css @@ -29,10 +29,16 @@ a, a.remove { color:#D14; } +span.disabled, a.disabled { color:#ccc; } +span.disabled:hover, +a.disabled:hover { + color:#DB5C7C; +} + .badge, a.add-button, #reset_wizards, @@ -812,7 +818,9 @@ table.confirm tr.spacer td:last-child{ /* jquery widget customizations */ .ui-autocomplete{ - font-size:0.7em + font-size:0.7em; + z-index:10000 !important; + width:350px; } .ui-autocomplete-loading { diff --git a/ishtar_common/templates/base.html b/ishtar_common/templates/base.html index cd7b00457..7101ed7de 100644 --- a/ishtar_common/templates/base.html +++ b/ishtar_common/templates/base.html @@ -33,13 +33,11 @@ diff --git a/ishtar_common/templates/ishtar/blocks/shortcut_menu.html b/ishtar_common/templates/ishtar/blocks/shortcut_menu.html index 8a0f694ae..fc1131c90 100644 --- a/ishtar_common/templates/ishtar/blocks/shortcut_menu.html +++ b/ishtar_common/templates/ishtar/blocks/shortcut_menu.html @@ -1,27 +1,27 @@ {% load i18n %} {% load url from future%} -{% if current_menu %} +{% if menu %}

- - + + +

+

+

-{% for lbl, model_name, main_cls, items in current_menu %} +{% for lbl, model_name, current, widget in menu %} {% with 'show-'|add:model_name as model_url%} - - + {% endwith %} diff --git a/ishtar_common/urls.py b/ishtar_common/urls.py index 27078dd9e..5d8d25843 100644 --- a/ishtar_common/urls.py +++ b/ishtar_common/urls.py @@ -192,6 +192,10 @@ urlpatterns += patterns( views.OrgaManualMergeItems.as_view(), name='orga_manual_merge_items'), url(r'reset/$', 'reset_wizards', name='reset_wizards'), + url(r'activate-all-search/$', 'activate_all_search', + name='activate-all-search'), + url(r'activate-own-search/$', 'activate_own_search', + name='activate-own-search'), url(r'(?P' + actions + r')/$', 'action', name='action'), ) diff --git a/ishtar_common/views.py b/ishtar_common/views.py index 27b192e74..67b883447 100644 --- a/ishtar_common/views.py +++ b/ishtar_common/views.py @@ -63,7 +63,8 @@ from archaeological_operations.forms import DashboardForm as DashboardFormOpe from archaeological_files.forms import DashboardForm as DashboardFormFile from ishtar_common.forms import FinalForm, FinalDeleteForm -from ishtar_common.utils import get_random_item_image_link, shortify +from ishtar_common.widgets import JQueryAutoComplete +from ishtar_common.utils import get_random_item_image_link from ishtar_common import forms_common as forms from ishtar_common import wizards from ishtar_common.models import HistoryError, PRIVATE_FIELDS, \ @@ -199,6 +200,16 @@ def get_autocomplete_generic(model, extra={'available': True}): return func +def activate_all_search(request): + request.session['SHORTCUT_SEARCH'] = 'all' + return HttpResponse('OK', mimetype='text/plain') + + +def activate_own_search(request): + request.session['SHORTCUT_SEARCH'] = 'own' + return HttpResponse('OK', mimetype='text/plain') + + def shortcut_menu(request): profile = get_current_profile() CURRENT_ITEMS = [] @@ -209,36 +220,19 @@ def shortcut_menu(request): CURRENT_ITEMS.append((_(u"Context record"), ContextRecord)) if profile.find: CURRENT_ITEMS.append((_(u"Find"), Find)) - dct = {'current_menu': []} - current_selected_item = None + dct = {'current_menu': [], 'menu': [], + 'SHORTCUT_SEARCH': request.session['SHORTCUT_SEARCH'] + if 'SHORTCUT_SEARCH' in request.session else 'own'} + for lbl, model in CURRENT_ITEMS: - new_selected_item = None model_name = model.SLUG - cls = '' current = model_name in request.session and request.session[model_name] - items = [] - for item in model.get_owns(request.user, - menu_filtr=current_selected_item): - pk = unicode(item.pk) - if item.IS_BASKET: - pk = "basket-" + pk - selected = pk == current - if selected: - cls = item.get_short_menu_class() - new_selected_item = item - items.append((pk, shortify(unicode(item), 60), - selected, item.get_short_menu_class())) - # selected is not in owns - add it to the list - if not new_selected_item and current: - try: - item = model.objects.get(pk=int(current)) - new_selected_item = item - items.append((item.pk, shortify(unicode(item), 60), - True, item.get_short_menu_class())) - except (model.DoesNotExist, ValueError): - pass - dct['current_menu'].append((lbl, model_name, cls, items)) - current_selected_item = new_selected_item + + dct['menu'].append((lbl, model_name, current or 0, JQueryAutoComplete( + reverse('get-' + model.SLUG + '-shortcut'), + model).render( + model.SLUG + '-shortcut', value=current, + attrs={'id': 'current_' + model.SLUG}))) return render_to_response('ishtar/blocks/shortcut_menu.html', dct, context_instance=RequestContext(request)) @@ -281,6 +275,7 @@ def update_current_item(request, item_type=None, pk=None): request.session[item_type] = request.POST['value'] else: request.session[item_type] = str(pk) + request.session['SHORTCUT_SEARCH'] = 'all' currents = get_current_items(request) # reinit when descending item are not relevant @@ -507,6 +502,9 @@ def get_item(model, func_name, default_name, extra_request_keys=[], break # max right reach if force_own: own = True + if full == 'shortcut' and 'SHORTCUT_SEARCH' in request.session and \ + request.session['SHORTCUT_SEARCH'] == 'own': + own = True EMPTY = '' if 'type' in dct: data_type = dct.pop('type') @@ -535,6 +533,8 @@ def get_item(model, func_name, default_name, extra_request_keys=[], request_items = request.method == 'POST' and request.POST \ or request.GET dct = base_request.copy() + if full == 'shortcut': + dct['cached_label__icontains'] = request.GET.get('term', None) and_reqs, or_reqs = [], [] try: old = 'old' in request_items and int(request_items['old']) @@ -568,7 +568,7 @@ def get_item(model, func_name, default_name, extra_request_keys=[], q = Q(**{req_key: val}) reqs = reqs | q and_reqs.append(reqs) - if 'submited' not in request_items: + if 'submited' not in request_items and full != 'shortcut': # default search # an item is selected in the default menu if default_name in request.session and \ @@ -782,6 +782,9 @@ def get_item(model, func_name, default_name, extra_request_keys=[], pass start = (page_nb - 1) * row_nb end = page_nb * row_nb + if full == 'shortcut': + start = 0 + end = 20 items_nb = items.count() if manual_sort_key: items = items.all() @@ -896,13 +899,18 @@ def get_item(model, func_name, default_name, extra_request_keys=[], if hasattr(model, 'COL_LINK') and k in model.COL_LINK: value = link_ext_template.format(value, value) res[k] = value + if full == 'shortcut': + res['value'] = res.pop('cached_label') rows.append(res) - data = json.dumps({ - "records": items_nb, - "rows": rows, - "page": page_nb, - "total": (items_nb / row_nb + 1) if row_nb else items_nb, - }) + if full == 'shortcut': + data = json.dumps(rows) + else: + data = json.dumps({ + "records": items_nb, + "rows": rows, + "page": page_nb, + "total": (items_nb / row_nb + 1) if row_nb else items_nb, + }) return HttpResponse(data, mimetype='text/plain') elif data_type == "csv": response = HttpResponse(mimetype='text/csv') -- cgit v1.2.3 From ed8291ebd2c5613a9bddffd9380c9f61a08303dd Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Tue, 11 Oct 2016 18:04:01 +0200 Subject: Shortcut menu: can now choose between simple and advanced menu --- ..._add_field_ishtaruser_advanced_shortcut_menu.py | 464 +++++++++++++++++++++ ishtar_common/models.py | 2 + ishtar_common/static/js/ishtar.js | 65 ++- ishtar_common/static/media/style.css | 12 + .../ishtar/blocks/advanced_shortcut_menu.html | 38 ++ .../templates/ishtar/blocks/shortcut_menu.html | 27 +- ishtar_common/urls.py | 4 + ishtar_common/views.py | 77 +++- 8 files changed, 656 insertions(+), 33 deletions(-) create mode 100644 ishtar_common/migrations/0063_auto__add_field_ishtaruser_advanced_shortcut_menu.py create mode 100644 ishtar_common/templates/ishtar/blocks/advanced_shortcut_menu.html (limited to 'ishtar_common/static') diff --git a/ishtar_common/migrations/0063_auto__add_field_ishtaruser_advanced_shortcut_menu.py b/ishtar_common/migrations/0063_auto__add_field_ishtaruser_advanced_shortcut_menu.py new file mode 100644 index 000000000..19a076913 --- /dev/null +++ b/ishtar_common/migrations/0063_auto__add_field_ishtaruser_advanced_shortcut_menu.py @@ -0,0 +1,464 @@ +# -*- coding: utf-8 -*- +import datetime +from south.db import db +from south.v2 import SchemaMigration +from django.db import models + + +class Migration(SchemaMigration): + + def forwards(self, orm): + # Adding field 'IshtarUser.advanced_shortcut_menu' + db.add_column('ishtar_common_ishtaruser', 'advanced_shortcut_menu', + self.gf('django.db.models.fields.BooleanField')(default=False), + keep_default=False) + + + def backwards(self, orm): + # Deleting field 'IshtarUser.advanced_shortcut_menu' + db.delete_column('ishtar_common_ishtaruser', 'advanced_shortcut_menu') + + + models = { + 'auth.group': { + 'Meta': {'object_name': 'Group'}, + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}), + 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) + }, + 'auth.permission': { + 'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'}, + 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) + }, + 'auth.user': { + 'Meta': {'object_name': 'User'}, + 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), + 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}), + 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), + 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), + 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), + 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}), + 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}), + 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) + }, + 'contenttypes.contenttype': { + 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, + 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}) + }, + 'ishtar_common.arrondissement': { + 'Meta': {'object_name': 'Arrondissement'}, + 'department': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['ishtar_common.Department']"}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '30'}) + }, + 'ishtar_common.author': { + 'Meta': {'object_name': 'Author'}, + 'author_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['ishtar_common.AuthorType']"}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'person': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'author'", 'to': "orm['ishtar_common.Person']"}) + }, + 'ishtar_common.authortype': { + 'Meta': {'object_name': 'AuthorType'}, + 'available': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'comment': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'txt_idx': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100'}) + }, + 'ishtar_common.canton': { + 'Meta': {'object_name': 'Canton'}, + 'arrondissement': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['ishtar_common.Arrondissement']"}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '30'}) + }, + 'ishtar_common.department': { + 'Meta': {'ordering': "['number']", 'object_name': 'Department'}, + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'label': ('django.db.models.fields.CharField', [], {'max_length': '30'}), + 'number': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '3'}), + 'state': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['ishtar_common.State']", 'null': 'True', 'blank': 'True'}) + }, + 'ishtar_common.documenttemplate': { + 'Meta': {'ordering': "['associated_object_name', 'name']", 'object_name': 'DocumentTemplate'}, + 'associated_object_name': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'available': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'template': ('django.db.models.fields.files.FileField', [], {'max_length': '100'}) + }, + 'ishtar_common.format': { + 'Meta': {'object_name': 'Format'}, + 'available': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'comment': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'txt_idx': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100'}) + }, + 'ishtar_common.formatertype': { + 'Meta': {'ordering': "('formater_type', 'options')", 'unique_together': "(('formater_type', 'options', 'many_split'),)", 'object_name': 'FormaterType'}, + 'formater_type': ('django.db.models.fields.CharField', [], {'max_length': '20'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'many_split': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True', 'blank': 'True'}), + 'options': ('django.db.models.fields.CharField', [], {'max_length': '500', 'null': 'True', 'blank': 'True'}) + }, + 'ishtar_common.globalvar': { + 'Meta': {'ordering': "['slug']", 'object_name': 'GlobalVar'}, + 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'slug': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '50'}), + 'value': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}) + }, + 'ishtar_common.historicalorganization': { + 'Meta': {'ordering': "('-history_date', '-history_id')", 'object_name': 'HistoricalOrganization'}, + 'address': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'address_complement': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'alt_address': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'alt_address_complement': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'alt_address_is_prefered': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'alt_country': ('django.db.models.fields.CharField', [], {'max_length': '30', 'null': 'True', 'blank': 'True'}), + 'alt_postal_code': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True', 'blank': 'True'}), + 'alt_town': ('django.db.models.fields.CharField', [], {'max_length': '70', 'null': 'True', 'blank': 'True'}), + 'archived': ('django.db.models.fields.NullBooleanField', [], {'default': 'False', 'null': 'True', 'blank': 'True'}), + 'country': ('django.db.models.fields.CharField', [], {'max_length': '30', 'null': 'True', 'blank': 'True'}), + 'email': ('django.db.models.fields.EmailField', [], {'max_length': '300', 'null': 'True', 'blank': 'True'}), + 'history_creator_id': ('django.db.models.fields.IntegerField', [], {'db_index': 'True', 'null': 'True', 'blank': 'True'}), + 'history_date': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), + 'history_id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'history_modifier_id': ('django.db.models.fields.IntegerField', [], {'db_index': 'True', 'null': 'True', 'blank': 'True'}), + 'history_type': ('django.db.models.fields.CharField', [], {'max_length': '1'}), + 'history_user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']", 'null': 'True'}), + 'id': ('django.db.models.fields.IntegerField', [], {'db_index': 'True', 'blank': 'True'}), + 'merge_key': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'mobile_phone': ('django.db.models.fields.CharField', [], {'max_length': '18', 'null': 'True', 'blank': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '500'}), + 'organization_type_id': ('django.db.models.fields.IntegerField', [], {'db_index': 'True', 'null': 'True', 'blank': 'True'}), + 'phone': ('django.db.models.fields.CharField', [], {'max_length': '18', 'null': 'True', 'blank': 'True'}), + 'phone2': ('django.db.models.fields.CharField', [], {'max_length': '18', 'null': 'True', 'blank': 'True'}), + 'phone3': ('django.db.models.fields.CharField', [], {'max_length': '18', 'null': 'True', 'blank': 'True'}), + 'phone_desc': ('django.db.models.fields.CharField', [], {'max_length': '300', 'null': 'True', 'blank': 'True'}), + 'phone_desc2': ('django.db.models.fields.CharField', [], {'max_length': '300', 'null': 'True', 'blank': 'True'}), + 'phone_desc3': ('django.db.models.fields.CharField', [], {'max_length': '300', 'null': 'True', 'blank': 'True'}), + 'postal_code': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True', 'blank': 'True'}), + 'raw_phone': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'town': ('django.db.models.fields.CharField', [], {'max_length': '70', 'null': 'True', 'blank': 'True'}) + }, + 'ishtar_common.historicalperson': { + 'Meta': {'ordering': "('-history_date', '-history_id')", 'object_name': 'HistoricalPerson'}, + 'address': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'address_complement': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'alt_address': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'alt_address_complement': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'alt_address_is_prefered': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'alt_country': ('django.db.models.fields.CharField', [], {'max_length': '30', 'null': 'True', 'blank': 'True'}), + 'alt_postal_code': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True', 'blank': 'True'}), + 'alt_town': ('django.db.models.fields.CharField', [], {'max_length': '70', 'null': 'True', 'blank': 'True'}), + 'archived': ('django.db.models.fields.NullBooleanField', [], {'default': 'False', 'null': 'True', 'blank': 'True'}), + 'attached_to_id': ('django.db.models.fields.IntegerField', [], {'db_index': 'True', 'null': 'True', 'blank': 'True'}), + 'comment': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'contact_type': ('django.db.models.fields.CharField', [], {'max_length': '300', 'null': 'True', 'blank': 'True'}), + 'country': ('django.db.models.fields.CharField', [], {'max_length': '30', 'null': 'True', 'blank': 'True'}), + 'email': ('django.db.models.fields.EmailField', [], {'max_length': '300', 'null': 'True', 'blank': 'True'}), + 'history_creator_id': ('django.db.models.fields.IntegerField', [], {'db_index': 'True', 'null': 'True', 'blank': 'True'}), + 'history_date': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), + 'history_id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'history_modifier_id': ('django.db.models.fields.IntegerField', [], {'db_index': 'True', 'null': 'True', 'blank': 'True'}), + 'history_type': ('django.db.models.fields.CharField', [], {'max_length': '1'}), + 'history_user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']", 'null': 'True'}), + 'id': ('django.db.models.fields.IntegerField', [], {'db_index': 'True', 'blank': 'True'}), + 'merge_key': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'mobile_phone': ('django.db.models.fields.CharField', [], {'max_length': '18', 'null': 'True', 'blank': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}), + 'old_title': ('django.db.models.fields.CharField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}), + 'phone': ('django.db.models.fields.CharField', [], {'max_length': '18', 'null': 'True', 'blank': 'True'}), + 'phone2': ('django.db.models.fields.CharField', [], {'max_length': '18', 'null': 'True', 'blank': 'True'}), + 'phone3': ('django.db.models.fields.CharField', [], {'max_length': '18', 'null': 'True', 'blank': 'True'}), + 'phone_desc': ('django.db.models.fields.CharField', [], {'max_length': '300', 'null': 'True', 'blank': 'True'}), + 'phone_desc2': ('django.db.models.fields.CharField', [], {'max_length': '300', 'null': 'True', 'blank': 'True'}), + 'phone_desc3': ('django.db.models.fields.CharField', [], {'max_length': '300', 'null': 'True', 'blank': 'True'}), + 'postal_code': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True', 'blank': 'True'}), + 'raw_name': ('django.db.models.fields.CharField', [], {'max_length': '300', 'null': 'True', 'blank': 'True'}), + 'raw_phone': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'salutation': ('django.db.models.fields.CharField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}), + 'surname': ('django.db.models.fields.CharField', [], {'max_length': '50', 'null': 'True', 'blank': 'True'}), + 'title_id': ('django.db.models.fields.IntegerField', [], {'db_index': 'True', 'null': 'True', 'blank': 'True'}), + 'town': ('django.db.models.fields.CharField', [], {'max_length': '70', 'null': 'True', 'blank': 'True'}) + }, + 'ishtar_common.import': { + 'Meta': {'object_name': 'Import'}, + 'conservative_import': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'creation_date': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'null': 'True', 'blank': 'True'}), + 'encoding': ('django.db.models.fields.CharField', [], {'default': "'utf-8'", 'max_length': '15'}), + 'end_date': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}), + 'error_file': ('django.db.models.fields.files.FileField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'imported_file': ('django.db.models.fields.files.FileField', [], {'max_length': '100'}), + 'imported_images': ('django.db.models.fields.files.FileField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}), + 'importer_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['ishtar_common.ImporterType']"}), + 'match_file': ('django.db.models.fields.files.FileField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}), + 'result_file': ('django.db.models.fields.files.FileField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}), + 'seconds_remaining': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), + 'skip_lines': ('django.db.models.fields.IntegerField', [], {'default': '1'}), + 'state': ('django.db.models.fields.CharField', [], {'default': "'C'", 'max_length': '2'}), + 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['ishtar_common.IshtarUser']"}) + }, + 'ishtar_common.importercolumn': { + 'Meta': {'ordering': "('importer_type', 'col_number')", 'unique_together': "(('importer_type', 'col_number'),)", 'object_name': 'ImporterColumn'}, + 'col_number': ('django.db.models.fields.IntegerField', [], {'default': '1'}), + 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'importer_type': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'columns'", 'to': "orm['ishtar_common.ImporterType']"}), + 'regexp_pre_filter': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['ishtar_common.Regexp']", 'null': 'True', 'blank': 'True'}), + 'required': ('django.db.models.fields.BooleanField', [], {'default': 'False'}) + }, + 'ishtar_common.importerdefault': { + 'Meta': {'object_name': 'ImporterDefault'}, + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'importer_type': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'defaults'", 'to': "orm['ishtar_common.ImporterType']"}), + 'target': ('django.db.models.fields.CharField', [], {'max_length': '500'}) + }, + 'ishtar_common.importerdefaultvalues': { + 'Meta': {'object_name': 'ImporterDefaultValues'}, + 'default_target': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'default_values'", 'to': "orm['ishtar_common.ImporterDefault']"}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'target': ('django.db.models.fields.CharField', [], {'max_length': '500'}), + 'value': ('django.db.models.fields.CharField', [], {'max_length': '500'}) + }, + 'ishtar_common.importerduplicatefield': { + 'Meta': {'object_name': 'ImporterDuplicateField'}, + 'column': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'duplicate_fields'", 'to': "orm['ishtar_common.ImporterColumn']"}), + 'concat': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'concat_str': ('django.db.models.fields.CharField', [], {'max_length': '5', 'null': 'True', 'blank': 'True'}), + 'field_name': ('django.db.models.fields.CharField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}), + 'force_new': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}) + }, + 'ishtar_common.importertype': { + 'Meta': {'object_name': 'ImporterType'}, + 'associated_models': ('django.db.models.fields.CharField', [], {'max_length': '200'}), + 'description': ('django.db.models.fields.CharField', [], {'max_length': '500', 'null': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'is_template': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}), + 'slug': ('django.db.models.fields.SlugField', [], {'max_length': '100', 'unique': 'True', 'null': 'True', 'blank': 'True'}), + 'unicity_keys': ('django.db.models.fields.CharField', [], {'max_length': '500', 'null': 'True', 'blank': 'True'}), + 'users': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'to': "orm['ishtar_common.IshtarUser']", 'null': 'True', 'blank': 'True'}) + }, + 'ishtar_common.importtarget': { + 'Meta': {'object_name': 'ImportTarget'}, + 'column': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'targets'", 'to': "orm['ishtar_common.ImporterColumn']"}), + 'comment': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'concat': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'concat_str': ('django.db.models.fields.CharField', [], {'max_length': '5', 'null': 'True', 'blank': 'True'}), + 'force_new': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'formater_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['ishtar_common.FormaterType']"}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'regexp_filter': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['ishtar_common.Regexp']", 'null': 'True', 'blank': 'True'}), + 'target': ('django.db.models.fields.CharField', [], {'max_length': '500'}) + }, + 'ishtar_common.ishtarsiteprofile': { + 'Meta': {'ordering': "['label']", 'object_name': 'IshtarSiteProfile'}, + 'active': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'base_find_external_id': ('django.db.models.fields.TextField', [], {'default': "'{context_record__external_id}-{label}'"}), + 'context_record': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'context_record_external_id': ('django.db.models.fields.TextField', [], {'default': "'{parcel__external_id}-{label}'"}), + 'currency': ('django.db.models.fields.CharField', [], {'default': "u'\\u20ac'", 'max_length': "'5'"}), + 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'file_external_id': ('django.db.models.fields.TextField', [], {'default': "'{year}-{numeric_reference}'"}), + 'files': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'find': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'find_external_id': ('django.db.models.fields.TextField', [], {'default': "'{get_first_base_find__context_record__external_id}-{label}'"}), + 'homepage': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'label': ('django.db.models.fields.TextField', [], {}), + 'parcel_external_id': ('django.db.models.fields.TextField', [], {'default': "'{associated_file__external_id}{operation__code_patriarche}-{town__numero_insee}-{section}{parcel_number}'"}), + 'person_raw_name': ('django.db.models.fields.TextField', [], {'default': "'{name|upper} {surname}'"}), + 'slug': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '50'}), + 'warehouse': ('django.db.models.fields.BooleanField', [], {'default': 'False'}) + }, + 'ishtar_common.ishtaruser': { + 'Meta': {'object_name': 'IshtarUser', '_ormbases': ['auth.User']}, + 'advanced_shortcut_menu': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'person': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'ishtaruser'", 'unique': 'True', 'to': "orm['ishtar_common.Person']"}), + 'user_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['auth.User']", 'unique': 'True', 'primary_key': 'True'}) + }, + 'ishtar_common.itemkey': { + 'Meta': {'object_name': 'ItemKey'}, + 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'importer': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['ishtar_common.Import']", 'null': 'True', 'blank': 'True'}), + 'key': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'object_id': ('django.db.models.fields.PositiveIntegerField', [], {}) + }, + 'ishtar_common.operationtype': { + 'Meta': {'ordering': "['-preventive', 'order', 'label']", 'object_name': 'OperationType'}, + 'available': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'comment': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'order': ('django.db.models.fields.IntegerField', [], {'default': '1'}), + 'preventive': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'txt_idx': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100'}) + }, + 'ishtar_common.organization': { + 'Meta': {'object_name': 'Organization'}, + 'address': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'address_complement': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'alt_address': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'alt_address_complement': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'alt_address_is_prefered': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'alt_country': ('django.db.models.fields.CharField', [], {'max_length': '30', 'null': 'True', 'blank': 'True'}), + 'alt_postal_code': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True', 'blank': 'True'}), + 'alt_town': ('django.db.models.fields.CharField', [], {'max_length': '70', 'null': 'True', 'blank': 'True'}), + 'archived': ('django.db.models.fields.NullBooleanField', [], {'default': 'False', 'null': 'True', 'blank': 'True'}), + 'country': ('django.db.models.fields.CharField', [], {'max_length': '30', 'null': 'True', 'blank': 'True'}), + 'email': ('django.db.models.fields.EmailField', [], {'max_length': '300', 'null': 'True', 'blank': 'True'}), + 'history_creator': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'+'", 'null': 'True', 'on_delete': 'models.SET_NULL', 'to': "orm['auth.User']"}), + 'history_modifier': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'+'", 'null': 'True', 'on_delete': 'models.SET_NULL', 'to': "orm['auth.User']"}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'imports': ('django.db.models.fields.related.ManyToManyField', [], {'blank': 'True', 'related_name': "'imported_ishtar_common_organization'", 'null': 'True', 'symmetrical': 'False', 'to': "orm['ishtar_common.Import']"}), + 'merge_candidate': ('django.db.models.fields.related.ManyToManyField', [], {'blank': 'True', 'related_name': "'merge_candidate_rel_+'", 'null': 'True', 'to': "orm['ishtar_common.Organization']"}), + 'merge_exclusion': ('django.db.models.fields.related.ManyToManyField', [], {'blank': 'True', 'related_name': "'merge_exclusion_rel_+'", 'null': 'True', 'to': "orm['ishtar_common.Organization']"}), + 'merge_key': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'mobile_phone': ('django.db.models.fields.CharField', [], {'max_length': '18', 'null': 'True', 'blank': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '500'}), + 'organization_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['ishtar_common.OrganizationType']"}), + 'phone': ('django.db.models.fields.CharField', [], {'max_length': '18', 'null': 'True', 'blank': 'True'}), + 'phone2': ('django.db.models.fields.CharField', [], {'max_length': '18', 'null': 'True', 'blank': 'True'}), + 'phone3': ('django.db.models.fields.CharField', [], {'max_length': '18', 'null': 'True', 'blank': 'True'}), + 'phone_desc': ('django.db.models.fields.CharField', [], {'max_length': '300', 'null': 'True', 'blank': 'True'}), + 'phone_desc2': ('django.db.models.fields.CharField', [], {'max_length': '300', 'null': 'True', 'blank': 'True'}), + 'phone_desc3': ('django.db.models.fields.CharField', [], {'max_length': '300', 'null': 'True', 'blank': 'True'}), + 'postal_code': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True', 'blank': 'True'}), + 'raw_phone': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'town': ('django.db.models.fields.CharField', [], {'max_length': '70', 'null': 'True', 'blank': 'True'}) + }, + 'ishtar_common.organizationtype': { + 'Meta': {'ordering': "('label',)", 'object_name': 'OrganizationType'}, + 'available': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'comment': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'txt_idx': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100'}) + }, + 'ishtar_common.person': { + 'Meta': {'object_name': 'Person'}, + 'address': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'address_complement': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'alt_address': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'alt_address_complement': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'alt_address_is_prefered': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'alt_country': ('django.db.models.fields.CharField', [], {'max_length': '30', 'null': 'True', 'blank': 'True'}), + 'alt_postal_code': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True', 'blank': 'True'}), + 'alt_town': ('django.db.models.fields.CharField', [], {'max_length': '70', 'null': 'True', 'blank': 'True'}), + 'archived': ('django.db.models.fields.NullBooleanField', [], {'default': 'False', 'null': 'True', 'blank': 'True'}), + 'attached_to': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'members'", 'null': 'True', 'on_delete': 'models.SET_NULL', 'to': "orm['ishtar_common.Organization']"}), + 'comment': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'contact_type': ('django.db.models.fields.CharField', [], {'max_length': '300', 'null': 'True', 'blank': 'True'}), + 'country': ('django.db.models.fields.CharField', [], {'max_length': '30', 'null': 'True', 'blank': 'True'}), + 'email': ('django.db.models.fields.EmailField', [], {'max_length': '300', 'null': 'True', 'blank': 'True'}), + 'history_creator': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'+'", 'null': 'True', 'on_delete': 'models.SET_NULL', 'to': "orm['auth.User']"}), + 'history_modifier': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'+'", 'null': 'True', 'on_delete': 'models.SET_NULL', 'to': "orm['auth.User']"}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'imports': ('django.db.models.fields.related.ManyToManyField', [], {'blank': 'True', 'related_name': "'imported_ishtar_common_person'", 'null': 'True', 'symmetrical': 'False', 'to': "orm['ishtar_common.Import']"}), + 'merge_candidate': ('django.db.models.fields.related.ManyToManyField', [], {'blank': 'True', 'related_name': "'merge_candidate_rel_+'", 'null': 'True', 'to': "orm['ishtar_common.Person']"}), + 'merge_exclusion': ('django.db.models.fields.related.ManyToManyField', [], {'blank': 'True', 'related_name': "'merge_exclusion_rel_+'", 'null': 'True', 'to': "orm['ishtar_common.Person']"}), + 'merge_key': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'mobile_phone': ('django.db.models.fields.CharField', [], {'max_length': '18', 'null': 'True', 'blank': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}), + 'old_title': ('django.db.models.fields.CharField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}), + 'person_types': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['ishtar_common.PersonType']", 'symmetrical': 'False'}), + 'phone': ('django.db.models.fields.CharField', [], {'max_length': '18', 'null': 'True', 'blank': 'True'}), + 'phone2': ('django.db.models.fields.CharField', [], {'max_length': '18', 'null': 'True', 'blank': 'True'}), + 'phone3': ('django.db.models.fields.CharField', [], {'max_length': '18', 'null': 'True', 'blank': 'True'}), + 'phone_desc': ('django.db.models.fields.CharField', [], {'max_length': '300', 'null': 'True', 'blank': 'True'}), + 'phone_desc2': ('django.db.models.fields.CharField', [], {'max_length': '300', 'null': 'True', 'blank': 'True'}), + 'phone_desc3': ('django.db.models.fields.CharField', [], {'max_length': '300', 'null': 'True', 'blank': 'True'}), + 'postal_code': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True', 'blank': 'True'}), + 'raw_name': ('django.db.models.fields.CharField', [], {'max_length': '300', 'null': 'True', 'blank': 'True'}), + 'raw_phone': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'salutation': ('django.db.models.fields.CharField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}), + 'surname': ('django.db.models.fields.CharField', [], {'max_length': '50', 'null': 'True', 'blank': 'True'}), + 'title': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['ishtar_common.TitleType']", 'null': 'True', 'blank': 'True'}), + 'town': ('django.db.models.fields.CharField', [], {'max_length': '70', 'null': 'True', 'blank': 'True'}) + }, + 'ishtar_common.persontype': { + 'Meta': {'ordering': "('label',)", 'object_name': 'PersonType'}, + 'available': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'comment': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'to': "orm['auth.Group']", 'null': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'txt_idx': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100'}) + }, + 'ishtar_common.regexp': { + 'Meta': {'object_name': 'Regexp'}, + 'description': ('django.db.models.fields.CharField', [], {'max_length': '500', 'null': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'regexp': ('django.db.models.fields.CharField', [], {'max_length': '500'}) + }, + 'ishtar_common.sourcetype': { + 'Meta': {'object_name': 'SourceType'}, + 'available': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'comment': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'txt_idx': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100'}) + }, + 'ishtar_common.state': { + 'Meta': {'ordering': "['number']", 'object_name': 'State'}, + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'label': ('django.db.models.fields.CharField', [], {'max_length': '30'}), + 'number': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '3'}) + }, + 'ishtar_common.supporttype': { + 'Meta': {'object_name': 'SupportType'}, + 'available': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'comment': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'txt_idx': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100'}) + }, + 'ishtar_common.targetkey': { + 'Meta': {'unique_together': "(('target', 'key', 'associated_user', 'associated_import'),)", 'object_name': 'TargetKey'}, + 'associated_import': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['ishtar_common.Import']", 'null': 'True', 'blank': 'True'}), + 'associated_user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['ishtar_common.IshtarUser']", 'null': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'is_set': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'key': ('django.db.models.fields.TextField', [], {}), + 'target': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'keys'", 'to': "orm['ishtar_common.ImportTarget']"}), + 'value': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}) + }, + 'ishtar_common.titletype': { + 'Meta': {'ordering': "('label',)", 'object_name': 'TitleType'}, + 'available': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'comment': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'txt_idx': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100'}) + }, + 'ishtar_common.town': { + 'Meta': {'ordering': "['numero_insee']", 'object_name': 'Town'}, + 'canton': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['ishtar_common.Canton']", 'null': 'True', 'blank': 'True'}), + 'center': ('django.contrib.gis.db.models.fields.PointField', [], {'srid': '27572', 'null': 'True', 'blank': 'True'}), + 'departement': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['ishtar_common.Department']", 'null': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'imports': ('django.db.models.fields.related.ManyToManyField', [], {'blank': 'True', 'related_name': "'imported_ishtar_common_town'", 'null': 'True', 'symmetrical': 'False', 'to': "orm['ishtar_common.Import']"}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'numero_insee': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '6'}), + 'surface': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}) + } + } + + complete_apps = ['ishtar_common'] \ No newline at end of file diff --git a/ishtar_common/models.py b/ishtar_common/models.py index 95d995a91..5b93b62a2 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -2526,6 +2526,8 @@ class IshtarUser(User): 'person__attached_to') person = models.ForeignKey(Person, verbose_name=_(u"Person"), unique=True, related_name='ishtaruser') + advanced_shortcut_menu = models.BooleanField( + _(u"Advanced shortcut menu"), default=False) class Meta: verbose_name = _(u"Ishtar user") diff --git a/ishtar_common/static/js/ishtar.js b/ishtar_common/static/js/ishtar.js index 9021dc4f5..6017aed64 100644 --- a/ishtar_common/static/js/ishtar.js +++ b/ishtar_common/static/js/ishtar.js @@ -37,11 +37,62 @@ function get_next_table_id(){} function get_previous_table_id(){} var shortcut_url = ''; +var advanced_menu = false; var activate_all_search_url = '/activate-all-search/'; var activate_own_search_url = '/activate-own-search/'; +var activate_advanced_url = '/activate-advanced-menu/'; +var activate_simple_url = '/activate-simple-menu/'; +function init_shortcut_menu(html){ + $("#progress").hide(); + $("#context_menu").html(html); + $(".chosen-select").chosen(); + if (advanced_menu) { + init_advanced_shortcut_fields(); + } else { + init_shortcut_fields(); + } + $("#short-menu-advanced").click(function(){ + $.get(url_path + activate_advanced_url, + load_shortcut_menu + ); + }); + $("#short-menu-simple").click(function(){ + $.get(url_path + activate_simple_url, + load_shortcut_menu + ); + }); +} + function init_shortcut_fields(){ + $("#current_file").change(function(){ + $.post('/' + url_path + 'update-current-item/', + {item:'file', value:$("#current_file").val()}, + load_shortcut_menu + ); + }); + $("#current_operation").change(function(){ + $.post('/' + url_path + 'update-current-item/', + {item:'operation', value:$("#current_operation").val()}, + load_shortcut_menu + ); + }); + $("#current_contextrecord").change(function(){ + $.post('/' + url_path + 'update-current-item/', + {item:'contextrecord', value:$("#current_contextrecord").val()}, + load_shortcut_menu + ); + }); + $("#current_find").change(function(){ + $.post('/' + url_path + 'update-current-item/', + {item:'find', value:$("#current_find").val()}, + load_shortcut_menu + ); + }); +} + +function init_advanced_shortcut_fields(){ $('#id_file-shortcut').change(function(){ $("#id_select_file-shortcut").attr( 'title', $('#id_select_file-shortcut').val()); @@ -76,13 +127,6 @@ function init_shortcut_fields(){ }); } -function init_shortcut_menu(html){ - $("#progress").hide(); - $("#context_menu").html(html); - $(".chosen-select").chosen(); - init_shortcut_fields(); -} - function display_info(msg){ $('#message .information .content').html(msg); $('#message').fadeIn('slow'); @@ -206,7 +250,12 @@ function load_window(url, speed, on_success){ } function load_current_window(url, model_name){ - var id = $("#id_" + model_name + "-shortcut").val(); + var id; + if (advanced_menu){ + id = $("#id_" + model_name + "-shortcut").val(); + } else { + id = $("#current_" + model_name).val(); + } if (!id) return; url = url.split('/'); url[url.length - 1] = id; diff --git a/ishtar_common/static/media/style.css b/ishtar_common/static/media/style.css index fff2fad78..8aac9e2a2 100644 --- a/ishtar_common/static/media/style.css +++ b/ishtar_common/static/media/style.css @@ -243,6 +243,7 @@ button, input[type=submit], button.submit{ -webkit-border-radius:4px; } +button.btn-selected, button:hover, input[type=submit]:hover{ cursor:pointer; color:#922; @@ -423,6 +424,16 @@ div#language_form_div label{ display:inline; }*/ +.btn-group .btn{ + padding: 0; + margin: 0; +} + +.short-menu-buttons{ + position: absolute; + margin-top: -20px; +} + div#context_menu{ height:110px; margin-right:10px; @@ -432,6 +443,7 @@ div#context_menu{ } div#context_menu fieldset{ + margin-top: 8px; background-color:#f1f2f6; border:0 solid #CCC; -moz-border-radius: 0; diff --git a/ishtar_common/templates/ishtar/blocks/advanced_shortcut_menu.html b/ishtar_common/templates/ishtar/blocks/advanced_shortcut_menu.html new file mode 100644 index 000000000..91f99f294 --- /dev/null +++ b/ishtar_common/templates/ishtar/blocks/advanced_shortcut_menu.html @@ -0,0 +1,38 @@ +{% load i18n %} +{% load url from future%} +{% if menu %} + +
+
+ + +
+
+

+

+ + +

+

+ +

+
+
- + {{widget|safe}} +
+{% for lbl, model_name, current, widget in menu %} + + + {% with 'show-'|add:model_name as model_url%} + + + {% endwith %} + +{% endfor %} +
+ {{widget|safe}} + + +
+
+
+ +{% endif %} diff --git a/ishtar_common/templates/ishtar/blocks/shortcut_menu.html b/ishtar_common/templates/ishtar/blocks/shortcut_menu.html index fc1131c90..f07e0ed99 100644 --- a/ishtar_common/templates/ishtar/blocks/shortcut_menu.html +++ b/ishtar_common/templates/ishtar/blocks/shortcut_menu.html @@ -1,27 +1,25 @@ {% load i18n %} {% load url from future%} -{% if menu %} +{% if current_menu %}
-
-

-

- - -

-

- -

+
+ +
+ -{% for lbl, model_name, current, widget in menu %} +{% for lbl, model_name, main_cls, items in current_menu %} {% with 'show-'|add:model_name as model_url%} - - + {% endwith %} @@ -30,4 +28,5 @@
- {{widget|safe}} + +
+ {% endif %} diff --git a/ishtar_common/urls.py b/ishtar_common/urls.py index 5d8d25843..22a09a052 100644 --- a/ishtar_common/urls.py +++ b/ishtar_common/urls.py @@ -196,6 +196,10 @@ urlpatterns += patterns( name='activate-all-search'), url(r'activate-own-search/$', 'activate_own_search', name='activate-own-search'), + url(r'activate-advanced-menu/$', 'activate_advanced_shortcut_menu', + name='activate-advanced-menu'), + url(r'activate-simple-menu/$', 'activate_simple_shortcut_menu', + name='activate-simple-menu'), url(r'(?P' + actions + r')/$', 'action', name='action'), ) diff --git a/ishtar_common/views.py b/ishtar_common/views.py index 67b883447..6dc7e6e0d 100644 --- a/ishtar_common/views.py +++ b/ishtar_common/views.py @@ -64,7 +64,7 @@ from archaeological_files.forms import DashboardForm as DashboardFormFile from ishtar_common.forms import FinalForm, FinalDeleteForm from ishtar_common.widgets import JQueryAutoComplete -from ishtar_common.utils import get_random_item_image_link +from ishtar_common.utils import get_random_item_image_link, shortify from ishtar_common import forms_common as forms from ishtar_common import wizards from ishtar_common.models import HistoryError, PRIVATE_FIELDS, \ @@ -210,6 +210,22 @@ def activate_own_search(request): return HttpResponse('OK', mimetype='text/plain') +def activate_advanced_shortcut_menu(request): + if not hasattr(request.user, 'ishtaruser'): + return HttpResponse('KO', mimetype='text/plain') + request.user.ishtaruser.advanced_shortcut_menu = True + request.user.ishtaruser.save() + return HttpResponse('OK', mimetype='text/plain') + + +def activate_simple_shortcut_menu(request): + if not hasattr(request.user, 'ishtaruser'): + return HttpResponse('KO', mimetype='text/plain') + request.user.ishtaruser.advanced_shortcut_menu = False + request.user.ishtaruser.save() + return HttpResponse('OK', mimetype='text/plain') + + def shortcut_menu(request): profile = get_current_profile() CURRENT_ITEMS = [] @@ -220,19 +236,58 @@ def shortcut_menu(request): CURRENT_ITEMS.append((_(u"Context record"), ContextRecord)) if profile.find: CURRENT_ITEMS.append((_(u"Find"), Find)) - dct = {'current_menu': [], 'menu': [], - 'SHORTCUT_SEARCH': request.session['SHORTCUT_SEARCH'] - if 'SHORTCUT_SEARCH' in request.session else 'own'} - + if hasattr(request.user, 'ishtaruser') and \ + request.user.ishtaruser.advanced_shortcut_menu: + dct = {'current_menu': [], 'menu': [], + 'SHORTCUT_SEARCH': request.session['SHORTCUT_SEARCH'] + if 'SHORTCUT_SEARCH' in request.session else 'own'} + + for lbl, model in CURRENT_ITEMS: + model_name = model.SLUG + current = model_name in request.session \ + and request.session[model_name] + + dct['menu'].append(( + lbl, model_name, current or 0, + JQueryAutoComplete( + reverse('get-' + model.SLUG + '-shortcut'), + model).render( + model.SLUG + '-shortcut', value=current, + attrs={'id': 'current_' + model.SLUG}))) + return render_to_response( + 'ishtar/blocks/advanced_shortcut_menu.html', + dct, context_instance=RequestContext(request)) + dct = {'current_menu': []} + current_selected_item = None for lbl, model in CURRENT_ITEMS: + new_selected_item = None model_name = model.SLUG + cls = '' current = model_name in request.session and request.session[model_name] - - dct['menu'].append((lbl, model_name, current or 0, JQueryAutoComplete( - reverse('get-' + model.SLUG + '-shortcut'), - model).render( - model.SLUG + '-shortcut', value=current, - attrs={'id': 'current_' + model.SLUG}))) + items = [] + for item in model.get_owns(request.user, + menu_filtr=current_selected_item): + pk = unicode(item.pk) + if item.IS_BASKET: + pk = "basket-" + pk + selected = pk == current + if selected: + cls = item.get_short_menu_class() + new_selected_item = item + items.append((pk, shortify(unicode(item), 60), + selected, item.get_short_menu_class())) + # selected is not in owns - add it to the list + if not new_selected_item and current: + try: + item = model.objects.get(pk=int(current)) + new_selected_item = item + items.append((item.pk, shortify(unicode(item), 60), + True, item.get_short_menu_class())) + except (model.DoesNotExist, ValueError): + pass + if items: + dct['current_menu'].append((lbl, model_name, cls, items)) + current_selected_item = new_selected_item return render_to_response('ishtar/blocks/shortcut_menu.html', dct, context_instance=RequestContext(request)) -- cgit v1.2.3