diff options
| -rw-r--r-- | archaeological_finds/models_finds.py | 1 | ||||
| -rw-r--r-- | archaeological_finds/views.py | 29 | ||||
| -rw-r--r-- | ishtar_common/models_common.py | 24 | ||||
| -rw-r--r-- | ishtar_common/templates/blocks/DataTables.html | 6 | 
4 files changed, 38 insertions, 22 deletions
| diff --git a/archaeological_finds/models_finds.py b/archaeological_finds/models_finds.py index 94c3b97b4..1672a9c3c 100644 --- a/archaeological_finds/models_finds.py +++ b/archaeological_finds/models_finds.py @@ -1712,6 +1712,7 @@ class Find(              text=_("Treatment many to one"),              target="many",              rights=["change_find", "change_own_find"], +            is_popup=False,          ),          QA_LOCK,      ] diff --git a/archaeological_finds/views.py b/archaeological_finds/views.py index d04a15c67..4def2e14b 100644 --- a/archaeological_finds/views.py +++ b/archaeological_finds/views.py @@ -353,10 +353,7 @@ find_creation_wizard = wizards.FindWizard.as_view(  def find_create(request, pk):      context_record = wizard_is_available( -        find_creation_wizard, -        request, -        ContextRecord, -        pk +        find_creation_wizard, request, ContextRecord, pk      )      if not context_record:          return HttpResponseRedirect("/") @@ -656,18 +653,24 @@ treatment_creation_n1_wizard = wizards.TreatmentN1Wizard.as_view(  def treatment_n1_create(request, pks): -    for pk in pks.split("-"): -        if not wizard_is_available(treatment_creation_n1_wizard, request, models.Find, pk): +    pks = pks.split("-") +    for pk in pks: +        if not wizard_is_available( +            treatment_creation_n1_wizard, request, models.Find, pk +        ):              return HttpResponseRedirect("/")      wizards.TreatmentN1Wizard.session_set_value( -        request, "selecfind-treatment_creation_n1", "pk", pks, reset=True +        request, +        "selecfind-treatment_creation_n1", +        "resulting_pk", +        ",".join(pks), +        reset=True,      )      return redirect( -        reverse( -            "treatment_creation_n1", kwargs={"step": "file-treatment_creation_n1"} -        ) +        reverse("treatment_creation_n1", kwargs={"step": "file-treatment_creation_n1"})      ) +  treatment_1n_wizard_steps = [      ("selecfind-treatment_creation_1n", forms.SingleUpstreamFindFormSelection),      ("file-treatment_creation_1n", forms.TreatmentFormFileChoice), @@ -1321,12 +1324,6 @@ class QAFindLockView(QABaseLockView):      base_url = "find-qa-lock" -class QAFindTreatmentN1View(QAItemForm): -    model = models.Treatment -    form_class = forms.QAFindTreatmentN1Form -    base_url = "find-qa-treatmentN1" - -  def get_geo_items(request, get_polygons, current_right=None):      operation_pk = request.GET.get("operation_pk")      context_record_pk = request.GET.get("context_record_pk") diff --git a/ishtar_common/models_common.py b/ishtar_common/models_common.py index 0d8eeac54..83955ab73 100644 --- a/ishtar_common/models_common.py +++ b/ishtar_common/models_common.py @@ -2701,7 +2701,14 @@ class QuickAction:      """      def __init__( -        self, url, icon_class="", text="", target=None, rights=None, module=None +        self, +        url, +        icon_class="", +        text="", +        target=None, +        rights=None, +        module=None, +        is_popup=True,      ):          self.url = url          self.icon_class = icon_class @@ -2709,6 +2716,7 @@ class QuickAction:          self.rights = rights          self.target = target          self.module = module +        self.is_popup = is_popup          assert self.target in ("one", "many", None)      def is_available(self, user, session=None, obj=None): @@ -3255,8 +3263,13 @@ class ShortMenuItem:  class SerializeItem:      SERIALIZE_EXCLUDE = ["search_vector"] -    SERIALIZE_PROPERTIES = ["external_id", "multi_polygon_geojson", "point_2d_geojson", -                            "images_number", "json_sections"] +    SERIALIZE_PROPERTIES = [ +        "external_id", +        "multi_polygon_geojson", +        "point_2d_geojson", +        "images_number", +        "json_sections", +    ]      SERIALIZE_CALL = {}      SERIALIZE_DATES = []      SERIALIZATION_FILES = [] @@ -3284,7 +3297,7 @@ class SerializeItem:                          and hasattr(value, "full_serialize")                          and not recursion                      ): -                        #print(field.name, self.__class__, self) +                        # print(field.name, self.__class__, self)                          value = value.full_serialize(recursion=True)                      elif field_name in self.SERIALIZATION_FILES:                          try: @@ -3305,7 +3318,7 @@ class SerializeItem:                          and hasattr(first_value, "full_serialize")                          and not recursion                      ): -                        #print(field.name, self.__class__, self) +                        # print(field.name, self.__class__, self)                          values = [                              v.full_serialize(recursion=True) for v in values.all()                          ] @@ -3400,6 +3413,7 @@ class MainItem(ShortMenuItem, SerializeItem):                      mark_safe(action.text),                      mark_safe(action.rendered_icon),                      action.target or "", +                    action.is_popup,                  ]              )          return qas diff --git a/ishtar_common/templates/blocks/DataTables.html b/ishtar_common/templates/blocks/DataTables.html index 2719a9b46..a4b34cd04 100644 --- a/ishtar_common/templates/blocks/DataTables.html +++ b/ishtar_common/templates/blocks/DataTables.html @@ -223,7 +223,7 @@ jQuery(document).ready(function(){          "style": {% if multiple_select or quick_actions %}'multi'{% else %}'single'{% endif %}      },      {% if multiple_select or quick_actions %}"buttons": [ -        {% for url, title, icon, target in quick_actions %} +        {% for url, title, icon, target, is_popup in quick_actions %}          {              {% if target == 'one' %}extend: 'selectedSingle',              {% elif target == 'many' %}extend: 'selected', @@ -233,7 +233,11 @@ jQuery(document).ready(function(){              titleAttr: "{{title}}",              action: function (e, dt, node, config) {                  var url = dt_generate_qa_url(dt, "{{url}}"); +            {% if is_popup %}                  dt_qa_open(url); +            {% else %} +                window.location.href = url; +            {% endif %}                  return false;              }          }, | 
