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.4.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexandreJunod committed Jan 17, 2024
2 parents 8cc5864 + 9654517 commit 74ad2e2
Show file tree
Hide file tree
Showing 36 changed files with 856 additions and 502 deletions.
14 changes: 7 additions & 7 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -53,26 +53,26 @@ SESSION_COOKIE_AGE=3600
# SESSION_SAVE_EVERY_REQUEST reset timeout on each user request, if set to False, only SESSION_COOKIE_AGE applies
SESSION_SAVE_EVERY_REQUEST=True
# SESSION_COOKIE_SAMESITE recommended options ('Lax' or 'Strict')
#https://docs.djangoproject.com/en/3.2/ref/settings/#session-cookie-samesite
# Doc: https://docs.djangoproject.com/en/3.2/ref/settings/#session-cookie-samesite
SESSION_COOKIE_SAMESITE=Lax
# Always make sure your proxy strips the HTTP_X_FORWARDED_PROTO header value before setting this value!
# (https://docs.djangoproject.com/en/3.2/ref/settings/#secure-proxy-ssl-header)
# Doc: https://docs.djangoproject.com/en/3.2/ref/settings/#secure-proxy-ssl-header
SECURE_PROXY_SSL_HEADER=HTTP_X_FORWARDED_PROTO,https
# LIMIT MAX CONNEXIONS ATTEMPTS
# Limit max connexions attempts
AXES_FAILURE_LIMIT=5
# Lock out by combination of ip AND User
# Please read https://django-axes.readthedocs.io/en/latest/5_customization.html#customizing-lockout-parameters
# Lockout parameters
# Doc: https://django-axes.readthedocs.io/en/latest/5_customization.html#customizing-lockout-parameters
AXES_LOCKOUT_PARAMETERS=username
AXES_COOLOFF_TIME=2
AXES_IPWARE_PROXY_COUNT=1
#Limit requests on DRF. Note that this might impact the print service!
# Limit requests on DRF. Note that this might impact the print service!
DRF_THROTTLE_RATE_PERMITS_API='1000/day'
DRF_THROTTLE_RATE_PERMITS_DETAILS_API='1000/day'
DRF_THROTTLE_RATE_EVENTS_API='100000/day'
DRF_THROTTLE_RATE_SEARCH_API='1000/day'
DRF_THROTTLE_RATE_AGENDA_API='100000/day'
# Only enable this option on local network where a secured SSO controls the network access
# Please refer to https://docs.djangoproject.com/en/4.0/howto/auth-remote-user/ for more informations
# Doc: https://docs.djangoproject.com/en/4.0/howto/auth-remote-user/
ALLOW_REMOTE_USER_AUTH=False
LOCATIONS_SEARCH_API="https://api3.geo.admin.ch/rest/services/api/SearchServer"
LOCATIONS_SEARCH_API_DETAILS="https://api3.geo.admin.ch/rest/services/api/MapServer/ch.bfs.gebaeude_wohnungs_register/"
Expand Down
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,18 @@ docker-compose run web scripts/migrate.sh

**Load demo data**

Edit file `geocity/apps/submissions/management/commands/fixturize_data/fixturize.py`
There is some examples in same folder and you can create new ones
Create a file in `geocity/apps/submissions/management/commands/fixturize_data/`.

There is some examples in same folder and you can create new ones.

The file will automatically appear once it's created.

`docker-compose run web python manage.py fixturize` is interactive and can use some arguments as :

- `--help` : Shows description of command and available arguments
- `--list` : List available files to be used as fixtures
- `--file` : Use a specific file. Example : `--file=agenda`
- no args : Asks if you want to run default fixture file

```bash
# Load demo data
Expand Down
2 changes: 1 addition & 1 deletion geocity/apps/accounts/dootix/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def save_user(self, request, sociallogin: SocialLogin, form=None):
phone_second=form.cleaned_data["phone_second"],
company_name=form.cleaned_data["company_name"],
vat_number=form.cleaned_data["vat_number"],
iban=form.cleaned_data["iban"],
iban=form.cleaned_data["iban"] if settings.AUTHOR_IBAN_VISIBLE else "",
)

return user
Expand Down
11 changes: 8 additions & 3 deletions geocity/apps/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -931,9 +931,14 @@ def get_available_filters_for_agenda_as_qs(domain):
if not domain:
return None

entity = AdministrativeEntity.objects.filter(
tags__name=domain
).first() # get can return an error
entity = (
AdministrativeEntity.objects.filter(
tags__name=domain,
forms__agenda_visible=True,
)
.distinct()
.first()
) # get can return an error

available_filters = Field.objects.filter(forms__administrative_entities=entity)

Expand Down
16 changes: 13 additions & 3 deletions geocity/apps/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,19 @@ def get_queryset(self):
entity = AdministrativeEntity.objects.filter(
tags__name=domain
).first() # get can return an error
submissions = submissions.filter(administrative_entity=entity)

# To validate a request and show it in agenda, an user need to be pilot of his own entity and validator for other entities.
# Retrieve pilots of entity
pilot_of_entity = User.objects.filter(
groups__permit_department__administrative_entity=entity,
groups__permit_department__is_backoffice=True,
).values("id")

# Check agenda submissions is validated by any user on the pilot group of it's own entity
submissions = submissions.filter(
Q(administrative_entity=entity)
| Q(validations__validated_by__in=pilot_of_entity)
)

if "starts_at" in query_params:
starts_at = datetime.datetime.strptime(
Expand Down Expand Up @@ -633,14 +645,12 @@ def get_queryset(self):

# Do the required actions fo every query_param
for field_name in query_params:

# Check if the given query_param is used to filter (is it a category ?)
field_name_is_api_filter = any(
field_name in api_filter
for api_filter in available_filters.values_list("api_name")
)
if field_name_is_api_filter:

# Prepare queryset to filter by categories
conditions = Q()

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#map-ro-result {
.map-ro-result {
width: 100%;
height: 30vh;
}

#map-custom-modal-button {
.map-custom-modal-button {
border: 1px solid #008c6f;
color: #008c6f;
width: 222px;
Expand All @@ -13,30 +13,38 @@
margin-top: 4px;
}

#map-custom-modal-button > i {
.disable-map-modal-button .map-custom-modal-button {
visibility: hidden;
}

.disable-map-modal-button {
width: 100%;
}

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

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

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

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

#map-custom-modal-overlay {
.map-custom-modal-overlay {
position: fixed;
z-index: 1021;
top: 0;
Expand Down Expand Up @@ -81,7 +89,7 @@
align-items: center;
}

#modal-validation-button {
.modal-validation-button {
width: 229px;
height: 36px;
color: white;
Expand Down
8 changes: 4 additions & 4 deletions geocity/apps/core/static/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -605,14 +605,14 @@ th.actions {
font-size: 1.3rem;
}

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

#web-component-advanced {
.web-component-advanced {
width: calc(100% - 40px);
height: calc(var(--window-modal-size) * 0.8 - 96px);
}
Expand Down Expand Up @@ -673,14 +673,14 @@ th.actions {
line-height: 15px;
}

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

#web-component-advanced {
.web-component-advanced {
width: 100%;
height: calc(var(--window-modal-size) - 96px);
}
Expand Down
14 changes: 14 additions & 0 deletions geocity/apps/core/static/js/admin/form_field.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ document.addEventListener('DOMContentLoaded', function() {
const choicesLabelElement = choicesRowElement.querySelector('label');
const isChoicesVisible = inputType === 'list_single' || inputType === 'list_multiple';

const mapWidgetConfigurationElement = document.getElementById('id_map_widget_configuration');
const mapWidgetConfigurationRowElement = mapWidgetConfigurationElement.closest('.form-group');
const mapWidgetConfigurationLabelElement = mapWidgetConfigurationRowElement.querySelector('label');
const isMapWidgetConfigurationVisible = inputType === 'geom';

const filterForApiElement = document.getElementById('id_filter_for_api');
const filterForApiRowElement = filterForApiElement.closest('.form-group');

Expand Down Expand Up @@ -79,6 +84,10 @@ document.addEventListener('DOMContentLoaded', function() {
choicesRowElement.classList.add(hiddenClass);
choicesLabelElement.classList.remove(requiredClass);

mapWidgetConfigurationElement.removeAttribute('required');
mapWidgetConfigurationRowElement.classList.add(hiddenClass);
mapWidgetConfigurationLabelElement.classList.remove(requiredClass);

filterForApiRowElement.classList.add(hiddenClass);

regexElement.removeAttribute('required');
Expand Down Expand Up @@ -113,6 +122,11 @@ document.addEventListener('DOMContentLoaded', function() {

filterForApiRowElement.classList.remove(hiddenClass);
}
else if (isMapWidgetConfigurationVisible) {
mapWidgetConfigurationElement.setAttribute('required', '');
mapWidgetConfigurationRowElement.classList.remove(hiddenClass);
mapWidgetConfigurationLabelElement.classList.add(requiredClass);
}
else if (isAllowedFileVisible) {
allowedFileElement.setAttribute('required', '');
allowedFileRowElement.classList.remove(hiddenClass);
Expand Down
Loading

0 comments on commit 74ad2e2

Please sign in to comment.