diff options
Diffstat (limited to 'archaeological_context_records/models.py')
| -rw-r--r-- | archaeological_context_records/models.py | 34 | 
1 files changed, 27 insertions, 7 deletions
diff --git a/archaeological_context_records/models.py b/archaeological_context_records/models.py index 57c95c3b6..45da5935c 100644 --- a/archaeological_context_records/models.py +++ b/archaeological_context_records/models.py @@ -1,6 +1,6 @@  #!/usr/bin/env python  # -*- coding: utf-8 -*- -# Copyright (C) 2012 Étienne Loks  <etienne.loks_AT_peacefrogsDOTnet> +# Copyright (C) 2012-2013 Étienne Loks  <etienne.loks_AT_peacefrogsDOTnet>  # This program is free software: you can redistribute it and/or modify  # it under the terms of the GNU Affero General Public License as @@ -19,7 +19,7 @@  from django.conf import settings  from django.contrib.gis.db import models -from django.utils.translation import ugettext_lazy as _, ugettext +from django.utils.translation import ugettext_lazy as _, ugettext, pgettext  from ishtar_common.models import GeneralType, BaseHistorizedItem, \            HistoricalRecords, OwnPerms, Town, Person, Source @@ -133,13 +133,17 @@ class ContextRecord(BaseHistorizedItem, OwnPerms):          verbose_name = _(u"Context Record")          verbose_name_plural = _(u"Context Record")          permissions = ( - ("view_contextrecord", ugettext(u"Can view all Context Record")), - ("view_own_contextrecord", ugettext(u"Can view own Context Record")), - ("add_own_contextrecord", ugettext(u"Can add own Context Record")), - ("change_own_contextrecord", ugettext(u"Can change own Context Record")), - ("delete_own_contextrecord", ugettext(u"Can delete own Context Record")), +            ("view_contextrecord", ugettext(u"Can view all Context Record")), +            ("view_own_contextrecord", ugettext(u"Can view own Context Record")), +            ("add_own_contextrecord", ugettext(u"Can add own Context Record")), +            ("change_own_contextrecord", ugettext(u"Can change own Context Record")), +            ("delete_own_contextrecord", ugettext(u"Can delete own Context Record")),          ) +    @property +    def short_class_name(self): +        return pgettext("short", u"Context record") +      def __unicode__(self):          return self.short_label() @@ -166,6 +170,22 @@ class ContextRecord(BaseHistorizedItem, OwnPerms):                                             self.operation.operation_code,                                             self.label] if lbl]) +    @property +    def reference(self): +        if not self.operation: +            return "00" +        return self.full_label() + +    def get_department(self): +        if not self.operation: +            return "00" +        return self.operation.get_department() + +    def get_town_label(self): +        if not self.operation: +            return "00" +        return self.operation.get_town_label() +      @classmethod      def get_years(cls):          years = set()  | 
