Skip to content

Commit

Permalink
Merge pull request #1773 from digitalfabrik/develop
Browse files Browse the repository at this point in the history
Release `2022.10.1`
  • Loading branch information
timobrembeck authored Oct 17, 2022
2 parents d68c72f + f8debc4 commit 93dd990
Show file tree
Hide file tree
Showing 207 changed files with 3,504 additions and 872 deletions.
8 changes: 4 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
steps:
- checkout
- restore_cache:
key: pipenv-{{ checksum "Pipfile.lock" }}-v1
key: pipenv-{{ checksum "Pipfile.lock" }}-v2
- run:
name: Install pip dependencies
command: |
Expand All @@ -26,7 +26,7 @@ jobs:
fi
fi
- save_cache:
key: pipenv-{{ checksum "Pipfile.lock" }}-v1
key: pipenv-{{ checksum "Pipfile.lock" }}-v2
paths:
- .venv
- integreat_cms.egg-info
Expand Down Expand Up @@ -97,7 +97,7 @@ jobs:
- checkout
- restore_cache:
keys:
- npm-{{ checksum "package-lock.json" }}-v1
- npm-{{ checksum "package-lock.json" }}-v2
- run:
name: Install npm dependencies
command: |
Expand All @@ -112,7 +112,7 @@ jobs:
fi
fi
- save_cache:
key: npm-{{ checksum "package-lock.json" }}-v1
key: npm-{{ checksum "package-lock.json" }}-v2
paths:
- node_modules
- run:
Expand Down
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
UNRELEASED
----------

* [ [#1759](https://github.com/digitalfabrik/integreat-cms/issues/1759) ] Add line break between images in PDF exports
* [ [#1537](https://github.com/digitalfabrik/integreat-cms/issues/1537) ] Fix broken inline icons in PDF exports
* [ [#951](https://github.com/digitalfabrik/integreat-cms/issues/951) ] Add possibility to create categories for POIs
* [ [#1742](https://github.com/digitalfabrik/integreat-cms/issues/1742) ] Add last modified date to media sidebar
* [ [#1703](https://github.com/digitalfabrik/integreat-cms/issues/1703) ] Remove pending account activation warning when user form is submitted with errors
* [ [#1684](https://github.com/digitalfabrik/integreat-cms/issues/1684) ] Set filesize limit for uploads to 3MB
* [ [#1000](https://github.com/digitalfabrik/integreat-cms/issues/1000) ] Auto-complete address and coordinates of locations
* [ [#1434](https://github.com/digitalfabrik/integreat-cms/issues/1434) ] Add display of HIX values to nudge users to write easier texts
* [ [#1770](https://github.com/digitalfabrik/integreat-cms/issues/1770) ] Fix error in SUMM.AI translation if paragraph contains only special characters
* [ [#1710](https://github.com/digitalfabrik/integreat-cms/issues/1710) ] Add spacing to sidebar to improve view on small screens
* [ [#1526](https://github.com/digitalfabrik/integreat-cms/issues/1526)] Fix sending push notifications in one language
* [ [#1630](https://github.com/digitalfabrik/integreat-cms/issues/1630)] Fix not recognized sent status of push notifications
* [ [#1683](https://github.com/digitalfabrik/integreat-cms/issues/1683) ] Improve organization management


2022.10.0
---------
Expand Down
1 change: 1 addition & 0 deletions dev-tools/_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ function wait_for_docker_container {
# This function creates a new postgres database docker container
function create_docker_container {
echo "Creating new PostgreSQL database docker container..." | print_info
mkdir -p "${BASE_DIR}/.postgres"
# Run new container
docker run -d --name "${DOCKER_CONTAINER_NAME}" -e "POSTGRES_USER=integreat" -e "POSTGRES_PASSWORD=password" -e "POSTGRES_DB=integreat" -v "${BASE_DIR}/.postgres:/var/lib/postgresql" -p 5433:5432 postgres > /dev/null
wait_for_docker_container
Expand Down
6 changes: 6 additions & 0 deletions example-configs/integreat-cms.ini
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,12 @@ SUMM_AI_EASY_GERMAN_LANGUAGE_SLUG = "de-si"
#: The separator which is used to split compound words [optional, defaults to "hyphen", must be one of ["hyphen", "interpunct"]
SUMM_AI_SEPARATOR = "hyphen"

[textlab]
# If you want to get the hix score for your texts, set your API key here [optional, defaults to None]
TEXTLAB_API_KEY = <your-textlab-api-key>
# Username for the textlab api [optional, defaults to "Integreat"]
TEXTLAB_API_USERNAME = <your-textlab-api-username>

[xliff]
# Which XLIFF version to use for export [optional, defaults to "xliff-1.2"]
XLIFF_EXPORT_VERSION = xliff-1.2
2 changes: 2 additions & 0 deletions integreat_cms/api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
push_page_translation_content,
)
from .v3.pdf_export import pdf_export
from .v3.location_categories import location_categories
from .v3.push_notifications import sent_push_notifications
from .v3.regions import regions, liveregions, hiddenregions
from .v3.offers import offers
Expand All @@ -39,6 +40,7 @@
content_api_urlpatterns = [
path("pages/", pages, name="pages"),
path("locations/", locations, name="locations"),
path("location-categories/", location_categories, name="location_categories"),
path("events/", events, name="events"),
path("page/", single_page, name="single_page"),
path("post/", single_page, name="single_page"),
Expand Down
61 changes: 61 additions & 0 deletions integreat_cms/api/v3/location_categories.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
"""
This module includes the POI category API endpoint.
"""
from django.http import JsonResponse

from ...cms.models import POICategory
from ..decorators import json_response


def transform_location_category(location_category, language_slug):
"""
Function to create a JSON from a single location category object.
:param location_category: The location category object which should be converted
:type location_category: ~integreat_cms.cms.models.poi_categories.poi_category.POICategory
:param language_slug: The slug of the requested language
:type language_slug: str
:return: Data necessary for API
:rtype: dict
"""
if not location_category:
return None
category_translation = location_category.get_translation(language_slug)
return {
"id": location_category.id,
"name": category_translation.name
if category_translation
else location_category.name,
}


@json_response
# pylint: disable=unused-argument
def location_categories(request, region_slug, language_slug):
"""
Function to return all POI categories as JSON.
:param request: The current request
:type request: ~django.http.HttpRequest
:param region_slug: The slug of the requested region
:type region_slug: str
:param language_slug: The slug of the requested language
:type language_slug: str
:return: JSON object of all POI categories
:rtype: ~django.http.JsonResponse
"""
region = request.region
# Throw a 404 error when the language does not exist or is disabled
region.get_language_or_404(language_slug, only_active=True)
result = [
transform_location_category(location_category, language_slug)
for location_category in POICategory.objects.all()
]
return JsonResponse(
result, safe=False
) # Turn off Safe-Mode to allow serializing arrays
5 changes: 5 additions & 0 deletions integreat_cms/api/v3/locations.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
from django.conf import settings
from django.http import JsonResponse
from django.utils import timezone

from ..decorators import json_response
from .location_categories import transform_location_category


def transform_poi(poi):
Expand Down Expand Up @@ -72,6 +74,9 @@ def transform_poi_translation(poi_translation):
"website": poi.website if poi.website else None,
"email": poi.email if poi.email else None,
"phone_number": poi.phone_number if poi.phone_number else None,
"category": transform_location_category(
poi.category, poi_translation.language.slug
),
"location": transform_poi(poi),
"hash": None,
}
Expand Down
4 changes: 2 additions & 2 deletions integreat_cms/api/v3/push_notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ def transform_notification(pnt):
"""
return {
"id": str(pnt.pk),
"title": pnt.title,
"message": pnt.text,
"title": pnt.get_title(),
"message": pnt.get_text(),
"timestamp": pnt.last_updated, # deprecated field in the future
"last_updated": timezone.localtime(pnt.last_updated),
"channel": pnt.push_notification.channel,
Expand Down
15 changes: 15 additions & 0 deletions integreat_cms/cms/apps.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import logging
import os
import sys

from django.apps import AppConfig
from django.contrib.auth.signals import (
Expand All @@ -21,13 +23,26 @@ class CmsConfig(AppConfig):
:type name: str
"""

#: The name of this app config
name = "integreat_cms.cms"

#: Whether the availability of external APIs should be checked
test_external_apis = False

# pylint: disable=unused-import,import-outside-toplevel
def ready(self):
# Implicitly connect a signal handlers decorated with @receiver.
from .signals import feedback_signals

# Determine whether the availability of external APIs should be checked
self.test_external_apis = (
# Either the dev server is started with the "runserver" command,
# but it's not the main process (to ignore autoreloads)
("runserver" in sys.argv and "RUN_MAIN" not in os.environ)
# or the prod server is started via wsgi
or "APACHE_PID_FILE" in os.environ
)


authlog = logging.getLogger("auth")

Expand Down
7 changes: 7 additions & 0 deletions integreat_cms/cms/constants/roles.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,19 @@
MANAGEMENT_PERMISSIONS = EDITOR_PERMISSIONS + [
"change_feedback",
"change_imprintpage",
"change_organization",
"change_pushnotification",
"change_user",
"change_chatmessage",
"delete_directory",
"delete_feedback",
"delete_mediafile",
"delete_organization",
"grant_page_permissions",
"send_push_notification",
"view_feedback",
"view_imprintpage",
"view_organization",
"view_pushnotification",
"view_user",
]
Expand All @@ -101,6 +104,7 @@
"view_organization",
"view_page",
"view_poi",
"view_poicategory",
"view_pushnotification",
"view_region",
"view_user",
Expand Down Expand Up @@ -132,6 +136,7 @@
"change_languagetreenode",
"change_offertemplate",
"change_organization",
"change_poicategory",
"change_user",
"delete_chatmessage",
"delete_directory",
Expand All @@ -140,8 +145,10 @@
"delete_imprintpage",
"delete_languagetreenode",
"delete_offertemplate",
"delete_organization",
"delete_page",
"delete_poi",
"delete_poicategory",
"delete_pushnotification",
"delete_region",
"delete_user",
Expand Down
72 changes: 71 additions & 1 deletion integreat_cms/cms/fixtures/test_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -2660,7 +2660,8 @@
"country": "Deutschland",
"latitude": 1.0,
"longitude": 1.0,
"archived": false
"archived": false,
"category": 2
}
},
{
Expand Down Expand Up @@ -2779,6 +2780,75 @@
"creator": 1
}
},
{
"model": "cms.poicategory",
"pk": 1,
"fields": {}
},
{
"model": "cms.poicategory",
"pk": 2,
"fields": {}
},
{
"model": "cms.poicategory",
"pk": 3,
"fields": {}
},
{
"model": "cms.poicategorytranslation",
"pk": 1,
"fields": {
"category": 1,
"language": 1,
"name": "Beratungsstelle"
}
},
{
"model": "cms.poicategorytranslation",
"pk": 2,
"fields": {
"category": 1,
"language": 2,
"name": "Advice Center"
}
},
{
"model": "cms.poicategorytranslation",
"pk": 3,
"fields": {
"category": 2,
"language": 1,
"name": "Behörde/Amt"
}
},
{
"model": "cms.poicategorytranslation",
"pk": 4,
"fields": {
"category": 2,
"language": 2,
"name": "Authority/Office"
}
},
{
"model": "cms.poicategorytranslation",
"pk": 5,
"fields": {
"category": 3,
"language": 1,
"name": "Gastronomie"
}
},
{
"model": "cms.poicategorytranslation",
"pk": 6,
"fields": {
"category": 3,
"language": 2,
"name": "Gastronomy"
}
},
{
"model": "linkcheck.url",
"pk": 1,
Expand Down
5 changes: 5 additions & 0 deletions integreat_cms/cms/forms/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,8 @@
from .users.password_reset_form import CustomPasswordResetForm

from .object_search_form import ObjectSearchForm

from .poi_categories.poi_category_translation_form import (
POICategoryTranslationForm,
poi_category_translation_formset_factory,
)
4 changes: 2 additions & 2 deletions integreat_cms/cms/forms/media/replace_media_file_form.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import logging
import os
from datetime import datetime


import magic

from django import forms
from django.conf import settings
from django.utils import timezone
from django.utils.translation import ugettext as _

from ...constants import allowed_media
Expand Down Expand Up @@ -112,7 +112,7 @@ def clean(self):
# Add the calculated file_size to the form data
if cleaned_data.get("file"):
cleaned_data["file_size"] = cleaned_data.get("file").size
cleaned_data["last_modified"] = datetime.now()
cleaned_data["last_modified"] = timezone.now()

logger.debug(
"ReplaceMediaFileForm validated [2] with cleaned data %r", cleaned_data
Expand Down
Loading

0 comments on commit 93dd990

Please sign in to comment.