diff options
-rw-r--r-- | archaeological_context_records/admin.py | 2 | ||||
-rw-r--r-- | archaeological_finds/wizards.py | 6 | ||||
-rw-r--r-- | ishtar_common/admin.py | 2 | ||||
-rw-r--r-- | ishtar_common/migrations/0248_ishtarsiteprofile_no_context_button.py | 20 | ||||
-rw-r--r-- | ishtar_common/models.py | 8 | ||||
-rw-r--r-- | ishtar_common/templates/gis/openlayers-osm.html | 7 | ||||
-rw-r--r-- | ishtar_common/templates/ishtar/wizard/default_wizard.html | 9 | ||||
-rw-r--r-- | ishtar_common/wizards.py | 2 |
8 files changed, 51 insertions, 5 deletions
diff --git a/archaeological_context_records/admin.py b/archaeological_context_records/admin.py index 8182c1bda..518650874 100644 --- a/archaeological_context_records/admin.py +++ b/archaeological_context_records/admin.py @@ -45,7 +45,7 @@ class ContextRecordAdmin(HistorizedObjectAdmin, MainGeoDataItem): list_filter = ("unit",) search_fields = ( "cached_label", - "town", + "town__name", "parcel__section", "parcel__parcel_number", ) diff --git a/archaeological_finds/wizards.py b/archaeological_finds/wizards.py index 91795d60e..d6647b81c 100644 --- a/archaeological_finds/wizards.py +++ b/archaeological_finds/wizards.py @@ -19,7 +19,7 @@ from django.contrib import messages from django.core.exceptions import ObjectDoesNotExist, PermissionDenied -from ishtar_common.utils import ugettext_lazy as _, pgettext +from ishtar_common.utils import ugettext_lazy as _, pgettext, get_current_profile from ishtar_common.forms import reverse_lazy from ishtar_common.wizards import ( @@ -86,6 +86,10 @@ class FindWizard(Wizard): """ context = super(FindWizard, self).get_context_data(form, **kwargs) current_cr = self.get_current_contextrecord() + if self.steps.current.startswith("selec"): + profile = get_current_profile() + if profile.no_context_button_id: + context["no_context_cr"] = profile.no_context_button_id if not current_cr or self.steps.current.startswith("select-"): return context context["reminders"] = ( diff --git a/ishtar_common/admin.py b/ishtar_common/admin.py index ae0f9eb3f..44ca43ec2 100644 --- a/ishtar_common/admin.py +++ b/ishtar_common/admin.py @@ -523,6 +523,7 @@ class IshtarSiteProfileAdmin(admin.ModelAdmin): ) model = models.IshtarSiteProfile form = AdminIshtarSiteProfileForm + autocomplete_fields = ["no_context_button"] fieldsets = ( (None, { "fields": ( @@ -583,6 +584,7 @@ class IshtarSiteProfileAdmin(admin.ModelAdmin): "use_town_for_geo", "relation_graph", "parcel_mandatory", + "no_context_button", ), }), (_("Index"), { diff --git a/ishtar_common/migrations/0248_ishtarsiteprofile_no_context_button.py b/ishtar_common/migrations/0248_ishtarsiteprofile_no_context_button.py new file mode 100644 index 000000000..4bb7a1883 --- /dev/null +++ b/ishtar_common/migrations/0248_ishtarsiteprofile_no_context_button.py @@ -0,0 +1,20 @@ +# Generated by Django 2.2.24 on 2024-07-15 10:50 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('archaeological_context_records', '0117_identification_m2m'), + ('ishtar_common', '0247_document_cached_authors'), + ] + + operations = [ + migrations.AddField( + model_name='ishtarsiteprofile', + name='no_context_button', + field=models.ForeignKey(blank=True, help_text='If provided a button is displayed on find search pages to create a "No context" find', null=True, on_delete=django.db.models.deletion.SET_NULL, to='archaeological_context_records.ContextRecord', verbose_name='Default context record for no context button'), + ), + ] diff --git a/ishtar_common/models.py b/ishtar_common/models.py index 9eeea5d66..1f8eab6a8 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -1181,6 +1181,14 @@ class IshtarSiteProfile(models.Model, Cached): _("Preventive operator module"), default=False ) underwater = models.BooleanField(_("Underwater module"), default=False) + no_context_button = models.ForeignKey( + "archaeological_context_records.ContextRecord", + verbose_name=_("Context record for no context button"), + help_text=_('If provided a button is displayed on find search pages to create a "No context" find'), + on_delete=models.SET_NULL, + null=True, + blank=True + ) parcel_mandatory = models.BooleanField( _("Parcel are mandatory for context records"), default=True ) diff --git a/ishtar_common/templates/gis/openlayers-osm.html b/ishtar_common/templates/gis/openlayers-osm.html index 4ed773a33..59969210a 100644 --- a/ishtar_common/templates/gis/openlayers-osm.html +++ b/ishtar_common/templates/gis/openlayers-osm.html @@ -35,8 +35,11 @@ groupSelectStyle: 'children' }); {{ module }}.map.addControl(layer_switcher); - $(".ol-viewport").parent().width($(".form").width()); - $(document).ready(function() { + {% comment %}$(".ol-viewport").parent().width($(".form").width());{% endcomment %} + let ol_viewport = document.querySelector(".ol-viewport"); + if (ol_viewport.parent) ol_viewport.parent().width(document.querySelector(".form").width()); + {% comment %}$(document).ready(function() { {% endcomment %} + document.addEventListener("DOMContentLoaded", function() { {{ module }}.map.updateSize(); let features = {{ module }}.featureOverlay.getSource().getFeatures(); if (features.length){ diff --git a/ishtar_common/templates/ishtar/wizard/default_wizard.html b/ishtar_common/templates/ishtar/wizard/default_wizard.html index c4a304111..0d3863af9 100644 --- a/ishtar_common/templates/ishtar/wizard/default_wizard.html +++ b/ishtar_common/templates/ishtar/wizard/default_wizard.html @@ -6,6 +6,15 @@ {% block content %} {% block wizard_head %} <h3>{{wizard_label}}</h3> +{% if no_context_cr %} +<div class="row mb-3"> + <div class="col"> + <a href="/find_create/{{no_context_cr|unlocalize}}/" class="btn btn-success"> + <i class="fa fa-plus" aria-hidden="true"></i> {% trans "find without context" %} + </a> + </div> +</div> +{% endif %} {% include "ishtar/blocks/wizard_breadcrumb.html" %} diff --git a/ishtar_common/wizards.py b/ishtar_common/wizards.py index dee3c9a1f..43e84fbcb 100644 --- a/ishtar_common/wizards.py +++ b/ishtar_common/wizards.py @@ -1689,7 +1689,7 @@ class SearchWizard(IshtarWizard): return self.label def get_context_data(self, form, **kwargs): - context = super(SearchWizard, self).get_context_data(form) + context = super().get_context_data(form) self.request.session["CURRENT_ACTION"] = self.get_wizard_name() current_step = self.steps.current bookmark = self.request.GET.get("bookmark", None) |