Skip to content

Commit f9231dd

Browse files
authored
Merge pull request watchdogpolska#2256 from watchdogpolska/develop
v1.5.50 fixes and upgrades
2 parents c221d29 + 5854fb1 commit f9231dd

28 files changed

+325
-166
lines changed

.github/workflows/frontend.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
regenerate_frontend:
1414
runs-on: ubuntu-latest
1515
steps:
16-
- uses: actions/checkout@v4
16+
- uses: actions/checkout@v5
1717
- name: Collect statics
1818
run: docker compose run web python manage.py collectstatic --noinput
1919
- name: Build and run frontend

.github/workflows/web.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
# # - "==2.2.*"
2020
# - "==4.2"
2121
steps:
22-
- uses: actions/checkout@v4
22+
- uses: actions/checkout@v5
2323
with:
2424
lfs: true
2525
- name: Build application

.github/workflows/web_image_buil_and_push.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
if: github.event.pull_request.merged == true && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/develop')
1313
steps:
1414
- name: Checkout
15-
uses: actions/checkout@v4
15+
uses: actions/checkout@v5
1616

1717
- name: Get version from script
1818
id: get_version

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ default_language_version:
1717
minimum_pre_commit_version: "1.20.0"
1818
repos:
1919
- repo: https://github.com/adamchainz/django-upgrade
20-
rev: 1.25.0
20+
rev: 1.28.0
2121
hooks:
2222
- id: django-upgrade
2323
args: [--target-version, "4.2"]
@@ -39,7 +39,7 @@ repos:
3939
- --skip-glob
4040
- "**/migrations/*.py"
4141
- repo: https://github.com/sirosen/check-jsonschema
42-
rev: 0.33.2
42+
rev: 0.34.0
4343
hooks:
4444
- id: check-github-workflows
4545
- id: check-readthedocs
@@ -50,7 +50,7 @@ repos:
5050
args: [-c, .yamllint.yml]
5151
# exclude: (feder/letters/logs/cassettes/.*|docker-compose.yml)
5252
- repo: https://github.com/psf/black
53-
rev: 25.1.0
53+
rev: 25.9.0
5454
hooks:
5555
- id: black
5656
args:

config/settings/common.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
)
3838
THIRD_PARTY_APPS = (
3939
"crispy_forms", # Form layouts
40+
"crispy_bootstrap3", # Bootstrap 3 theme for crispy forms
4041
"allauth", # registration
4142
"allauth.account", # registration
4243
"allauth.socialaccount", # registration
@@ -230,7 +231,11 @@
230231
]
231232

232233
# See: http://django-crispy-forms.readthedocs.org/en/latest/install.html#template-packs
234+
CRISPY_ALLOWED_TEMPLATE_PACKS = [
235+
"bootstrap3",
236+
]
233237
CRISPY_TEMPLATE_PACK = "bootstrap3"
238+
CRISPY_FAIL_SILENTLY = False
234239

235240
# STATIC FILE CONFIGURATION
236241
# ------------------------------------------------------------------------------
@@ -273,16 +278,16 @@
273278
)
274279

275280
# Some really nice defaults
276-
ACCOUNT_AUTHENTICATION_METHOD = "username_email"
277-
ACCOUNT_EMAIL_REQUIRED = True
281+
ACCOUNT_LOGIN_METHODS = {"email", "username"}
282+
ACCOUNT_SIGNUP_FIELDS = ["email*", "username*", "password1*", "password2*"]
278283
ACCOUNT_EMAIL_VERIFICATION = "mandatory"
279284
# NoSignupAdapter disables the signup functionality - new users to be
280285
# manually added by admins
281286
ACCOUNT_ADAPTER = "feder.main.adapters.NoSignupAdapter"
282287
SOCIALACCOUNT_EMAIL_VERIFICATION = "optional"
283288
SOCIALACCOUNT_PROVIDERS = {
284289
"github": {"SCOPE": ["user"]},
285-
"gilab": {"SCOPE": ["read_user", "openid"]},
290+
"gitlab": {"SCOPE": ["read_user", "openid"]},
286291
}
287292
# Custom user app defaults
288293
# Select the correct user model

feder/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# PEP 396: The __version__ attribute's value SHOULD be a string.
2-
__version__ = "1.5.48"
2+
__version__ = "1.5.50"
33

44

55
# Compatibility to eg. django-rest-framework

feder/letters/forms.py

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
from django import forms
66
from django.conf import settings
77
from django.contrib import messages
8+
from django.contrib.admin.models import ADDITION, CHANGE, LogEntry
9+
from django.contrib.contenttypes.models import ContentType
810
from django.template.loader import render_to_string
11+
from django.utils.encoding import force_str
912
from django.utils.safestring import mark_safe
1013
from django.utils.translation import gettext_lazy as _
1114
from tinymce.widgets import TinyMCE
@@ -103,6 +106,19 @@ def save(self, *args, **kwargs):
103106
):
104107
self.instance.author_user = self.user
105108
if not self.instance.is_mass_draft() and "ai_evaluation" in self.changed_data:
109+
change_dict = {
110+
"changed": self.changed_data,
111+
"ai_evaluation_previous": self.initial.get("ai_evaluation", None),
112+
"ai_evaluation_new": self.cleaned_data.get("ai_evaluation", None),
113+
}
114+
LogEntry.objects.log_action(
115+
user_id=self.request.user.id,
116+
content_type_id=ContentType.objects.get_for_model(self.instance).pk,
117+
object_id=self.instance.pk,
118+
object_repr=force_str(self.instance),
119+
action_flag=CHANGE,
120+
change_message=f"{change_dict}",
121+
)
106122
update_letter_normalized_answers(self.instance.pk)
107123
messages.success(
108124
self.request,
@@ -119,6 +135,22 @@ def save(self, *args, **kwargs):
119135
case=self.cleaned_data["case"]
120136
)
121137
self.instance.record.save()
138+
change_dict = {
139+
"changed": self.changed_data,
140+
"new_case": self.cleaned_data["case"].pk,
141+
"previous_case": self.initial["case"].pk,
142+
"letter": self.instance.pk,
143+
}
144+
LogEntry.objects.log_action(
145+
user_id=self.request.user.id,
146+
content_type_id=ContentType.objects.get_for_model(
147+
self.instance.record
148+
).pk,
149+
object_id=self.instance.record.pk,
150+
object_repr=force_str(self.instance.record),
151+
action_flag=CHANGE,
152+
change_message=f"{change_dict}",
153+
)
122154
if "ai_evaluation" not in self.changed_data:
123155
categorize_letter_in_background(self.instance.pk)
124156
messages.success(
@@ -130,6 +162,21 @@ def save(self, *args, **kwargs):
130162
)
131163
if not hasattr(self.instance, "record"):
132164
self.instance.record = Record.objects.create(case=self.cleaned_data["case"])
165+
change_dict = {
166+
"changed": self.changed_data,
167+
"new_case": self.cleaned_data["case"].pk,
168+
"letter": self.instance.pk,
169+
}
170+
LogEntry.objects.log_action(
171+
user_id=self.request.user.id,
172+
content_type_id=ContentType.objects.get_for_model(
173+
self.instance.record
174+
).pk,
175+
object_id=self.instance.record.pk,
176+
object_repr=force_str(self.instance.record),
177+
action_flag=ADDITION,
178+
change_message=f"{change_dict}",
179+
)
133180
self.instance.save()
134181
return super().save(*args, **kwargs)
135182

@@ -278,6 +325,20 @@ def save(self):
278325
self.letter.case = self.cleaned_data["case"]
279326
self.letter.record.save()
280327
self.letter.case.save()
328+
chang_dict = {
329+
"changed": ["case"],
330+
"new_case": self.cleaned_data["case"].pk,
331+
"previous_case": None,
332+
"letter": self.letter.pk,
333+
}
334+
LogEntry.objects.log_action(
335+
user_id=self.request.user.id,
336+
content_type_id=ContentType.objects.get_for_model(self.letter.record).pk,
337+
object_id=self.letter.record.pk,
338+
object_repr=force_str(self.letter.record),
339+
action_flag=CHANGE,
340+
change_message=f"{chang_dict}",
341+
)
281342
categorize_letter_in_background(self.letter.pk)
282343
messages.success(
283344
self.request,

feder/letters/formsets.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
from atom.ext.crispy_forms.forms import BaseTableFormSet
21
from extra_views import InlineFormSetFactory
32

43
from feder.letters.models import Attachment
4+
from feder.main.forms import BaseTableFormSetB3
55

66

77
class AttachmentInline(InlineFormSetFactory):
88
model = Attachment
9-
formset_class = BaseTableFormSet
9+
formset_class = BaseTableFormSetB3
1010
fields = ["attachment"]

feder/letters/views.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
BaseXSendFileView,
4949
RaisePermissionRequiredMixin,
5050
)
51+
from feder.main.utils import DeleteViewLogEntryMixin
5152
from feder.monitorings.models import Monitoring
5253
from feder.monitorings.tasks import send_mass_draft
5354
from feder.records.models import Record
@@ -328,7 +329,11 @@ def get_form_kwargs(self):
328329

329330

330331
class LetterDeleteView(
331-
LetterCommonMixin, AttrPermissionRequiredMixin, DeleteMessageMixin, DeleteView
332+
LetterCommonMixin,
333+
AttrPermissionRequiredMixin,
334+
DeleteMessageMixin,
335+
DeleteViewLogEntryMixin,
336+
DeleteView,
332337
):
333338
model = Letter
334339
permission_required = "monitorings.delete_letter"
@@ -597,7 +602,10 @@ def update_object_list(self, object_list):
597602

598603

599604
class AssignLetterFormView(
600-
PrefetchRelatedMixin, RaisePermissionRequiredMixin, SuccessMessageMixin, FormView
605+
PrefetchRelatedMixin,
606+
RaisePermissionRequiredMixin,
607+
SuccessMessageMixin,
608+
FormView,
601609
):
602610
model = Letter
603611
form_class = AssignLetterForm

feder/main/forms.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from crispy_forms.helper import FormHelper
2+
from django.forms.models import BaseInlineFormSet
3+
4+
5+
class BaseTableFormSetB3(BaseInlineFormSet):
6+
def __init__(self, *args, **kwargs):
7+
super().__init__(*args, **kwargs)
8+
h = FormHelper()
9+
h.template_pack = "bootstrap3"
10+
h.template = "bootstrap3/table_inline_formset.html"
11+
h.form_tag = False # outer <form> is in the page template
12+
self.helper = h

0 commit comments

Comments
 (0)