Skip to content
This repository has been archived by the owner on Jun 24, 2024. It is now read-only.

Commit

Permalink
Merge branch 'release/3.7.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexandreJunod committed May 29, 2024
2 parents aae4881 + 16a1e6b commit fc568eb
Show file tree
Hide file tree
Showing 31 changed files with 342 additions and 115 deletions.
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,5 @@ USE_THUMBOR=false
# For dockerized thumbor service not exposed over the Internet, attache Geocity to its network with this override on top of this file:
# COMPOSE_FILE=docker-compose.yml:docker-compose.thumbor.yml
THUMBOR_SERVICE_URL="http://nginx-proxy"
# https://docs.djangoproject.com/en/5.0/ref/settings/#csrf-trusted-origins
CSRF_TRUSTED_ORIGINS=https://yoursite.geocity
29 changes: 28 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,31 @@
FROM sitdocker/geocity-base:v2.1.5
FROM ghcr.io/osgeo/gdal:ubuntu-small-3.8.3

RUN apt-get -y update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --fix-missing \
--no-install-recommends \
build-essential \
gettext \
python3-pip \
libcairo2-dev \
poppler-utils \
python3-dev \
python3-setuptools \
python3-wheel \
python3-cffi \
libcairo2 \
libpango-1.0-0 \
libpangocairo-1.0-0 \
libgdk-pixbuf2.0-0 \
libffi-dev \
shared-mime-info \
tzdata \
&& ln -fs /usr/share/zoneinfo/Europe/Zurich /etc/localtime \
&& dpkg-reconfigure -f noninteractive tzdata

# Update C env vars so compiler can find gdal
ENV CPLUS_INCLUDE_PATH=/usr/include/gdal
ENV C_INCLUDE_PATH=/usr/include/gdal
ENV PYTHONUNBUFFERED 1

ARG ENV

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Geocity - build your (geo)-forms easily! ![Geocity CI](https://github.com/yverdon/geocity/workflows/Geocity%20CI/badge.svg?branch=main)

**[What is Geocity ?](https://geocity.ch/about)**
**[What is Geocity ?](https://geocity-asso.ch)**

**[Features and user guide](https://github.com/yverdon/geocity/wiki)**

Expand Down
3 changes: 2 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ volumes:

services:
web: # Name of this container should not be changed
image: gms_web
image: geocity
restart: unless-stopped
build:
context: ./
Expand Down Expand Up @@ -79,6 +79,7 @@ services:
SITE_DOMAIN:
USE_THUMBOR:
THUMBOR_SERVICE_URL:
CSRF_TRUSTED_ORIGINS:
ports:
- "${DJANGO_DOCKER_PORT}:9000"
networks:
Expand Down
11 changes: 5 additions & 6 deletions geocity/apps/accounts/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,7 @@ class AdministrativeEntityAdmin(IntegratorFilterMixin, admin.ModelAdmin):
{
"fields": (
"name",
"agenda_domain",
"agenda_name",
"tags",
"ofs_id",
Expand Down Expand Up @@ -1011,13 +1012,11 @@ def sortable_str(self, obj):

@admin.display(boolean=True)
def has_background_image(self, obj):
try:
return obj.background_image.url is not None
except ValueError:
return False
return True if obj.background_image.name else False

has_background_image.admin_order_field = "background_image"
has_background_image.short_description = "Image de fond"
if has_background_image:
has_background_image.admin_order_field = "background_image"
has_background_image.short_description = "Image de fond"


# Inline for base Django Site
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 4.2.11 on 2024-05-03 13:26

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("accounts", "0018_administrativeentity_agenda_name_and_more"),
]

operations = [
migrations.AddField(
model_name="administrativeentity",
name="agenda_domain",
field=models.CharField(
blank=True,
help_text="Utilisé afin de sélectionner les agendas visible dans agenda-embed",
max_length=128,
verbose_name="Domaine de l'agenda",
),
),
]
20 changes: 20 additions & 0 deletions geocity/apps/accounts/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,14 @@ def associated_to_user(self, user):

class AdministrativeEntity(models.Model):
name = models.CharField(_("name"), max_length=128)
agenda_domain = models.CharField(
_("Domaine de l'agenda"),
help_text=_(
"Utilisé afin de sélectionner les agendas visible dans agenda-embed"
),
max_length=128,
blank=True,
)
agenda_name = models.CharField(
_("Nom dans l'api agenda"),
help_text=_("Nom visible dans le filtre de l'agenda"),
Expand Down Expand Up @@ -442,6 +450,18 @@ def clean(self):
}
)

# Unique constraint for agenda_domain
# Cannot be used on model, because None is also subject to the constraint (blank=True)
if self.agenda_domain:
if (
AdministrativeEntity.objects.exclude(pk=self.pk)
.filter(agenda_domain=self.agenda_domain)
.exists()
):
raise ValidationError(
{"agenda_domain": _("Le domaine de l'agenda doit être unique.")}
)

if (
not self.is_single_form_submissions
and Form.objects.filter(
Expand Down
2 changes: 1 addition & 1 deletion geocity/apps/accounts/templates/account/lockout.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ <h3>{% translate "Votre compte a été verrouillé par mesure de sécurité. Mer
<small>
&copy; {% now "Y" %} Geocity
&nbsp;|&nbsp;
<a href="https://geocity.ch/about" target="_blank" rel="noreferrer">{% translate "A propos" %}</a>
<a href="https://geocity-asso.ch" target="_blank" rel="noreferrer">{% translate "A propos" %}</a>
{% if config.CONTACT_URL %}
&nbsp;|&nbsp;
<a href="{{ config.CONTACT_URL }}" target="_blank" rel="noreferrer">{% translate "Contact" %}</a>
Expand Down
8 changes: 3 additions & 5 deletions geocity/apps/accounts/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
check_mandatory_2FA,
permanent_user_required,
)
from geocity.fields import PrivateFileSystemStorage, PublicFileSystemStorage
from geocity.apps.submissions import services
from geocity.fields import PublicFileSystemStorage

from . import forms, models
from .users import is_2FA_mandatory
Expand Down Expand Up @@ -396,11 +397,8 @@ def administrative_entity_file_download(request, path):
Only allows logged user to download administrative entity files
"""

mime_type, encoding = mimetypes.guess_type(path)
storage = PrivateFileSystemStorage()

try:
return StreamingHttpResponse(storage.open(path), content_type=mime_type)
return services.download_file(path)
except IOError:
raise Http404

Expand Down
2 changes: 1 addition & 1 deletion geocity/apps/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -964,7 +964,7 @@ def get_available_filters_for_agenda_as_qs(domains):

entity = (
AdministrativeEntity.objects.filter(
tags__name=domain,
agenda_domain=domain,
forms__agenda_visible=True,
)
.distinct()
Expand Down
8 changes: 6 additions & 2 deletions geocity/apps/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -625,15 +625,19 @@ def get_queryset(self):
# Filter domain (administrative_entity) to permit sites to filter on their own domain (e.g.: sports, culture)
domains = None

# Dont filter with other conditions, when trying to access to event details
# Still possible to put after a domain_filter later, if we return it in agenda-embed
if "pk" in self.kwargs:
return submissions

if "domain_filter" in query_params:
domain_filter = query_params.getlist("domain_filter")
entities = AdministrativeEntity.objects.filter(id__in=domain_filter)
submissions = get_agenda_submissions(entities, submissions)

elif "domain" in query_params:
domains = query_params["domain"]
domains = domains.split(",") if domains else None
entities = AdministrativeEntity.objects.filter(tags__name__in=domains)
entities = AdministrativeEntity.objects.filter(agenda_domain__in=domains)
submissions = get_agenda_submissions(entities, submissions)

if "starts_at" in query_params:
Expand Down
36 changes: 33 additions & 3 deletions geocity/apps/core/static/css/admin/admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,37 @@
overflow-x: auto;
}

/*Reduce select2 field width so that CRUD button remain visible*/
tr .select2 {
width: 70% !important;
/* tweak admin-sortable2 for jazzmin compatibility with tabular inlines */
/* Used in "1.4 Formulaires", tab "Champs" */

fieldset.module.sortable tbody tr.form-row {
padding: 20px 0px 10px 0px; /* top right bottom left*/
border-bottom: 1px dashed #c7c7c7;
}

fieldset.module.sortable tbody .original {
width: 50px;
text-align: center;
}

fieldset.module.sortable td.original p {
width: 45px !important;
}

fieldset.module.sortable tbody .field-field {
width: 650px;
}

fieldset.module.sortable tbody .delete {
width: 50px; /* width of div. (thead .original - tbody.original - tbody .field-field)*/
position: relative; /* used to move 50 px left */
left: 75px;
}

fieldset.module.sortable thead .original {
width: 750px;
}

fieldset.module.sortable thead .column-field {
display: none;
}
2 changes: 1 addition & 1 deletion geocity/apps/core/templates/base_generic.html
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@
<small>
&copy; {% now "Y" %} Geocity
&nbsp;|&nbsp;
<a href="https://geocity.ch/about" target="_blank" rel="noreferrer">{% translate "A propos" %}</a>
<a href="https://geocity-asso.ch" target="_blank" rel="noreferrer">{% translate "A propos" %}</a>
{% if config.CONTACT_URL %}
&nbsp;|&nbsp;
<a href="{{ config.CONTACT_URL }}" target="_blank" rel="noreferrer">{% translate "Contact" %}</a>
Expand Down
23 changes: 19 additions & 4 deletions geocity/apps/forms/admin.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import string

import django.db.models
from adminsortable2.admin import SortableAdminMixin, SortableInlineAdminMixin
from adminsortable2.admin import SortableAdminMixin, SortableTabularInline
from constance import config
from django import forms
from django.contrib import admin
Expand Down Expand Up @@ -178,8 +178,7 @@ def save(self, *args, **kwargs):
return super().save(*args, **kwargs)


# TODO: enable drag and drop for inline reorder
class FormFieldInline(admin.TabularInline, SortableInlineAdminMixin):
class FormFieldInline(SortableTabularInline):
model = models.FormField
extra = 2
verbose_name = _("Champ")
Expand All @@ -198,7 +197,7 @@ class Media:
css = {"all": ("css/admin/admin.css",)}


class FormPricesInline(admin.TabularInline, SortableInlineAdminMixin):
class FormPricesInline(admin.TabularInline):
model = models.Form.prices.through
extra = 1
verbose_name = _("Tarif")
Expand Down Expand Up @@ -556,6 +555,22 @@ def clean_maximum_date(self):

return maximum_date

def clean_map_widget_configuration(self):
selected_input_type = self.cleaned_data.get("input_type")
map_widget_configuration = self.cleaned_data.get("map_widget_configuration")

if (
selected_input_type == models.Field.INPUT_TYPE_GEOM
and not map_widget_configuration
):
raise forms.ValidationError(
_(
"Vous devez obligatoirement sélectionner une configuration de carte avancée."
)
)

return map_widget_configuration

class Media:
js = ("js/admin/form_field.js",)

Expand Down
3 changes: 3 additions & 0 deletions geocity/apps/forms/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,9 @@ class Meta:
verbose_name_plural = _("Champs du formulaire")
ordering = ("order",)

def __str__(self):
return str(self.order)


# Input types
INPUT_TYPE_ADDRESS = "address"
Expand Down
Loading

0 comments on commit fc568eb

Please sign in to comment.