summaryrefslogtreecommitdiff
path: root/archaeological_finds/views.py
diff options
context:
space:
mode:
Diffstat (limited to 'archaeological_finds/views.py')
-rw-r--r--archaeological_finds/views.py56
1 files changed, 42 insertions, 14 deletions
diff --git a/archaeological_finds/views.py b/archaeological_finds/views.py
index 11509f4aa..7fdc83197 100644
--- a/archaeological_finds/views.py
+++ b/archaeological_finds/views.py
@@ -24,14 +24,14 @@ from django.conf import settings
from django.core.exceptions import PermissionDenied
from django.db.models import Q
from django.http import HttpResponseRedirect, HttpResponse, Http404
-from django.shortcuts import redirect
+from django.shortcuts import redirect, render
from django.urls import reverse
from ishtar_common.utils import ugettext_lazy as _, BSMessage
from django.views.generic import TemplateView
from django.views.generic.edit import CreateView, FormView, UpdateView
-from ishtar_common.models import get_current_profile, IshtarUser, QuickAction
+from ishtar_common.models import get_current_profile, IshtarUser
from archaeological_operations.models import AdministrativeAct, Operation
from archaeological_context_records.models import ContextRecord
from archaeological_finds import models
@@ -143,7 +143,13 @@ get_treatmentfile = get_item(
search_form=forms.TreatmentFileSelect,
)
-show_exhibition = show_item(models.Exhibition, "exhibition")
+
+def show_exhibition_extra(request, exhibition):
+ return {"ISHTAR_MUSEUM_GAM": settings.ISHTAR_MUSEUM_GAM}
+
+
+show_exhibition = show_item(models.Exhibition, "exhibition",
+ extra_dct=show_exhibition_extra)
revert_exhibition = revert_item(models.Exhibition)
get_exhibition = get_item(
models.Exhibition, "get_exhibition", "exhibition",
@@ -1410,16 +1416,7 @@ class QAExhibitionLoanFormView(QAItemForm):
base_url = "exhibition-qa-add-loan"
icon = "fa fa-plus"
action_name = _("Create")
-
- def get_quick_action(self):
- return QuickAction(
- url=self.base_url,
- icon_class=self.icon,
- text=self.page_name,
- rights=[
- "archaeological_finds.add_treatmentfile",
- ],
- )
+ permisssions = ["archaeological_finds.add_treatmentfile"]
def get_form_kwargs(self):
kwargs = super().get_form_kwargs()
@@ -1431,7 +1428,7 @@ class QAExhibitionLoanFormView(QAItemForm):
if not self.items[0].associated_basket_id:
data["messages"] = [
BSMessage(
- _("No basket associted to the exhibition."),
+ _("No basket associated to the exhibition."),
"danger", "fa fa-exclamation-triangle")
]
return data
@@ -1439,3 +1436,34 @@ class QAExhibitionLoanFormView(QAItemForm):
def form_valid(self, form):
form.save()
return HttpResponseRedirect(reverse("success"))
+
+
+def qa_gam_export_views(request, pk, *args, **kwargs):
+ # TODO: verify treatement file own view
+ try:
+ loan = models.TreatmentFile.objects.get(pk=pk)
+ except models.TreatmentFile.DoesNotExist:
+ raise Http404()
+ dct = {
+ "loan": loan,
+ "page_name": "Export GAM",
+ "url": reverse("exhibition-qa-gam-export", args=[pk]),
+ "icon": "fa fa-share-square-o",
+ "action_name": "Export GAM",
+ "cancel_name": _("Close")
+ }
+ if request.POST:
+ dct["gam_file"] = loan.gam_export()
+ dct["unavailable"] = True
+ return render(request, "ishtar/forms/qa_gam_result.html", dct)
+ if loan.is_gam_exportable():
+ dct["messages"] = [
+ BSMessage("Prêt OK pour export GAM", "info", no_dismiss=True)
+ ]
+ else:
+ dct["messages"] = [
+ BSMessage(error, "danger", no_dismiss=True)
+ for error in loan.gam_errors
+ ]
+ dct["unavailable"] = True
+ return render(request, "ishtar/forms/qa_form.html", dct)