diff options
Diffstat (limited to 'ishtar_common/models.py')
| -rw-r--r-- | ishtar_common/models.py | 33 | 
1 files changed, 26 insertions, 7 deletions
diff --git a/ishtar_common/models.py b/ishtar_common/models.py index 8d0339b92..b92614e08 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -3069,15 +3069,19 @@ m2m_changed.connect(town_child_changed, sender=Town.children.through)  class OperationType(GeneralType):      order = models.IntegerField(_(u"Order"), default=1)      preventive = models.BooleanField(_(u"Is preventive"), default=True) +    judiciary = models.BooleanField(_(u"Is judiciary"), default=False)      class Meta:          verbose_name = _(u"Operation type")          verbose_name_plural = _(u"Operation types") -        ordering = ['-preventive', 'order', 'label'] +        ordering = ['judiciary', '-preventive', 'order', 'label']      @classmethod -    def get_types(cls, dct={}, instances=False, exclude=[], empty_first=True, -                  default=None, initial=[]): +    def get_types(cls, dct=None, instances=False, exclude=None, +                  empty_first=True, default=None, initial=None): +        dct = dct or {} +        exclude = exclude or [] +        initial = initial or []          tuples = []          dct['available'] = True          if not instances and empty_first and not default: @@ -3093,7 +3097,7 @@ class OperationType(GeneralType):              exclude.append(default.txt_idx)          if exclude:              items = items.exclude(txt_idx__in=exclude) -        current_preventive, current_lst = None, None +        current_preventive, current_judiciary, current_lst = None, None, None          item_list = list(items.order_by(*cls._meta.ordering).all())          new_vals = cls._get_initial_types(initial, [i.pk for i in item_list],                                            instance=True) @@ -3103,12 +3107,19 @@ class OperationType(GeneralType):          if instances:              return item_list          for item in item_list: -            if not current_lst or item.preventive != current_preventive: +            if not current_lst or item.preventive != current_preventive \ +                    or item.judiciary != current_judiciary:                  if current_lst:                      tuples.append(current_lst) -                current_lst = [_(u"Preventive") if item.preventive else -                               _(u"Research"), []] +                if item.judiciary: +                    gp_lbl = _(u"Judiciary") +                elif item.preventive: +                    gp_lbl = _(u"Preventive") +                else: +                    gp_lbl = _(u"Research") +                current_lst = [gp_lbl, []]                  current_preventive = item.preventive +                current_judiciary = item.judiciary              current_lst[1].append((item.pk, _(unicode(item))))          if current_lst:              tuples.append(current_lst) @@ -3124,6 +3135,14 @@ class OperationType(GeneralType):              return op_type.preventive          return key == op_type.txt_idx +    @classmethod +    def is_judiciary(cls, ope_type_id): +        try: +            op_type = cls.objects.get(pk=ope_type_id) +        except cls.DoesNotExist: +            return False +        return op_type.judiciary +  post_save.connect(post_save_cache, sender=OperationType)  post_delete.connect(post_save_cache, sender=OperationType)  | 
