Skip to content

Commit 4b851bf

Browse files
authored
Merge pull request #3275 from digitalfabrik/develop
Release `2024.12.1`
2 parents 3df1ef2 + f00b63c commit 4b851bf

File tree

166 files changed

+554
-434
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

166 files changed

+554
-434
lines changed

docs/src/code-style.rst

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,13 @@ Run pylint with our developer tool :github-source:`tools/pylint.sh`::
5858

5959
./tools/pylint.sh
6060

61-
When you think a warning is a false positive, add a comment before the specific line::
61+
When you think a warning is a false positive, add a comment (see :doc:`pylint:user_guide/messages/message_control`)::
6262

63-
# pylint: disable=unused-argument
64-
def some_function(*args, **kwargs)
63+
def some_function(
64+
something: SomeModel, # pylint: disable=unused-argument
65+
*args,
66+
**kwargs) -> None:
67+
# pylint: disable=too-many-branches
6568

6669
.. Note::
6770

docs/src/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
"dateutil": ("https://dateutil.readthedocs.io/en/stable/", None),
7878
"geopy": ("https://geopy.readthedocs.io/en/stable/", None),
7979
"lxml": ("https://lxml.de/apidoc/", None),
80+
"pylint": ("https://pylint.readthedocs.io/en/latest/", None),
8081
"python": (
8182
f"https://docs.python.org/{sys.version_info.major}.{sys.version_info.minor}/",
8283
None,

integreat_cms/api/middleware/json_debug_toolbar_middleware.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
from django.http import HttpRequest
1818

1919

20-
# pylint: disable=too-few-public-methods
2120
class JsonDebugToolbarMiddleware:
21+
# pylint: disable=too-few-public-methods
2222
"""
2323
The Django Debug Toolbar usually only works for views that return HTML.
2424
This middleware wraps any JSON response in HTML if the request

integreat_cms/api/v3/chat/user_chat.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,10 @@ def send_message(
145145

146146
@csrf_exempt
147147
@json_response
148-
# pylint: disable=unused-argument
149148
def is_chat_enabled_for_user(
150-
request: HttpRequest, region_slug: str, device_id: str
149+
request: HttpRequest,
150+
region_slug: str, # pylint: disable=unused-argument
151+
device_id: str,
151152
) -> JsonResponse:
152153
"""
153154
Function to check if the chat feature is enabled for the given region and the given user.
@@ -173,10 +174,9 @@ def is_chat_enabled_for_user(
173174

174175
@csrf_exempt
175176
@json_response
176-
# pylint: disable=unused-argument
177177
def chat(
178178
request: HttpRequest,
179-
region_slug: str,
179+
region_slug: str, # pylint: disable=unused-argument
180180
language_slug: str,
181181
device_id: str,
182182
attachment_id: str = "",

integreat_cms/api/v3/chat/utils/chat_bot.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def automatic_answer(message: str, region: Region, language_slug: str) -> str |
4242
f"https://{settings.INTEGREAT_CHAT_BACK_END_DOMAIN}/chatanswers/extract_answer/"
4343
)
4444
body = {"message": message, "language": language_slug, "region": region.slug}
45-
r = requests.post(url, json=body, timeout=120)
45+
r = requests.post(url, json=body, timeout=settings.INTEGREAT_CHAT_BACK_END_TIMEOUT)
4646
return format_message(r.json())
4747

4848

@@ -58,7 +58,9 @@ def automatic_translation(
5858
"source_language": source_language_slug,
5959
"target_language": target_language_slug,
6060
}
61-
response = requests.post(url, json=body, timeout=120).json()
61+
response = requests.post(
62+
url, json=body, timeout=settings.INTEGREAT_CHAT_BACK_END_TIMEOUT
63+
).json()
6264
if "status" in response and response["status"] == "success":
6365
return response["translation"]
6466
raise ValueError("Did not receive success response for translation request.")

integreat_cms/api/v3/chat/utils/zammad_api.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@
2121
AUTO_ANSWER_STRING = "automatically generated message"
2222

2323

24-
# pylint: disable=unused-argument
25-
def _raise_or_return_json(self: Any, response: HttpResponse) -> dict:
24+
def _raise_or_return_json(
25+
self: Any, response: HttpResponse # pylint: disable=unused-argument
26+
) -> dict:
2627
"""
2728
Raise HTTPError before converting response to json
2829
@@ -37,8 +38,8 @@ def _raise_or_return_json(self: Any, response: HttpResponse) -> dict:
3738
return json_value
3839

3940

40-
# pylint: disable=too-many-instance-attributes
4141
class ZammadChatAPI:
42+
# pylint: disable=too-many-instance-attributes
4243
"""
4344
Class providing an API for Zammad used in the context of user chats.
4445
@@ -109,8 +110,8 @@ def _parse_response(self, response: dict | list[dict]) -> dict | list[dict]:
109110

110111
return {key: response[key] for key in keys_to_keep if key in response}
111112

112-
# pylint: disable=method-hidden
113113
def create_ticket(self, device_id: str, language_slug: str) -> dict:
114+
# pylint: disable=method-hidden
114115
"""
115116
Create a new ticket (i.e. initialize a new chat conversation)
116117
@@ -141,8 +142,8 @@ def _transform_attachment(
141142
)[0].random_hash,
142143
}
143144

144-
# pylint: disable=method-hidden
145145
def get_messages(self, chat: UserChat) -> dict[str, dict | list[dict]]:
146+
# pylint: disable=method-hidden
146147
"""
147148
Get all non-internal messages for a given ticket
148149
@@ -164,14 +165,14 @@ def get_messages(self, chat: UserChat) -> dict[str, dict | list[dict]]:
164165

165166
return {"messages": response}
166167

167-
# pylint: disable=method-hidden
168168
def send_message(
169169
self,
170170
chat_id: int,
171171
message: str,
172172
internal: bool = False,
173173
automatic_message: bool = False,
174174
) -> dict:
175+
# pylint: disable=method-hidden
175176
"""
176177
Post a new message to the given ticket
177178
@@ -198,8 +199,8 @@ def send_message(
198199
self._attempt_call(self.client.ticket_article.create, params=params)
199200
)
200201

201-
# pylint: disable=method-hidden
202202
def get_attachment(self, attachment_map: AttachmentMap) -> bytes | dict:
203+
# pylint: disable=method-hidden
203204
"""
204205
Get the (binary) attachment file from Zammad.
205206

integreat_cms/api/v3/events.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,11 @@ def transform_event_recurrences(
175175

176176

177177
@json_response
178-
# pylint: disable=unused-argument
179-
def events(request: HttpRequest, region_slug: str, language_slug: str) -> JsonResponse:
178+
def events(
179+
request: HttpRequest,
180+
region_slug: str, # pylint: disable=unused-argument
181+
language_slug: str,
182+
) -> JsonResponse:
180183
"""
181184
List all events of the region and transform result into JSON
182185

integreat_cms/api/v3/feedback/event_list_feedback.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@
1717

1818
@feedback_handler
1919
@json_response
20-
# pylint: disable=unused-argument
2120
def event_list_feedback(
22-
data: dict,
21+
data: dict, # pylint: disable=unused-argument
2322
region: Region,
2423
language: Language,
2524
comment: str,

integreat_cms/api/v3/feedback/imprint_page_feedback.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,8 @@ def imprint_page_feedback(
4444
)
4545

4646

47-
# pylint: disable=unused-argument
4847
def imprint_page_feedback_internal(
49-
data: dict,
48+
data: dict, # pylint: disable=unused-argument
5049
region: Region,
5150
language: Language,
5251
comment: str,

integreat_cms/api/v3/feedback/map_feedback.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@
1717

1818
@feedback_handler
1919
@json_response
20-
# pylint: disable=unused-argument
2120
def map_feedback(
22-
data: dict,
21+
data: dict, # pylint: disable=unused-argument
2322
region: Region,
2423
language: Language,
2524
comment: str,

integreat_cms/api/v3/feedback/offer_list_feedback.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@
1717

1818
@feedback_handler
1919
@json_response
20-
# pylint: disable=unused-argument
2120
def offer_list_feedback(
22-
data: dict,
21+
data: dict, # pylint: disable=unused-argument
2322
region: Region,
2423
language: Language,
2524
comment: str,

integreat_cms/api/v3/feedback/region_feedback.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@
1717

1818
@feedback_handler
1919
@json_response
20-
# pylint: disable=unused-argument
2120
def region_feedback(
22-
data: dict,
21+
data: dict, # pylint: disable=unused-argument
2322
region: Region,
2423
language: Language,
2524
comment: str,

integreat_cms/api/v3/imprint.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,11 @@ def transform_imprint(imprint_translation: ImprintPageTranslation) -> dict[str,
4949

5050

5151
@json_response
52-
# pylint: disable=unused-argument
53-
def imprint(request: HttpRequest, region_slug: str, language_slug: str) -> JsonResponse:
52+
def imprint(
53+
request: HttpRequest,
54+
region_slug: str, # pylint: disable=unused-argument
55+
language_slug: str,
56+
) -> JsonResponse:
5457
"""
5558
Get imprint for language and return JSON object to client. If no imprint translation
5659
is available in the selected language, try to return the translation in the region

integreat_cms/api/v3/languages.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@ def transform_language(language: Language) -> dict[str, Any]:
3636

3737

3838
@json_response
39-
# pylint: disable=unused-argument
40-
def languages(request: HttpRequest, region_slug: str) -> JsonResponse:
39+
def languages(
40+
request: HttpRequest, region_slug: str # pylint: disable=unused-argument
41+
) -> JsonResponse:
4142
"""
4243
Function to add all languages related to a region to a JSON.
4344

integreat_cms/api/v3/location_categories.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,10 @@ def transform_location_category(
5050

5151

5252
@json_response
53-
# pylint: disable=unused-argument
5453
def location_categories(
55-
request: HttpRequest, region_slug: str, language_slug: str
54+
request: HttpRequest,
55+
region_slug: str, # pylint: disable=unused-argument
56+
language_slug: str,
5657
) -> JsonResponse:
5758
"""
5859
Function to return all POI categories as JSON.

integreat_cms/api/v3/locations.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,10 @@ def transform_poi_translation(poi_translation: POITranslation) -> dict[str, Any]
115115

116116

117117
@json_response
118-
# pylint: disable=unused-argument
119118
def locations(
120-
request: HttpRequest, region_slug: str, language_slug: str
119+
request: HttpRequest,
120+
region_slug: str, # pylint: disable=unused-argument
121+
language_slug: str,
121122
) -> JsonResponse:
122123
"""
123124
List all POIs of the region and transform result into JSON

integreat_cms/api/v3/offers.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,10 @@ def transform_offer(offer: OfferTemplate, region: Region) -> dict[str, Any]:
7777

7878

7979
@json_response
80-
# pylint: disable=unused-argument
8180
def offers(
82-
request: HttpRequest, region_slug: str, language_slug: str | None = None
81+
request: HttpRequest,
82+
region_slug: str, # pylint: disable=unused-argument
83+
language_slug: str | None = None, # pylint: disable=unused-argument
8384
) -> JsonResponse:
8485
"""
8586
Function to iterate through all offers related to a region and adds them to a JSON.

integreat_cms/api/v3/pages.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,11 @@ def transform_page(page_translation: PageTranslation) -> dict[str, Any]:
112112

113113
@matomo_tracking
114114
@json_response
115-
# pylint: disable=unused-argument
116-
def pages(request: HttpRequest, region_slug: str, language_slug: str) -> JsonResponse:
115+
def pages(
116+
request: HttpRequest,
117+
region_slug: str, # pylint: disable=unused-argument
118+
language_slug: str,
119+
) -> JsonResponse:
117120
"""
118121
Function to iterate through all non-archived pages of a region and return them as JSON.
119122
@@ -205,9 +208,10 @@ def get_single_page(request: HttpRequest, language_slug: str) -> Page:
205208

206209

207210
@json_response
208-
# pylint: disable=unused-argument
209211
def single_page(
210-
request: HttpRequest, region_slug: str, language_slug: str
212+
request: HttpRequest,
213+
region_slug: str, # pylint: disable=unused-argument
214+
language_slug: str,
211215
) -> JsonResponse:
212216
"""
213217
View function returning the desired page as a JSON or a 404 if the
@@ -277,8 +281,11 @@ def children(
277281

278282

279283
@json_response
280-
# pylint: disable=unused-argument
281-
def parents(request: HttpRequest, region_slug: str, language_slug: str) -> JsonResponse:
284+
def parents(
285+
request: HttpRequest,
286+
region_slug: str, # pylint: disable=unused-argument
287+
language_slug: str,
288+
) -> JsonResponse:
282289
"""
283290
Retrieves all ancestors (parent and all nodes up to the root node) of a page.
284291
If any ancestor is archived, an 404 is raised.
@@ -326,10 +333,9 @@ def get_public_ancestor_translations(
326333

327334
@csrf_exempt
328335
@json_response
329-
# pylint: disable=unused-argument
330336
def push_page_translation_content(
331337
request: HttpRequest,
332-
region_slug: str,
338+
region_slug: str, # pylint: disable=unused-argument
333339
language_slug: str,
334340
) -> JsonResponse:
335341
"""

integreat_cms/api/v3/pdf_export.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@
2424

2525
@json_response
2626
@never_cache
27-
# pylint: disable=unused-argument
2827
def pdf_export(
29-
request: HttpRequest, region_slug: str, language_slug: str
28+
request: HttpRequest,
29+
region_slug: str, # pylint: disable=unused-argument
30+
language_slug: str,
3031
) -> HttpResponseRedirect:
3132
"""
3233
View function that either returns the requested page specified by the

integreat_cms/api/v3/regions.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,9 @@ def regions(_: HttpRequest) -> JsonResponse:
6969

7070

7171
@json_response
72-
# pylint: disable=unused-argument
73-
def region_by_slug(request: HttpRequest, region_slug: str) -> JsonResponse:
72+
def region_by_slug(
73+
request: HttpRequest, region_slug: str # pylint: disable=unused-argument
74+
) -> JsonResponse:
7475
"""
7576
Retrieve a single region and transform result into JSON
7677

0 commit comments

Comments
 (0)