Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions geocity/admin_jazzmin_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
"forms.Field": "fas fa-list-ol",
"forms.Form": "fas fa-book",
"forms.FormCategory": "fas fa-object-ungroup",
"forms.MapWidgetConfiguration": "fa fa-map",
"knox.AuthToken": "fas fa-user-secret",
"reports.Report": "fas fa-print",
"reports.ReportLayout": "fas fa-file-alt",
Expand Down
23 changes: 23 additions & 0 deletions geocity/apps/accounts/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from knox.models import AuthToken

from geocity.apps.accounts.models import AdministrativeEntity, UserProfile
from geocity.apps.forms.models import MapWidgetConfiguration
from geocity.apps.reports.models import Report
from geocity.apps.submissions.models import Submission, SubmissionWorkflowStatus
from geocity.fields import GeometryWidget
Expand Down Expand Up @@ -548,13 +549,29 @@ def get_sites_field(user):
)


class MapCustomChoiceField(forms.ModelChoiceField):
def label_from_instance(self, obj):
return obj.name


def get_map_config():
qs = MapWidgetConfiguration.objects.all()

return MapCustomChoiceField(
queryset=qs,
widget=forms.Select,
label=_("Configuration de la carte avancée"),
)


class AdministrativeEntityAdminForm(forms.ModelForm):
"""Form class to configure an administrative entity (commune, organisation)"""

def __init__(self, *args, **kwargs):
user = kwargs.pop("user")
super().__init__(*args, **kwargs)
self.fields["sites"] = get_sites_field(user)
self.fields["map_widget_configuration"] = get_map_config()

class Meta:
model = models.AdministrativeEntityForAdminSite
Expand All @@ -577,6 +594,7 @@ class Meta:
"signature_sheet",
"signature_sheet_description",
"additional_searchtext_for_address_field",
"map_widget_configuration",
"geom",
"integrator",
]
Expand Down Expand Up @@ -662,6 +680,7 @@ class AdministrativeEntityAdmin(IntegratorFilterMixin, admin.ModelAdmin):
"general_informations",
"phone",
"additional_searchtext_for_address_field",
"map_widget_configuration",
"geom",
"integrator",
)
Expand Down Expand Up @@ -760,6 +779,10 @@ def formfield_for_foreignkey(self, db_field, request, **kwargs):
kwargs["queryset"] = Group.objects.filter(
permit_department__is_integrator_admin=True,
)
if db_field.name == "map_widget_configuration":
kwargs["queryset"] = filter_for_user(
request.user, MapWidgetConfiguration.objects.all()
)
return super().formfield_for_foreignkey(db_field, request, **kwargs)

def save_model(self, request, obj, form, change):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Generated by Django 4.1.7 on 2023-03-10 12:54

import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("forms", "0018_add_fields_for_new_map_widget"),
("accounts", "0011_add_signature_sheet_to_administrative_entity"),
]

operations = [
migrations.AddField(
model_name="administrativeentity",
name="map_widget_configuration",
field=models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.SET_NULL,
to="forms.mapwidgetconfiguration",
verbose_name="Configuration de la carte avancée",
),
),
]
26 changes: 26 additions & 0 deletions geocity/apps/accounts/migrations/0013_add_related_name_for_fk.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Generated by Django 4.1.7 on 2023-03-10 13:17

import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("forms", "0019_add_related_name_for_fk"),
("accounts", "0012_add_fields_for_new_map_widget"),
]

operations = [
migrations.AlterField(
model_name="administrativeentity",
name="map_widget_configuration",
field=models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="map_widget_configuration_administrative_entity",
to="forms.mapwidgetconfiguration",
verbose_name="Configuration de la carte avancée",
),
),
]
7 changes: 7 additions & 0 deletions geocity/apps/accounts/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,13 @@ class AdministrativeEntity(models.Model):
),
)
geom = geomodels.MultiPolygonField(_("geom"), null=True, srid=2056)
map_widget_configuration = models.ForeignKey(
"forms.MapWidgetConfiguration",
null=True,
on_delete=models.SET_NULL,
verbose_name=_("Configuration de la carte avancée"),
related_name="map_widget_configuration_administrative_entity",
)
tags = TaggableManager(
blank=True,
verbose_name=_("Mots-clés"),
Expand Down
1 change: 1 addition & 0 deletions geocity/apps/accounts/permissions_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"paymentsettings",
"price",
"formprice",
"mapwidgetconfiguration",
],
"submissions": [
"submissionamendfield",
Expand Down
3 changes: 3 additions & 0 deletions geocity/apps/core/static/css/admin/display.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.hide {
display: none;
}
53 changes: 53 additions & 0 deletions geocity/apps/core/static/css/admin/map_widget_configurator.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
@media (min-width: 768px) {

.rjf-form-row > .rjf-form-row-controls + .rjf-form-row-inner {
padding-right: 0px;
}

.rjf-form-row > .rjf-form-row-controls + .rjf-form-row-inner > div > label {
width: 100%;
}

.rjf-form-row > .rjf-form-row-inner > div > .rjf-input-group {
width: 100%;
}

.rjf-form-row > .rjf-form-row-inner > div > .rjf-input-group > input {
max-width: none;
}

.rjf-form-group-inner > .rjf-form-group-wrapper {
max-width: none;
}

.rjf-form-wrapper > .module > .rjf-form-group {
max-width: none;
}

.rjf-form-wrapper > .module > .rjf-form-group > .rjf-form-group-inner > .rjf-form-group {
max-width: none;
}

.rjf-form-group-inner > .rjf-form-group-wrapper > .rjf-form-group > .rjf-form-group-inner > .rjf-form-group-wrapper > .rjf-form-group > .rjf-form-group-inner > .rjf-form-group {
max-width: none;
}

}

.rjf-check-input > label > input[name="rjf§mode§type"],
.rjf-check-input > label > input[name="rjf§outputFormat"] {
max-width: 12px;
margin: 10px;
}

.rjf-form-row > .rjf-form-row-controls {
display: none;
}

.rjf-form-row label input[type="checkbox"] {
margin-right: 8px;
}

input[type="text"]::placeholder {
color: lightgray;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#map-ro-result {
width: 100%;
height: 30vh;
}

#map-custom-modal-button {
border: 1px solid #008c6f;
color: #008c6f;
width: 222px;
height: 38px;
justify-content: center;
align-items: center;
margin-top: 4px;
}

#map-custom-modal-button > i {
padding-right: 7px;
}

#geo-invalid-content {
color: #dc3545;
display: none;
width: 100%;
font-weight: bold;
font-size: 80%;
}

#map-custom-modal {
position: fixed;
z-index: 1022;
background-color: white;
}

#web-component-advanced {
margin-left: auto;
margin-right: auto;
}

#map-custom-modal-overlay {
position: fixed;
z-index: 1021;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
background-color: black;
opacity: 0.4;
}

.map-modal-header {
width: calc(100% - 40px);
margin-left: 20px;
height: 48px;
display: flex;
align-items: center;
}

.map-modal-header > p {
width: 80%;
margin: 0;
font-weight: bold;
font-size: 16px;
line-height: 19px;
display: flex;
justify-content: flex-start;
align-items: center;
}

.map-modal-header > i {
width: 20%;
display: flex;
justify-content: flex-end;
align-items: center;
}

.validate-layout {
width: 100%;
height: 48px;
display: flex;
justify-content: center;
align-items: center;
}

#modal-validation-button {
width: 229px;
height: 36px;
color: white;
background-color: #008c6f;
display: flex;
align-items: center;
justify-content: center;
text-align: center;
}

.cursor {
cursor: pointer;
}
24 changes: 24 additions & 0 deletions geocity/apps/core/static/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,18 @@ th.actions {
h5 {
font-size: 1.3rem;
}

#map-custom-modal {
top: 5vh;
left: 10vw;
width: 80vw;
height: 80vh;
}

#web-component-advanced {
width: calc(100% - 40px);
height: calc(var(--window-modal-size) * 0.8 - 96px);
}
}

@media (max-width: 768px) {
Expand Down Expand Up @@ -653,6 +665,18 @@ th.actions {
line-height: 15px;
}

#map-custom-modal {
top: 0vh;
left: 0vw;
width: 100vw;
height: 100vh;
}

#web-component-advanced {
width: 100%;
height: calc(var(--window-modal-size) - 96px);
}

}

.search-results {
Expand Down
9 changes: 9 additions & 0 deletions geocity/apps/core/static/images/aerial.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions geocity/apps/core/static/images/base.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions geocity/apps/core/static/js/admin/display.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
document.addEventListener('DOMContentLoaded', () => {
function updateFields() {
const state = document.getElementById('id_geo_widget_option').value;
if (state == 1) {
document.getElementsByClassName('field-map_widget_configuration')[0].classList.add('hide')
document.getElementsByClassName('field-geometry_types')[0].classList.remove('hide')
document.getElementsByClassName('field-wms_layers')[0].classList.remove('hide')
document.getElementsByClassName('field-wms_layers_order')[0].classList.remove('hide')
}

if (state == 2) {
document.getElementsByClassName('field-map_widget_configuration')[0].classList.remove('hide')
document.getElementsByClassName('field-geometry_types')[0].classList.add('hide')
document.getElementsByClassName('field-wms_layers')[0].classList.add('hide')
document.getElementsByClassName('field-wms_layers_order')[0].classList.add('hide')
}
}

jQuery('#id_geo_widget_option').on("change", updateFields);
updateFields();
})
Loading