summaryrefslogtreecommitdiff
path: root/archaeological_finds/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'archaeological_finds/models.py')
-rw-r--r--archaeological_finds/models.py20
1 files changed, 19 insertions, 1 deletions
diff --git a/archaeological_finds/models.py b/archaeological_finds/models.py
index b52aabbf2..417dd3929 100644
--- a/archaeological_finds/models.py
+++ b/archaeological_finds/models.py
@@ -27,7 +27,7 @@ from django.utils.translation import ugettext_lazy as _, ugettext
from ishtar_common.models import GeneralType, ImageModel, BaseHistorizedItem, \
ShortMenuItem, LightHistorizedItem, HistoricalRecords, OwnPerms, Source, \
- Person
+ Person, Basket
from archaeological_operations.models import AdministrativeAct
from archaeological_context_records.models import ContextRecord, Dating
@@ -240,6 +240,11 @@ CHECK_CHOICES = (('NC', _(u"Not checked")),
)
+class FindBasket(Basket):
+ items = models.ManyToManyField('Find', blank=True, null=True,
+ related_name='basket')
+
+
class Find(BaseHistorizedItem, ImageModel, OwnPerms, ShortMenuItem):
CHECK_DICT = dict(CHECK_CHOICES)
SHOW_URL = 'show-find'
@@ -329,6 +334,7 @@ class Find(BaseHistorizedItem, ImageModel, OwnPerms, ShortMenuItem):
check_date = models.DateField(_(u"Check date"),
default=datetime.date.today)
history = HistoricalRecords()
+ BASKET_MODEL = FindBasket
def __init__(self, *args, **kwargs):
super(Find, self).__init__(*args, **kwargs)
@@ -372,6 +378,18 @@ class Find(BaseHistorizedItem, ImageModel, OwnPerms, ShortMenuItem):
return u" - ".join([base_find.name
for base_find in self.base_finds.all()])
+ @property
+ def full_label(self):
+ lbl = u" - ".join([
+ getattr(self, attr)
+ for attr in ('label', 'administrative_index')
+ if getattr(self, attr)])
+ base = u" - ".join([base_find.complete_id()
+ for base_find in self.base_finds.all()])
+ if base:
+ lbl += u' ({})'.format(base)
+ return lbl
+
def get_first_base_find(self):
q = self.base_finds
if not q.count():