From dba44bcd7d2933f082e72b63e9823c8141282034 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Thu, 21 Apr 2016 09:26:06 +0200 Subject: Fix operation wizard --- archaeological_operations/wizards.py | 1 + 1 file changed, 1 insertion(+) (limited to 'archaeological_operations') diff --git a/archaeological_operations/wizards.py b/archaeological_operations/wizards.py index c90b6fa8a..c51b88d0b 100644 --- a/archaeological_operations/wizards.py +++ b/archaeological_operations/wizards.py @@ -361,6 +361,7 @@ class OperationAdministrativeActWizard(OperationWizard): step = self.steps.current if step.startswith('final-'): general_form_key = 'administrativeact-' + self.url_name + act_type = None try: act_type = models.ActType.objects.get( pk=self.session_get_value(general_form_key, "act_type")) -- cgit v1.2.3 From 2728c5a51c474429bea741dc469fd87ed48cee32 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Tue, 26 Apr 2016 15:17:50 +0200 Subject: Administrativ act admin: can change operation --- archaeological_operations/admin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'archaeological_operations') diff --git a/archaeological_operations/admin.py b/archaeological_operations/admin.py index 9f886bc62..d976aac77 100644 --- a/archaeological_operations/admin.py +++ b/archaeological_operations/admin.py @@ -31,7 +31,7 @@ class AdministrativeActAdmin(HistorizedObjectAdmin): list_filter = ('act_type',) search_fields = ('year', 'index') readonly_fields = ('in_charge', 'operator', 'scientist', 'signatory', - 'operation', 'associated_file', 'imports', + 'associated_file', 'imports', 'departments_label', 'towns_label', 'history_modifier', 'history_creator') model = models.AdministrativeAct -- cgit v1.2.3 From 7868245668607ab9fb618011e4880f15ec1ef7de Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Thu, 2 Jun 2016 16:07:31 +0200 Subject: Generic management of baskets in owns items --- archaeological_files/models.py | 2 +- archaeological_finds/models.py | 17 ++++++----------- archaeological_operations/models.py | 2 +- ishtar_common/models.py | 7 ++++++- 4 files changed, 14 insertions(+), 14 deletions(-) (limited to 'archaeological_operations') diff --git a/archaeological_files/models.py b/archaeological_files/models.py index 519d3ced3..0258cb16d 100644 --- a/archaeological_files/models.py +++ b/archaeological_files/models.py @@ -331,7 +331,7 @@ class File(BaseHistorizedItem, OwnPerms, ValueGetter, ShortMenuItem, @classmethod def get_owns(cls, user): owns = super(File, cls).get_owns(user) - return sorted(owns.all(), key=lambda x: x.cached_label) + return sorted(owns, key=lambda x: x.cached_label) def get_values(self, prefix=''): values = super(File, self).get_values(prefix=prefix) diff --git a/archaeological_finds/models.py b/archaeological_finds/models.py index 9c972f68c..417dd3929 100644 --- a/archaeological_finds/models.py +++ b/archaeological_finds/models.py @@ -240,6 +240,11 @@ CHECK_CHOICES = (('NC', _(u"Not checked")), ) +class FindBasket(Basket): + items = models.ManyToManyField('Find', blank=True, null=True, + related_name='basket') + + class Find(BaseHistorizedItem, ImageModel, OwnPerms, ShortMenuItem): CHECK_DICT = dict(CHECK_CHOICES) SHOW_URL = 'show-find' @@ -329,6 +334,7 @@ class Find(BaseHistorizedItem, ImageModel, OwnPerms, ShortMenuItem): check_date = models.DateField(_(u"Check date"), default=datetime.date.today) history = HistoricalRecords() + BASKET_MODEL = FindBasket def __init__(self, *args, **kwargs): super(Find, self).__init__(*args, **kwargs) @@ -384,12 +390,6 @@ class Find(BaseHistorizedItem, ImageModel, OwnPerms, ShortMenuItem): lbl += u' ({})'.format(base) return lbl - @classmethod - def get_owns(cls, user): - if user.is_anonymous(): - return FindBasket.objects.none() - return FindBasket.objects.filter(user=user) - def get_first_base_find(self): q = self.base_finds if not q.count(): @@ -546,11 +546,6 @@ class Find(BaseHistorizedItem, ImageModel, OwnPerms, ShortMenuItem): # idx and idx['material_index__max'] + 1 or 1 -class FindBasket(Basket): - items = models.ManyToManyField(Find, blank=True, null=True, - related_name='basket') - - class FindSource(Source): SHOW_URL = 'show-findsource' diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py index 253ea7635..e3453f0cf 100644 --- a/archaeological_operations/models.py +++ b/archaeological_operations/models.py @@ -251,7 +251,7 @@ class Operation(BaseHistorizedItem, OwnPerms, ValueGetter, ShortMenuItem, owns = super(Operation, cls).get_owns(user) # owns = owns.annotate(null_count=Count('operation_code')) # return owns.order_by("common_name", "-year", "operation_code") - return sorted(owns.all(), key=lambda x: x.cached_label) + return sorted(owns, key=lambda x: x.cached_label) def __unicode__(self): if self.cached_label: diff --git a/ishtar_common/models.py b/ishtar_common/models.py index 33ae05369..f3974d04d 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -243,10 +243,15 @@ class OwnPerms: user = IshtarUser.objects.get(user_ptr=user) if user.is_anonymous(): return cls.objects.filter(pk__isnull=True) + items = [] + if hasattr(cls, 'BASKET_MODEL'): + items = list(cls.BASKET_MODEL.objects.filter(user=user).all()) query = cls.get_query_owns(user) if not query: return cls.objects.filter(pk__isnull=True) - return cls.objects.filter(query).order_by(*cls._meta.ordering) + items += list( + cls.objects.filter(query).order_by(*cls._meta.ordering).all()) + return items class Cached(object): -- cgit v1.2.3 From 51ab900d3a61c719923390be1fb980019ac1da56 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Thu, 2 Jun 2016 17:27:03 +0200 Subject: Add full export of operation's sources --- archaeological_operations/forms.py | 3 ++- archaeological_operations/urls.py | 3 +++ ishtar_common/forms.py | 7 +++++-- ishtar_common/templatetags/window_tables.py | 4 ++-- 4 files changed, 12 insertions(+), 5 deletions(-) (limited to 'archaeological_operations') diff --git a/archaeological_operations/forms.py b/archaeological_operations/forms.py index 49824e24a..b61285177 100644 --- a/archaeological_operations/forms.py +++ b/archaeological_operations/forms.py @@ -1136,7 +1136,8 @@ class OperationSourceSelect(SourceSelect): OperationSourceFormSelection = get_form_selection( 'OperationSourceFormSelection', _(u"Documentation search"), 'pk', models.OperationSource, OperationSourceSelect, 'get-operationsource', - _(u"You should select a document.")) + _(u"You should select a document."), + get_full_url='get-operationsource-full') ################################################ # Administrative act management for operations # diff --git a/archaeological_operations/urls.py b/archaeological_operations/urls.py index 76723deab..ef7d14dd6 100644 --- a/archaeological_operations/urls.py +++ b/archaeological_operations/urls.py @@ -130,6 +130,9 @@ urlpatterns += patterns( 'show_operationsource', name=models.OperationSource.SHOW_URL), url(r'get-operationsource/(?P.+)?$', 'get_operationsource', name='get-operationsource'), + url(r'get-operationsource-full/(?P.+)?$', + 'get_operationsource', name='get-operationsource-full', + kwargs={'full': True}), url(r'dashboard_operation/$', 'dashboard_operation', name='dashboard-operation'), url(r'autocomplete-archaeologicalsite/$', diff --git a/ishtar_common/forms.py b/ishtar_common/forms.py index a5abdddcd..5e0d14eb8 100644 --- a/ishtar_common/forms.py +++ b/ishtar_common/forms.py @@ -128,7 +128,7 @@ class ClosingDateFormSelection(forms.Form): def get_form_selection( class_name, label, key, model, base_form, get_url, not_selected_error=_(u"You should select an item."), new=False, - new_message=_(u"Add a new item")): + new_message=_(u"Add a new item"), get_full_url=None): """ Generate a class selection form class_name -- name of the class @@ -145,11 +145,14 @@ def get_form_selection( 'form_label': label, 'associated_models': {key: model}, 'currents': {key: model}} + widget_kwargs = {"new": new, "new_message": new_message} + if get_full_url: + widget_kwargs['source_full'] = reverse_lazy(get_full_url) attrs[key] = forms.IntegerField( label="", required=False, validators=[models.valid_id(model)], widget=widgets.JQueryJqGrid(reverse_lazy(get_url), base_form, model, - new=new, new_message=new_message)) + **widget_kwargs)) def clean(self): cleaned_data = self.cleaned_data diff --git a/ishtar_common/templatetags/window_tables.py b/ishtar_common/templatetags/window_tables.py index 8be4e5559..6bed38201 100644 --- a/ishtar_common/templatetags/window_tables.py +++ b/ishtar_common/templatetags/window_tables.py @@ -27,8 +27,8 @@ def table_document(caption, data): ASSOCIATED_MODELS = {} ASSOCIATED_MODELS['files'] = (File, 'get-file', '') -ASSOCIATED_MODELS['operation_docs'] = (OperationSource, - 'get-operationsource', '') +ASSOCIATED_MODELS['operation_docs'] = ( + OperationSource, 'get-operationsource', 'get-operationsource-full') ASSOCIATED_MODELS['operations'] = (Operation, 'get-operation', '') ASSOCIATED_MODELS['context_records'] = (ContextRecord, 'get-contextrecord', 'get-contextrecord-full') -- cgit v1.2.3