summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--archaeological_context_records/models.py2
-rw-r--r--archaeological_finds/models_finds.py6
-rw-r--r--archaeological_finds/urls.py3
-rw-r--r--archaeological_finds/views.py9
-rw-r--r--archaeological_operations/models.py6
-rw-r--r--example_project/settings.py1
-rw-r--r--ishtar_common/models.py4
7 files changed, 19 insertions, 12 deletions
diff --git a/archaeological_context_records/models.py b/archaeological_context_records/models.py
index 2d60ba4e2..d2325082d 100644
--- a/archaeological_context_records/models.py
+++ b/archaeological_context_records/models.py
@@ -559,7 +559,7 @@ class ContextRecord(BulkUpdatedItem, DocumentItem, BaseHistorizedItem,
"site": self.archaeological_site and
self.archaeological_site.public_representation(),
"parcel": str(self.parcel),
- "town": self.town.label_with_areas(),
+ "town": self.town.label_with_areas,
"label": self.label,
"description": self.description,
"comment": self.comment
diff --git a/archaeological_finds/models_finds.py b/archaeological_finds/models_finds.py
index 8a942e306..0658496d6 100644
--- a/archaeological_finds/models_finds.py
+++ b/archaeological_finds/models_finds.py
@@ -342,8 +342,10 @@ class BaseFind(BulkUpdatedItem, BaseHistorizedItem, GeoItem, OwnPerms,
"comment": self.comment,
"discovery-date": self.discovery_date and
self.discovery_date.strftime("%Y/%m/%d"),
- "discovery-date-taq": self.discovery_date_taq,
- "discovery-date-tpq": self.discovery_date_tpq,
+ "discovery-date-taq": self.discovery_date and
+ self.discovery_date_taq.strftime("%Y/%m/%d"),
+ "discovery-date-tpq": self.discovery_date and
+ self.discovery_date.strftime("%Y/%m/%d"),
})
return dct
diff --git a/archaeological_finds/urls.py b/archaeological_finds/urls.py
index 0f86a363e..8e01a2931 100644
--- a/archaeological_finds/urls.py
+++ b/archaeological_finds/urls.py
@@ -302,6 +302,9 @@ urlpatterns = [
check_rights(['change_find', 'change_own_find'])(
views.autocomplete_findbasket),
name='autocomplete-findbasket'),
+
+ url(r'api/public/find/$', views.PublicFindAPI.as_view(),
+ name='api-public-find'),
]
urlpatterns += get_urls_for_model(models.Find, views, own=True,
diff --git a/archaeological_finds/views.py b/archaeological_finds/views.py
index 694a1e0ad..d5d5d88b6 100644
--- a/archaeological_finds/views.py
+++ b/archaeological_finds/views.py
@@ -1012,14 +1012,15 @@ class PublicFindAPI(APIView):
# permission_classes = (permissions.IsAdminUser,)
def get_queryset(self):
- basket_slug = self.kwargs.get("basket", None)
+ empty = models.Find.objects.filter(pk=None)
+ basket_slug = self.request.GET.get("basket", None)
if not basket_slug:
- return models.Find.objects.filter(pk=None)
+ return empty
try:
basket = models.FindBasket.objects.get(
- slug=basket, public=True)
+ slug=basket_slug, public=True)
except models.FindBasket.DoesNotExist:
- return Http404()
+ return empty
return models.Find.objects.filter(basket=basket).order_by("pk")
def get(self, request, format=None):
diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py
index 336a9ca74..f971981c0 100644
--- a/archaeological_operations/models.py
+++ b/archaeological_operations/models.py
@@ -347,14 +347,14 @@ class ArchaeologicalSite(DocumentItem, BaseHistorizedItem, QRCodeItem,
dct.update({
"reference": self.reference,
"name": self.name,
- "materials": [str(p) for p in self.periods.all()],
+ "periods": [str(p) for p in self.periods.all()],
"remains": [str(r) for r in self.remains.all()],
- "towns": [t.label_with_areas() for t in self.towns.all()],
+ "towns": [t.label_with_areas for t in self.towns.all()],
"comment": self.comment,
"locality": self.locality_ngi or self.locality_cadastral,
})
profile = get_current_profile()
- if profile.underwater():
+ if profile.underwater:
dct["shipwreck-name"] = self.shipwreck_name
dct["sinking-date"] = self.sinking_date
dct["discovery-area"] = self.discovery_area
diff --git a/example_project/settings.py b/example_project/settings.py
index 3897cbb21..96feaa477 100644
--- a/example_project/settings.py
+++ b/example_project/settings.py
@@ -154,6 +154,7 @@ INSTALLED_APPS = [
'archaeological_finds',
'ajax_select',
'compressor',
+ 'rest_framework',
'django.contrib.auth',
'django.contrib.admin',
'django.contrib.contenttypes',
diff --git a/ishtar_common/models.py b/ishtar_common/models.py
index bcde57ea3..7d7b6c872 100644
--- a/ishtar_common/models.py
+++ b/ishtar_common/models.py
@@ -1761,7 +1761,7 @@ class DocumentItem(object):
images.append(self.main_image.public_representation())
images += [
image.public_representation()
- for image in self.images_without_main_image().all()
+ for image in self.images_without_main_image.all()
]
return {"images": images}
@@ -5073,7 +5073,7 @@ class Document(BaseHistorizedItem, OwnPerms, ImageModel, ValueGetter, MainItem):
return {
"title": self.title,
"reference": self.reference,
- "type": self.source_type,
+ "type": self.source_type and str(self.source_type),
"authors": [a.public_representation() for a in self.authors.all()],
"image": image,
"thumbnail": thumbnail,