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

Commit 2e5802c

Browse files
author
Søren Howe Gersager
committed
Merge branch 'release/3.3.0' into 'master'
Release/3.3.0 - master See merge request bevillingsplatform/bevillingsplatform!1028
2 parents 4a48fae + b8498f5 commit 2e5802c

Some content is hidden

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

72 files changed

+3603
-1710
lines changed

.gitlab-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ FrontendTest:
182182
- cd frontend-tests
183183
- npm install
184184
script:
185-
- ./node_modules/.bin/testcafe chrome:headless tests/*.js --baseurl http://bev:5000/ --screenshot $CI_PROJECT_DIR/artifacts --video $CI_PROJECT_DIR/artifacts
185+
- ./node_modules/.bin/testcafe chrome:headless tests/*.js --baseurl http://bev:5000 --screenshot $CI_PROJECT_DIR/artifacts --video $CI_PROJECT_DIR/artifacts --assertion-timeout 15000 --selector-timeout 15000
186186
artifacts:
187187
when: always
188188
paths:

NEWS.rst

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,31 @@
1+
Version 3.3.0, 2020-12-17
2+
-------------------------
3+
4+
New in this version:
5+
6+
Features
7+
^^^^^^^^
8+
9+
- Add redirect after SSO login.
10+
- Save filters across page transitions.
11+
- Save filters in URL to make them bookmarkable.
12+
- Change "reset" functionality of overview pages.
13+
- Remove unneeded Team on Case and instead display and filter on Team of the case worker.
14+
- Validate CVR number for recipient_id on PaymentSchedule when recipient is "Firma".
15+
- Add generic time intervals for payments (previous, current, next - week, month, year).
16+
- Added fields to payments report.
17+
- Changed the flow of emails when manipulating activities.
18+
- Add child name to CPR number of Payments overview.
19+
- Add Users and Teams to workflow users Admin page.
20+
- Update third party dependencies.
21+
22+
Bug fixes
23+
^^^^^^^^^
24+
25+
- Fix a bug where updating a payment caused a PATCH twice.
26+
- Various fixes to frontend tests.
27+
28+
129
Version 3.2.5, 2020-12-02
230
-------------------------
331

README.rst

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
======
2+
OS2BOS
3+
======
4+
15
|pipeline status|
26
|coverage report|
37

@@ -119,7 +123,7 @@ We log the following:
119123

120124
* Export to Prism log - Log related to the PRISM exports management command. The log is written to ``/log/export_to_prism.log``.
121125

122-
* Mark Fictive Payments Paid log - Log related to the marking fictive payments paid management command. The log is written to ``mark_fictive_payments_paid.log``.
126+
* Mark Payments Paid log - Log related to the marking payments paid management command. The log is written to ``mark_payments_paid.log``.
123127

124128
* Generate Payments Report log - Log related to generating the payment reports. The log is written to ``/log/generate_payments_report.log``.
125129

@@ -173,18 +177,22 @@ Docker-compose
173177
--------------
174178

175179
You can use ``docker-compose`` to start up bevillingsplatform and related
176-
service such as postgres and postfix.
180+
services such as postgres and postfix.
177181

178182
A ``docker-compose.yml`` for development is included. It includes the settings
179-
to connect them. It starts four services:
183+
to connect them. It starts the following services:
180184

181185
- `frontend`: the vue frontend reachable at http://localhost:8080
182186
- `bev`: the django backend
183187
- `db`: a OS2BOS specific `postgres database server`_
188+
- `bev-cron`: `supercronic`_, a job runner running our cronjobs
189+
- `idp`: a local version of the IdP running our version of `SimpleSAMLphp`_
184190
- `postfix`: a `postfix email server`_
185191

186192
.. _postfix email server: https://hub.docker.com/r/catatnight/postfix
187193
.. _postgres database server: https://git.magenta.dk/bevillingsplatform/postgres-os2bos
194+
.. _supercronic: https://github.com/aptible/supercronic
195+
.. _SimpleSAMLphp: https://simplesamlphp.org/
188196

189197
Normally the backend image also serves the frontend code, but to ease frontend
190198
development, we include a frontend service that run `vue-cli-service serve

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.2.5
1+
3.3.0

backend/bevillingsplatform/settings.py

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,16 @@
354354
fallback=os.path.join(LOG_DIR, "serviceplatformen.log"),
355355
),
356356
},
357+
# handler for the django-mailer package.
358+
"mailer": {
359+
"level": "INFO",
360+
"class": "logging.FileHandler",
361+
"formatter": "verbose",
362+
"filename": settings.get(
363+
"MAILER_LOG_FILE",
364+
fallback=os.path.join(LOG_DIR, "cron_mail.log"),
365+
),
366+
},
357367
},
358368
"formatters": {
359369
"verbose": {
@@ -406,6 +416,12 @@
406416
"level": "INFO",
407417
"propagate": True,
408418
},
419+
# logger for the django-mailer package.
420+
"mailer": {
421+
"handlers": ["mailer"],
422+
"level": "INFO",
423+
"propagate": True,
424+
},
409425
},
410426
}
411427

@@ -501,7 +517,7 @@
501517
"BEFORE_LOGIN": "core.utils.saml_before_login",
502518
},
503519
"USE_JWT": True,
504-
"FRONTEND_URL": settings.get("SAML_PUBLIC_HOST") + "#/",
520+
"FRONTEND_URL": settings.get("SAML_PUBLIC_HOST") + "#",
505521
"CERT_FILE": settings.get("CERT_FILE", fallback=""),
506522
"KEY_FILE": settings.get("KEY_FILE", fallback=""),
507523
"AUTHN_REQUESTS_SIGNED": settings.getboolean(
@@ -511,6 +527,20 @@
511527

512528
SILENCED_SYSTEM_CHECKS = ["rest_framework.W001"]
513529

530+
# Settings for manage.py graph_models from django-extensions.
531+
GRAPH_MODELS = {
532+
"exclude_models": [
533+
"AbstractUser",
534+
"AuditModelMixin",
535+
"SectionEffortStepProxy",
536+
"ActivityDetailsSectionProxy",
537+
"HistoricalRatePerDateProxy",
538+
"HistoricalRatePerDate",
539+
"HistoricalPayment",
540+
"HistoricalCase",
541+
]
542+
}
543+
514544
ALLOW_EDIT_OF_PAST_PAYMENTS = settings.getboolean(
515545
"ALLOW_EDIT_OF_PAST_PAYMENTS", fallback=False
516546
)
@@ -520,3 +550,7 @@
520550
"watchman.checks.databases",
521551
# disable storage check since fileupload is not used.
522552
)
553+
554+
# Prometheus logging.
555+
LOG_TO_PROMETHEUS = settings.getboolean("LOG_TO_PROMETHEUS", fallback=False)
556+
PROMETHEUS_HOST = settings.get("PROMETHEUS_HOST", fallback="localhost:9091")

backend/core/admin.py

Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,6 @@
5252
HistoricalRatePerDateProxy,
5353
)
5454

55-
for klass in (PaymentMethodDetails, Team):
56-
admin.site.register(klass, admin.ModelAdmin)
57-
58-
5955
User = get_user_model()
6056

6157

@@ -262,7 +258,7 @@ class PriceAdmin(VariableRateAdmin):
262258

263259
@admin.register(Payment)
264260
class PaymentAdmin(SimpleHistoryAdmin):
265-
"""Dislay read only fields on payment."""
261+
"""ModelAdmin for Payment."""
266262

267263
readonly_fields = ("payment_id", "account_string", "account_alias")
268264
search_fields = ("payment_schedule__payment_id",)
@@ -413,6 +409,20 @@ def account_alias(self, obj):
413409
account_alias.short_description = _("kontoalias")
414410

415411

412+
@admin.register(PaymentMethodDetails)
413+
class PaymentMethodDetails(admin.ModelAdmin):
414+
"""ModelAdmin for PaymentMethodDetails."""
415+
416+
pass
417+
418+
419+
@admin.register(Team)
420+
class TeamAdmin(ClassificationAdmin):
421+
"""ModelAdmin for Team."""
422+
423+
pass
424+
425+
416426
@admin.register(User)
417427
class CustomUserAdmin(BaseUserAdmin):
418428
"""Add team to user admin interface."""
@@ -421,6 +431,31 @@ class CustomUserAdmin(BaseUserAdmin):
421431
("Organisation", {"fields": ("team",)}),
422432
) + BaseUserAdmin.fieldsets
423433

434+
def has_view_permission(self, request, obj=None):
435+
"""Override has_view_permission for ModelAdmin."""
436+
user = request.user
437+
return user.is_authenticated and user.is_workflow_engine_or_admin()
438+
439+
def has_add_permission(self, request):
440+
"""Override has_add_permission for ModelAdmin."""
441+
user = request.user
442+
return user.is_authenticated and user.is_workflow_engine_or_admin()
443+
444+
def has_change_permission(self, request, obj=None):
445+
"""Override has_change_permission for ModelAdmin."""
446+
user = request.user
447+
return user.is_authenticated and user.is_workflow_engine_or_admin()
448+
449+
def has_delete_permission(self, request, obj=None):
450+
"""Override has_delete_permission for ModelAdmin."""
451+
user = request.user
452+
return user.is_authenticated and user.is_workflow_engine_or_admin()
453+
454+
def has_module_permission(self, request):
455+
"""Override has_model_permission for ModelAdmin."""
456+
user = request.user
457+
return user.is_authenticated and user.is_workflow_engine_or_admin()
458+
424459

425460
class SectionInfoInline(ClassificationInline):
426461
"""SectionInfoInline for ActivityDetailsAdmin."""
@@ -634,6 +669,6 @@ class SectionInfoAdmin(ClassificationAdmin):
634669

635670
@admin.register(AccountAlias)
636671
class AccountAliasAdmin(ClassificationAdmin):
637-
"""ModelAdmin for SectionInfo."""
672+
"""ModelAdmin for AccountAlias."""
638673

639674
list_display = ("section_info", "activity_details", "alias")

backend/core/decorators.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Copyright (C) 2019 Magenta ApS, http://magenta.dk.
2+
# Contact: [email protected].
3+
#
4+
# This Source Code Form is subject to the terms of the Mozilla Public
5+
# License, v. 2.0. If a copy of the MPL was not distributed with this
6+
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
7+
"""Decorators used by other parts of this app."""
8+
from django.conf import settings
9+
10+
from prometheus_client import Gauge, CollectorRegistry, pushadd_to_gateway
11+
12+
13+
def log_to_prometheus(job_name):
14+
"""
15+
Log function metrics to prometheus.
16+
17+
for example @log_to_prometheus('send_expired_emails')
18+
"""
19+
20+
def decorator_log_to_prometheus(job_func):
21+
def wrapper_log_to_prometheus(*args, **kwargs):
22+
result = None
23+
if not settings.LOG_TO_PROMETHEUS:
24+
result = job_func(*args, **kwargs)
25+
else:
26+
registry = CollectorRegistry()
27+
duration = Gauge(
28+
f"os2bos_{job_name}_duration_seconds",
29+
f"Duration of {job_name}",
30+
registry=registry,
31+
)
32+
33+
try:
34+
with duration.time():
35+
result = job_func(*args, **kwargs)
36+
except Exception:
37+
pass
38+
else:
39+
# only runs when there are no exceptions
40+
last_success = Gauge(
41+
f"os2bos_{job_name}_last_success",
42+
f"Unixtime {job_name} last succeeded",
43+
registry=registry,
44+
)
45+
last_success.set_to_current_time()
46+
finally:
47+
pushadd_to_gateway(
48+
settings.PROMETHEUS_HOST,
49+
job=f"{job_name}",
50+
registry=registry,
51+
)
52+
return result
53+
54+
return wrapper_log_to_prometheus
55+
56+
return decorator_log_to_prometheus

0 commit comments

Comments
 (0)