summaryrefslogtreecommitdiff
path: root/ishtar_common/models.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2016-04-19 18:33:16 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2016-04-19 18:33:16 +0200
commiteb471a13710be88ca249f30a68bd056aa8c5a292 (patch)
treef2596427b81ad0df9e3a0b1b97201372b9fcc9cc /ishtar_common/models.py
parent983662e505adca020492e0672968a19c0abb6ec2 (diff)
parentfc1c422e6c5e0c57ddb6209b609b2335f9cb4dde (diff)
downloadIshtar-eb471a13710be88ca249f30a68bd056aa8c5a292.tar.bz2
Ishtar-eb471a13710be88ca249f30a68bd056aa8c5a292.zip
Merge branch 'master' into v0.9
Diffstat (limited to 'ishtar_common/models.py')
-rw-r--r--ishtar_common/models.py65
1 files changed, 52 insertions, 13 deletions
diff --git a/ishtar_common/models.py b/ishtar_common/models.py
index 2a12edc02..9509b36a6 100644
--- a/ishtar_common/models.py
+++ b/ishtar_common/models.py
@@ -1124,11 +1124,34 @@ class Address(BaseHistorizedItem):
town = models.CharField(_(u"Town"), max_length=70, null=True, blank=True)
country = models.CharField(_(u"Country"), max_length=30, null=True,
blank=True)
+ alt_address = models.TextField(_(u"Other address: address"), null=True,
+ blank=True)
+ alt_address_complement = models.TextField(
+ _(u"Other address: address complement"), null=True, blank=True)
+ alt_postal_code = models.CharField(_(u"Other address: postal code"),
+ max_length=10, null=True, blank=True)
+ alt_town = models.CharField(_(u"Other address: town"), max_length=70,
+ null=True, blank=True)
+ alt_country = models.CharField(_(u"Other address: country"),
+ max_length=30, null=True, blank=True)
phone = models.CharField(_(u"Phone"), max_length=18, null=True, blank=True)
+ phone_desc = models.CharField(_(u"Phone description"), max_length=300,
+ null=True, blank=True)
+ phone2 = models.CharField(_(u"Phone description 2"), max_length=18,
+ null=True, blank=True)
+ phone_desc2 = models.CharField(_(u"Phone description 2"), max_length=300,
+ null=True, blank=True)
+ phone3 = models.CharField(_(u"Phone 3"), max_length=18, null=True,
+ blank=True)
+ phone_desc3 = models.CharField(_(u"Phone description 3"), max_length=300,
+ null=True, blank=True)
+ raw_phone = models.TextField(_(u"Raw phone"), blank=True, null=True)
mobile_phone = models.CharField(_(u"Mobile phone"), max_length=18,
null=True, blank=True)
email = models.EmailField(
- _(u"Email"), max_length=75, blank=True, null=True)
+ _(u"Email"), max_length=300, blank=True, null=True)
+ alt_address_is_prefered = models.BooleanField(
+ _(u"Alternative address is prefered"), default=False)
history = HistoricalRecords()
class Meta:
@@ -1146,19 +1169,24 @@ class Address(BaseHistorizedItem):
def address_lbl(self):
lbl = u''
- if self.address:
- lbl += self.address
- if self.address_complement:
+ prefix = ''
+ if self.alt_address_is_prefered:
+ prefix = 'alt_'
+ if getattr(self, prefix + 'address'):
+ lbl += getattr(self, prefix + 'address')
+ if getattr(self, prefix + 'address_complement'):
if lbl:
lbl += "\n"
- lbl += self.address_complement
- if self.postal_code or self.town:
+ lbl += getattr(self, prefix + 'address_complement')
+ postal_code = getattr(self, prefix + 'postal_code')
+ town = getattr(self, prefix + 'town')
+ if postal_code or town:
if lbl:
lbl += "\n"
lbl += u"{}{}{}".format(
- self.postal_code or '',
- " " if self.postal_code and self.town else '',
- self.town or '')
+ postal_code or '',
+ " " if postal_code and town else '',
+ town or '')
if self.phone:
if lbl:
lbl += u"\n"
@@ -1248,6 +1276,8 @@ IMPORTER_CLASSES.update({
def get_importer_models():
MODELS = [
+ ('ishtar_common.models.Person', _(u"Person")),
+ ('ishtar_common.models.Organization', _(u"Organization")),
('archaeological_operations.models.Operation', _(u"Operation")),
('archaeological_operations.models.ArchaeologicalSite',
_(u"Archaeological site")),
@@ -1258,7 +1288,9 @@ def get_importer_models():
MODELS = [('archaeological_files.models.File',
_(u"Archaeological files"))] + MODELS
MODELS = [('archaeological_context_records.models.ContextRecord',
- _(u"Context records")), ] + MODELS
+ _(u"Context records")),
+ ('archaeological_context_records.models.RecordRelations',
+ _(u"Context record relations"))] + MODELS
MODELS = [('archaeological_finds.models.BaseFind',
_(u"Finds")), ] + MODELS
return MODELS
@@ -1653,6 +1685,8 @@ TARGET_MODELS = [
('archaeological_finds.models.ObjectType', _(u"Object type")),
('archaeological_context_records.models.IdentificationType',
_("Identification type")),
+ ('archaeological_context_records.models.RelationType',
+ _(u"Context record relation type")),
('SupportType', _(u"Support type")),
]
@@ -1952,7 +1986,7 @@ pre_delete.connect(pre_delete_import, sender=Import)
class Organization(Address, Merge, OwnPerms, ValueGetter):
TABLE_COLS = ('name', 'organization_type',)
- name = models.CharField(_(u"Name"), max_length=300)
+ name = models.CharField(_(u"Name"), max_length=500)
organization_type = models.ForeignKey(OrganizationType,
verbose_name=_(u"Type"))
history = HistoricalRecords()
@@ -2022,6 +2056,8 @@ class Person(Address, Merge, OwnPerms, ValueGetter):
)
TABLE_COLS = ('name', 'surname', 'raw_name', 'email', 'person_types_list',
'attached_to')
+ SHOW_URL = 'show-person'
+ MODIFY_URL = 'person_modify'
title = models.CharField(_(u"Title"), max_length=100, choices=TYPE,
blank=True, null=True)
surname = models.CharField(_(u"Surname"), max_length=50, blank=True,
@@ -2030,6 +2066,9 @@ class Person(Address, Merge, OwnPerms, ValueGetter):
null=True)
raw_name = models.CharField(_(u"Raw name"), max_length=300, blank=True,
null=True)
+ contact_type = models.CharField(_(u"Contact type"), max_length=300,
+ blank=True, null=True)
+ comment = models.TextField(_(u"Comment"), blank=True, null=True)
person_types = models.ManyToManyField(PersonType, verbose_name=_(u"Types"))
attached_to = models.ForeignKey(
'Organization', related_name='members', on_delete=models.SET_NULL,
@@ -2199,7 +2238,7 @@ class IshtarUser(User):
def full_label(self):
return self.person.full_label()
- def has_perm(self, perm, model=None, session=None):
+ def has_perm(self, perm, model=None, session=None, obj=None):
if not session:
return super(IshtarUser, self).has_perm(perm, model)
cache_key = 'usersession-{}-{}'.format(session.session_key, perm,
@@ -2207,7 +2246,7 @@ class IshtarUser(User):
res = cache.get(cache_key)
if res in (True, False):
return res
- res = super(IshtarUser, self).has_perm(perm, model)
+ res = super(IshtarUser, self).has_perm(perm, obj)
cache.set(cache_key, res, settings.CACHE_SMALLTIMEOUT)
return res