From 64101d6c9112110420c077f26146f879ffec349d Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Tue, 15 Nov 2016 16:41:27 +0100 Subject: Shortcut menu: put research archaeological files in blue (refs #3346) --- ishtar_common/static/media/style.css | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'ishtar_common/static') diff --git a/ishtar_common/static/media/style.css b/ishtar_common/static/media/style.css index 00fed380d..b1939eaf0 100644 --- a/ishtar_common/static/media/style.css +++ b/ishtar_common/static/media/style.css @@ -60,6 +60,10 @@ a.add-button, color:#000; } +#context_menu .blue { + color:#00a8ff; +} + .chosen-container, #context_menu .green, #context_menu .red, @@ -272,7 +276,9 @@ button.ui-widget-header:hover { .chosen-container-single .chosen-single{ background: none; background-color: #fff; - border-radius:4px; + border-radius: 0; + box-shadow: none; + border: 1px solid #fff; } textarea, @@ -847,6 +853,11 @@ ul.form .help_text{ .autocomplete{ width:350px; + font-size: 13px; +} + +#current_items .autocomplete{ + width:400px; } .delete td{ -- cgit v1.2.3 From cd6fd329f22241a6a3dd14a14c579bdf1831677d Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Mon, 2 Jan 2017 15:33:56 +0100 Subject: Manage multiple condition for cascading shortcut menu - Manage shortcut menu for treatment and treatment files (refs #3384) --- archaeological_context_records/models.py | 6 +++--- archaeological_finds/models_finds.py | 8 +++++--- archaeological_finds/models_treatments.py | 34 ++++++++++++++++++++++++++++--- archaeological_operations/models.py | 6 +++--- ishtar_common/models.py | 2 +- ishtar_common/static/js/ishtar.js | 12 +++++++++++ ishtar_common/views.py | 18 +++++++++++++--- 7 files changed, 70 insertions(+), 16 deletions(-) (limited to 'ishtar_common/static') diff --git a/archaeological_context_records/models.py b/archaeological_context_records/models.py index 7d399ecd9..a0ba6c379 100644 --- a/archaeological_context_records/models.py +++ b/archaeological_context_records/models.py @@ -268,9 +268,9 @@ class ContextRecord(BaseHistorizedItem, ImageModel, OwnPerms, @classmethod def get_owns(cls, user, menu_filtr=None, limit=None): - replace_query = {} - if menu_filtr: - replace_query = {'operation': menu_filtr} + replace_query = None + if menu_filtr and 'operation' in menu_filtr: + replace_query = Q(operation=menu_filtr['operation']) owns = super(ContextRecord, cls).get_owns( user, replace_query=replace_query, limit=limit) diff --git a/archaeological_finds/models_finds.py b/archaeological_finds/models_finds.py index 9a7a71f84..e29669773 100644 --- a/archaeological_finds/models_finds.py +++ b/archaeological_finds/models_finds.py @@ -663,9 +663,11 @@ class Find(BaseHistorizedItem, ImageModel, OwnPerms, ShortMenuItem): @classmethod def get_owns(cls, user, menu_filtr=None, limit=None): - replace_query = {} - if menu_filtr: - replace_query = {'base_finds__context_record': menu_filtr} + replace_query = None + if menu_filtr and 'contextrecord' in menu_filtr: + replace_query = Q( + base_finds__context_record=menu_filtr['contextrecord'] + ) owns = super(Find, cls).get_owns( user, replace_query=replace_query, limit=limit) diff --git a/archaeological_finds/models_treatments.py b/archaeological_finds/models_treatments.py index eff8d8371..5e763085c 100644 --- a/archaeological_finds/models_treatments.py +++ b/archaeological_finds/models_treatments.py @@ -21,7 +21,7 @@ import datetime from django.conf import settings from django.contrib.gis.db import models -from django.db.models import Max +from django.db.models import Max, Q from django.db.models.signals import post_save, post_delete, pre_delete from django.template.defaultfilters import slugify from django.utils.translation import ugettext_lazy as _, ugettext @@ -144,11 +144,29 @@ class Treatment(BaseHistorizedItem, ImageModel, OwnPerms, ShortMenuItem): lbl += u" %s %s" % (_(u"by"), unicode(self.person)) return lbl + @property + def short_class_name(self): + return _(u"TREATMENT") + + @classmethod + def get_query_owns(cls, user): + return (Q(history_creator=user) | + Q(person__ishtaruser=user.ishtaruser)) \ + & Q(end_date__isnull=True) + @classmethod def get_owns(cls, user, menu_filtr=None, limit=None): - replace_query = {} + replace_query = None if menu_filtr: - replace_query = {'file': menu_filtr} + if 'treatmentfile' in menu_filtr: + replace_query = Q(file=menu_filtr['treatmentfile']) + if 'find' in menu_filtr: + q = Q(upstream=menu_filtr['find']) | Q( + downstream=menu_filtr['find']) + if replace_query: + replace_query = replace_query | q + else: + replace_query = q owns = super(Treatment, cls).get_owns( user, replace_query=replace_query, limit=limit) return sorted( @@ -454,6 +472,16 @@ class TreatmentFile(ClosedItem, BaseHistorizedItem, OwnPerms, ValueGetter, def __unicode__(self): return self.cached_label + @property + def short_class_name(self): + return _(u"Treatment file") + + @classmethod + def get_query_owns(cls, user): + return (Q(history_creator=user) | + Q(in_charge__ishtaruser=user.ishtaruser)) \ + & Q(end_date__isnull=True) + @property def associated_filename(self): return "-".join([str(slugify(getattr(self, attr))) diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py index 7507da817..0270a0c74 100644 --- a/archaeological_operations/models.py +++ b/archaeological_operations/models.py @@ -377,9 +377,9 @@ class Operation(ClosedItem, BaseHistorizedItem, ImageModel, OwnPerms, @classmethod def get_owns(cls, user, menu_filtr=None, limit=None): - replace_query = {} - if menu_filtr: - replace_query = {'associated_file': menu_filtr} + replace_query = None + if menu_filtr and 'file' in menu_filtr: + replace_query = Q(associated_file=menu_filtr['file']) owns = super(Operation, cls).get_owns( user, replace_query=replace_query, limit=limit) diff --git a/ishtar_common/models.py b/ishtar_common/models.py index fcb367ae5..ccb817adc 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -257,7 +257,7 @@ class OwnPerms: if query: q = cls.objects.filter(query) if replace_query: - q = cls.objects.filter(**replace_query) + q = cls.objects.filter(replace_query) if limit: items += list(q.order_by('-pk')[:limit]) else: diff --git a/ishtar_common/static/js/ishtar.js b/ishtar_common/static/js/ishtar.js index 8abf23289..b5f4f1a79 100644 --- a/ishtar_common/static/js/ishtar.js +++ b/ishtar_common/static/js/ishtar.js @@ -102,6 +102,18 @@ function init_shortcut_fields(){ load_shortcut_menu ); }); + $("#current_treatment").change(function(){ + $.post('/' + url_path + 'update-current-item/', + {item:'treatment', value:$("#current_treatment").val()}, + load_shortcut_menu + ); + }); + $("#current_treatmentfile").change(function(){ + $.post('/' + url_path + 'update-current-item/', + {item:'treatmentfile', value:$("#current_treatmentfile").val()}, + load_shortcut_menu + ); + }); } function init_advanced_shortcut_fields(){ diff --git a/ishtar_common/views.py b/ishtar_common/views.py index 783c6badb..cf3f968b1 100644 --- a/ishtar_common/views.py +++ b/ishtar_common/views.py @@ -264,7 +264,7 @@ def shortcut_menu(request): 'ishtar/blocks/advanced_shortcut_menu.html', dct, context_instance=RequestContext(request)) dct = {'current_menu': []} - current_selected_item = None + current_selected_item = {} for lbl, model in CURRENT_ITEMS: new_selected_item = None model_name = model.SLUG @@ -294,7 +294,8 @@ def shortcut_menu(request): pass if items: dct['current_menu'].append((lbl, model_name, cls, items)) - current_selected_item = new_selected_item + if new_selected_item: + current_selected_item[model_name] = new_selected_item return render_to_response('ishtar/blocks/shortcut_menu.html', dct, context_instance=RequestContext(request)) @@ -317,6 +318,16 @@ def get_current_items(request): def unpin(request, item_type): + if item_type not in ('find', 'contextrecord', 'operation', 'file', + 'treatment', 'treatmentfile'): + logger.warning("unpin unknow type: {}".format(item_type)) + return HttpResponse('nok') + request.session['treatment'] = '' + if item_type == 'treatment': + return HttpResponse('ok') + request.session['treatmentfile'] = '' + if item_type == 'treatmentfile': + return HttpResponse('ok') request.session['find'] = '' if item_type == 'find': return HttpResponse('ok') @@ -327,7 +338,8 @@ def unpin(request, item_type): if item_type == 'operation': return HttpResponse('ok') request.session['file'] = '' - return HttpResponse('ok') + if item_type == 'file': + return HttpResponse('ok') def update_current_item(request, item_type=None, pk=None): -- cgit v1.2.3