From 851e8b81898279079c14c4c0c3580699f9bb9998 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Fri, 14 Jan 2011 14:55:41 +0100 Subject: Implementation of default operations (refs #16) --- ishtar/furnitures/context_processors.py | 3 ++- ishtar/furnitures/forms.py | 2 +- ishtar/furnitures/models.py | 6 ++++++ ishtar/templates/base.html | 18 +++++++++++------- 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/ishtar/furnitures/context_processors.py b/ishtar/furnitures/context_processors.py index ed6fb1252..f81b6f7c3 100644 --- a/ishtar/furnitures/context_processors.py +++ b/ishtar/furnitures/context_processors.py @@ -39,7 +39,8 @@ def get_base_context(request): dct['JQUERY_URL'] = settings.JQUERY_URL dct['JQUERY_UI_URL'] = settings.JQUERY_UI_URL dct['current_menu'] = [] - for lbl, model in ((_(u"Archaelogical file"), models.File),): + for lbl, model in ((_(u"Archaelogical file"), models.File), + (_(u"Operation"), models.Operation)): model_name = model.__name__.lower() current = model_name in request.session and request.session[model_name] items = [] diff --git a/ishtar/furnitures/forms.py b/ishtar/furnitures/forms.py index 376287d68..5bb1af6a9 100644 --- a/ishtar/furnitures/forms.py +++ b/ishtar/furnitures/forms.py @@ -703,7 +703,7 @@ class OperationFormGeneral(forms.Form): operation_type = forms.ChoiceField(label=_("Operation type"), choices=models.OperationType.get_types()) start_date = forms.DateField(label=_(u"Start date"), required=False, - initial=get_now, widget=widgets.JQueryDate) + widget=widgets.JQueryDate) end_date = forms.DateField(label=_(u"End date"), required=False, widget=widgets.JQueryDate) year = forms.IntegerField(label=_("Year"), diff --git a/ishtar/furnitures/models.py b/ishtar/furnitures/models.py index e3c434f7a..01296c109 100644 --- a/ishtar/furnitures/models.py +++ b/ishtar/furnitures/models.py @@ -334,6 +334,12 @@ class Operation(BaseHistorizedItem, OwnPerms): if getattr(self, k)] return u" - ".join(items) + @classmethod + def get_owns(cls, user, order_by=['-year', '-operation_code']): + if user.is_anonymous(): + return [] + return cls.objects.filter(history_modifier=user).order_by(*order_by + ).all() class Parcel(LightHistorizedItem): associated_file = models.ForeignKey(File, related_name='parcels', diff --git a/ishtar/templates/base.html b/ishtar/templates/base.html index 2b2b440c8..e726cf782 100644 --- a/ishtar/templates/base.html +++ b/ishtar/templates/base.html @@ -37,15 +37,19 @@
{% trans "Default items"%} -
    + {% for lbl, model_name, items in current_menu %} -
  • -
  • + + + + {% endfor %} - +
    + +
{% endif %}{% endblock %} -- cgit v1.2.3