diff options
| author | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-04-19 18:22:21 +0200 | 
|---|---|---|
| committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-06-12 08:43:31 +0200 | 
| commit | 8f73502c249f8b190a7638dfdd94535f987aeefc (patch) | |
| tree | bc1e1f4349a10489a489a5b52d515c196d20fda9 /ishtar_common/models.py | |
| parent | 149adde9e905380bfc6d633dd379be323a098dd4 (diff) | |
| download | Ishtar-8f73502c249f8b190a7638dfdd94535f987aeefc.tar.bz2 Ishtar-8f73502c249f8b190a7638dfdd94535f987aeefc.zip | |
Manage own permissions with areas for operations
Diffstat (limited to 'ishtar_common/models.py')
| -rw-r--r-- | ishtar_common/models.py | 16 | 
1 files changed, 15 insertions, 1 deletions
| diff --git a/ishtar_common/models.py b/ishtar_common/models.py index 67c4422f6..2ebe07961 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -2693,6 +2693,15 @@ class UserProfile(models.Model):              [unicode(area) for area in self.areas.all()]))      @property +    def query_towns(self): +        return Town.objects.filter( +            Q(areas__profiles=self) | Q(areas__parent__profiles=self) | +            Q(areas__parent__parent__profiles=self) | +            Q(areas__parent__parent__parent__profiles=self) | +            Q(areas__parent__parent__parent__parent__profiles=self) +        ) + +    @property      def area_labels(self):          return u", ".join([unicode(area) for area in self.areas.all()]) @@ -2743,6 +2752,10 @@ class IshtarUser(FullSearch):              return u""          return unicode(profile) +    @property +    def current_profile(self): +        return self.person.current_profile +      @classmethod      def set_superuser(cls, user):          q = cls.objects.filter(user_ptr=user) @@ -3141,7 +3154,8 @@ m2m_changed.connect(town_child_changed, sender=Town.children.through)  class Area(HierarchicalType): -    towns = models.ManyToManyField(Town, verbose_name=_(u"Towns"), blank=True) +    towns = models.ManyToManyField(Town, verbose_name=_(u"Towns"), blank=True, +                                   related_name='areas')      parent = models.ForeignKey(          'self', blank=True, null=True, verbose_name=_(u"Parent"),          help_text=_(u"Only four level of parent are managed.") | 
