summaryrefslogtreecommitdiff
path: root/archaeological_finds
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2016-06-02 16:07:31 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2016-06-02 16:07:31 +0200
commit4566ddf6dfaa7d6a888e41638238096a4f8f53fc (patch)
tree7c6f95d37fe429c118496e3f797f69df88aa129b /archaeological_finds
parente403a92298d8108b55a9631c65a98a660f451d61 (diff)
downloadIshtar-4566ddf6dfaa7d6a888e41638238096a4f8f53fc.tar.bz2
Ishtar-4566ddf6dfaa7d6a888e41638238096a4f8f53fc.zip
Generic management of baskets in owns items
Diffstat (limited to 'archaeological_finds')
-rw-r--r--archaeological_finds/models.py17
1 files changed, 6 insertions, 11 deletions
diff --git a/archaeological_finds/models.py b/archaeological_finds/models.py
index 9c972f68c..417dd3929 100644
--- a/archaeological_finds/models.py
+++ b/archaeological_finds/models.py
@@ -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)
@@ -384,12 +390,6 @@ class Find(BaseHistorizedItem, ImageModel, OwnPerms, ShortMenuItem):
lbl += u' ({})'.format(base)
return lbl
- @classmethod
- def get_owns(cls, user):
- if user.is_anonymous():
- return FindBasket.objects.none()
- return FindBasket.objects.filter(user=user)
-
def get_first_base_find(self):
q = self.base_finds
if not q.count():
@@ -546,11 +546,6 @@ class Find(BaseHistorizedItem, ImageModel, OwnPerms, ShortMenuItem):
# idx and idx['material_index__max'] + 1 or 1
-class FindBasket(Basket):
- items = models.ManyToManyField(Find, blank=True, null=True,
- related_name='basket')
-
-
class FindSource(Source):
SHOW_URL = 'show-findsource'