diff options
| -rw-r--r-- | Makefile.example | 1 | ||||
| -rw-r--r-- | archaeological_finds/forms.py | 8 | ||||
| -rw-r--r-- | ishtar_common/admin.py | 2 | ||||
| -rw-r--r-- | ishtar_common/models.py | 13 | 
4 files changed, 18 insertions, 6 deletions
| diff --git a/Makefile.example b/Makefile.example index 4b78bd3ae..06c580d4f 100644 --- a/Makefile.example +++ b/Makefile.example @@ -144,6 +144,7 @@ fixtures_common_importers:  fixtures_common_towns:  	cd $(project); $(PYTHON) ./manage.py dumpdata --indent 4 --natural-primary --natural-foreign  \ +							ishtar_common.state \  							ishtar_common.department \  							ishtar_common.town \  	   > '../ishtar_common/fixtures/towns-'$(default_data)'.json' diff --git a/archaeological_finds/forms.py b/archaeological_finds/forms.py index 1f81cf52f..87aaf76a9 100644 --- a/archaeological_finds/forms.py +++ b/archaeological_finds/forms.py @@ -787,7 +787,7 @@ class FindBasketAddItemForm(forms.Form):      def save(self, user):          try:              basket = models.FindBasket.objects.get( -                pk=self.cleaned_data['basket_id'], user=user.ishtaruser) +                pk=self.cleaned_data['basket_id'], user=user)              item = models.Find.objects.get(                  pk=self.cleaned_data['item_id'])          except models.FindBasket.DoesNotExist or\ @@ -795,9 +795,9 @@ class FindBasketAddItemForm(forms.Form):              # something strange... TODO: log it              raise PermissionDenied          # check rights -        if not user.is_superuser and \ -                not user.ishtaruser.has_right('change_find') and \ -                not (user.ishtaruser.has_right('change_own_find') +        if not user.user_ptr.is_superuser and \ +                not user.has_right('change_find') and \ +                not (user.has_right('change_own_find')                       and item.is_own(user)):              raise PermissionDenied          basket.items.add(item) diff --git a/ishtar_common/admin.py b/ishtar_common/admin.py index 227f7ba25..d3292148f 100644 --- a/ishtar_common/admin.py +++ b/ishtar_common/admin.py @@ -445,8 +445,6 @@ admin_site.register(models.AdministrationTask, AdministrationTaskAdmin)  basic_models = [models.DocumentTemplate] -if settings.COUNTRY == 'fr': -    basic_models += [models.Arrondissement, models.Canton]  for model in basic_models:      admin_site.register(model) diff --git a/ishtar_common/models.py b/ishtar_common/models.py index 678564dda..53c05d180 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -1900,9 +1900,15 @@ class DocumentTemplate(models.Model):          return output_name +class NumberManager(models.Manager): +    def get_by_natural_key(self, number): +        return self.get(number=number) + +  class State(models.Model):      label = models.CharField(_(u"Label"), max_length=30)      number = models.CharField(_(u"Number"), unique=True, max_length=3) +    objects = NumberManager()      class Meta:          verbose_name = _(u"State") @@ -1911,12 +1917,16 @@ class State(models.Model):      def __unicode__(self):          return self.label +    def natural_key(self): +        return (self.number, ) +  class Department(models.Model):      label = models.CharField(_(u"Label"), max_length=30)      number = models.CharField(_(u"Number"), unique=True, max_length=3)      state = models.ForeignKey('State', verbose_name=_(u"State"), blank=True,                                null=True) +    objects = NumberManager()      class Meta:          verbose_name = _(u"Department") @@ -1926,6 +1936,9 @@ class Department(models.Model):      def __unicode__(self):          return self.label +    def natural_key(self): +        return (self.number, ) +  class Address(BaseHistorizedItem):      address = models.TextField(_(u"Address"), null=True, blank=True) | 
