summaryrefslogtreecommitdiff
path: root/ishtar_common/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'ishtar_common/models.py')
-rw-r--r--ishtar_common/models.py16
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.")