summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--archaeological_finds/forms.py2
-rw-r--r--archaeological_finds/models_finds.py8
-rw-r--r--ishtar_common/models.py10
3 files changed, 13 insertions, 7 deletions
diff --git a/archaeological_finds/forms.py b/archaeological_finds/forms.py
index 843d082fe..7cbbca81c 100644
--- a/archaeological_finds/forms.py
+++ b/archaeological_finds/forms.py
@@ -752,7 +752,7 @@ class QAFindBasketForm(IshtarForm):
def save(self, items):
if self.cleaned_data['qa_bf_create_or_update'] == 'update':
q = Q(user=self.user) | Q(shared_write_with__pk=self.user.pk)
- basket = models.FindBasket.objects.filter(q).get(
+ basket = models.FindBasket.objects.filter(q).distinct().get(
pk=self.cleaned_data['qa_bf_basket'])
else:
label = self.cleaned_data['qa_bf_label'].strip()
diff --git a/archaeological_finds/models_finds.py b/archaeological_finds/models_finds.py
index 328821386..25563edd0 100644
--- a/archaeological_finds/models_finds.py
+++ b/archaeological_finds/models_finds.py
@@ -55,13 +55,13 @@ from archaeological_warehouse.models import Warehouse
class MaterialType(HierarchicalType):
- code = models.CharField(_(u"Code"), max_length=10, blank=True, null=True)
- recommendation = models.TextField(_(u"Recommendation"), blank=True,
+ code = models.CharField(_("Code"), max_length=10, blank=True, null=True)
+ recommendation = models.TextField(_("Recommendation"), blank=True,
null=True)
class Meta:
- verbose_name = _(u"Material type")
- verbose_name_plural = _(u"Material types")
+ verbose_name = _("Material type")
+ verbose_name_plural = _("Material types")
ordering = ('label',)
diff --git a/ishtar_common/models.py b/ishtar_common/models.py
index 9b446ff9e..b804739ad 100644
--- a/ishtar_common/models.py
+++ b/ishtar_common/models.py
@@ -5021,7 +5021,13 @@ class Basket(FullSearch, OwnPerms, ValueGetter, TemplateItem):
:param ishtaruser: if provided an alternate user is used
:return: the new basket
"""
- items = list(self.items.all())
+ items = []
+ through = self.items.through
+ basket_pk = "{}_id".format(self.SLUG)
+ item_pk = "{}_id".format(self.items.model.SLUG)
+ q = through.objects.filter(**{basket_pk: self.pk})
+ for r in q.values("pk", item_pk).order_by("pk").all():
+ items.append(r[item_pk])
new_item = self
new_item.pk = None
if ishtaruser:
@@ -5034,7 +5040,7 @@ class Basket(FullSearch, OwnPerms, ValueGetter, TemplateItem):
new_item.label = label
new_item.save()
for item in items:
- new_item.items.add(item)
+ through.objects.create(**{basket_pk: new_item.pk, item_pk: item})
return new_item