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

Commit 1ab72be

Browse files
author
Søren Howe Gersager
committed
Merge branch 'release/3.2.4' into 'master'
Release/3.2.4 - master See merge request bevillingsplatform/bevillingsplatform!994
2 parents b2dd3bc + 5ff3fa3 commit 1ab72be

29 files changed

+650
-216
lines changed

.gitlab-ci.yml

Lines changed: 39 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -121,21 +121,22 @@ Build app image:
121121
.test-default: &test-default
122122
stage: test
123123
needs: ["Build app image"]
124+
dependencies: []
125+
126+
Unittest:
127+
<<: *test-default
128+
variables:
129+
DATABASE_NAME: bev
130+
DATABASE_USER: bev
131+
DATABASE_PASSWORD: bev
132+
BEV_USER_CONFIG_PATH: $CI_PROJECT_DIR/dev-environment/dev-settings.ini
133+
COVERAGE_FILE: $CI_PROJECT_DIR/.coverage
124134
image: ${IMAGE_SHA}
125135
tags:
126136
- docker
127137
services:
128-
- name: postgres:11
138+
- name: magentaaps/postgres-os2bos:1-10.14-test
129139
alias: db
130-
dependencies: []
131-
variables:
132-
POSTGRES_USER: bev
133-
POSTGRES_PASSWORD: bev
134-
BEV_USER_CONFIG_PATH: $CI_PROJECT_DIR/dev-environment/dev-settings.ini
135-
COVERAGE_FILE: $CI_PROJECT_DIR/.coverage
136-
137-
Unittest:
138-
<<: *test-default
139140
script:
140141
- cd /code/backend &&
141142
pytest
@@ -159,19 +160,23 @@ FrontendTest:
159160
<<: *test-default
160161
variables:
161162
FF_NETWORK_PER_BUILD: 1
162-
POSTGRES_USER: bev
163-
POSTGRES_PASSWORD: bev
164-
BEV_USER_CONFIG_PATH: $CI_PROJECT_DIR/dev-environment/frontend-tests-settings.ini
163+
DATABASE_NAME: bev
164+
DATABASE_USER: bev
165+
DATABASE_PASSWORD: bev
166+
BEV_USER_CONFIG_PATH: /code/dev-environment/ci-settings.ini
165167
SIMPLESAMLPHP_BASEURLPATH: http://idp:8080/simplesaml
166168
SIMPLESAMLPHP_SP_ENTITY_ID: http://bev:5000
167169
SIMPLESAMLPHP_SP_ASSERTION_CONSUMER_SERVICE: http://bev:5000/api/saml2_auth/acs/
168170
image: magentalabs/frontend-test:v0.2 #includes npm, chrome, firefox and ffmpeg
171+
tags:
172+
- docker
173+
- high-mem
169174
services:
170-
- name: postgres:11
175+
- name: magentaaps/postgres-os2bos:1-10.14-test
171176
alias: db
172177
- name: ${IMAGE_SHA}
173178
alias: bev
174-
- name: magentalabs/os2bos-idp-test:2.0.0
179+
- name: magentalabs/os2bos-idp-test:2.0.1
175180
alias: idp
176181
before_script:
177182
- cd frontend-tests
@@ -182,15 +187,13 @@ FrontendTest:
182187
when: always
183188
paths:
184189
- $CI_PROJECT_DIR/artifacts
185-
allow_failure: true
186190

187191
# Release stage
188192
###############
189193

190194
.release-default: &release-default
191195
stage: release
192-
needs: ['Unittest']
193-
#needs: ["Unittest", "FrontendTest"] require also frontendTest to pass
196+
needs: ["Unittest", "FrontendTest"]
194197
image: alpine
195198
variables:
196199
GIT_STRATEGY: none # We do not need the source code
@@ -280,7 +283,7 @@ Deploy test:
280283
Deploy dev:
281284
# Manuel deployment job to cburdev.magenta.dk
282285
<<: *deploy-default
283-
needs: ["Unittest"]
286+
needs: ["Unittest", "FrontendTest"]
284287
except:
285288
refs:
286289
- master
@@ -299,14 +302,27 @@ Deploy dev:
299302
name: dev
300303
url: https://cburdev.magenta.dk
301304

302-
.deploy-rc:
305+
306+
Deploy tag to staging:
303307
<<: *deploy-default
304308
needs: ["Release rc"]
309+
when: manual
305310
only:
306-
- /release/.*/
311+
variables:
312+
# Matches all of SemVer 2.0.0
313+
- $CI_COMMIT_TAG =~ /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/
314+
variables:
315+
DEPLOYMENT_NAMESPACE: cbur.ballerup.staging
316+
SALTAPI_URL: https://ctrl1.magenta-aps.dk/api/
317+
SALTAPI_EAUTH: file
318+
GIT_STRATEGY: none
319+
PILLAR_OVERRIDE: "{\"OS2BOS_APPLICATION_DOCKER_IMAGE\":\"${IMAGE}:${CI_COMMIT_TAG}\"}"
307320
script:
308-
- echo Deploying ${IMAGE_RC} to moratest.magneta.dk
309-
# TODO: push ${IMAGE_RC} to moratest.magneta.dk
321+
- echo Deploying ${IMAGE_TAG} to https://test-bevilling.balk.dk
322+
- pepper --client runner --fail-any state.orchestrate ${DEPLOYMENT_NAMESPACE} pillar=$(echo $PILLAR_OVERRIDE)
323+
environment:
324+
name: ballerup-staging
325+
url: https://test-bevilling.balk.dk
310326

311327

312328
.deploy-master:

CI/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
FROM magentalabs/simplesamlphp:2.0.0
1+
FROM magentalabs/simplesamlphp:2.0.1
22
COPY /dev-environment/authsources.php /var/www/simplesamlphp/config/authsources.php

NEWS.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
Version 3.2.4, 2020-11-24
2+
-------------------------
3+
4+
New in this version:
5+
6+
Bug fixes
7+
^^^^^^^^^
8+
9+
- Remove upper time limit for generated payment reports.
10+
- Fix calculation of earliest start date when creating an activity.
11+
- Remove redundant PRISM file generation so only one is generated.
12+
- Don't automatically mark fictive invoice payments as paid.
13+
- Add a warning on the supplementary activities when shortening a main activity.
14+
- Update various dependencies.
15+
16+
117
Version 3.2.3, 2020-11-16
218
-------------------------
319

README.rst

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -180,11 +180,11 @@ to connect them. It starts four services:
180180

181181
- `frontend`: the vue frontend reachable at http://localhost:8080
182182
- `bev`: the django backend
183-
- `db`: a `postgres database server`_
183+
- `db`: a OS2BOS specific `postgres database server`_
184184
- `postfix`: a `postfix email server`_
185185

186186
.. _postfix email server: https://hub.docker.com/r/catatnight/postfix
187-
.. _postgres database server: https://hub.docker.com/_/postgres
187+
.. _postgres database server: https://git.magenta.dk/bevillingsplatform/postgres-os2bos
188188

189189
Normally the backend image also serves the frontend code, but to ease frontend
190190
development, we include a frontend service that run `vue-cli-service serve
@@ -196,11 +196,11 @@ requests to the backend. The exact list of proxied endpoints can be seen in
196196
automatically restarts the server on changes to the backend files. This enables
197197
you to edit the backend files and the server will be reloaded automatically.
198198

199-
To pull the images and start the three service run:
199+
To pull the images and start the services run:
200200

201201
.. code-block:: bash
202202
203-
docker-compose up -d --build frontend
203+
docker-compose up -d --build
204204
205205
206206
The ``-d`` flag move the services to the background. You can inspect the output of
@@ -213,16 +213,6 @@ services, but the data will persist. To completely remove the containers and
213213
data run ``docker-compose down -v``.
214214

215215

216-
Postgres initialisation
217-
^^^^^^^^^^^^^^^^^^^^^^^
218-
219-
The ``docker-compose.yml`` file contains a service named ``bev-cp``. Its purpose
220-
is to copy the files needed to initialize the database and database user to a
221-
volume. This volume can then be mounted to the postgres image to automatically
222-
initialize the database. This functionality is not needed by default because the
223-
needed files are mounted directly from the host. It is included as an example
224-
when you want to use an environment closer to production.
225-
226216
Tests and shell access
227217
======================
228218

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.2.3
1+
3.2.4

backend/bevillingsplatform/settings.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -305,15 +305,13 @@
305305
fallback=os.path.join(LOG_DIR, "generate_payments_report.log"),
306306
),
307307
},
308-
"mark_fictive_payments_paid": {
308+
"mark_payments_paid": {
309309
"level": "INFO",
310310
"class": "logging.FileHandler",
311311
"formatter": "verbose",
312312
"filename": settings.get(
313313
"FICTIVE_PAYMENTS_LOG_FILE",
314-
fallback=os.path.join(
315-
LOG_DIR, "mark_fictive_payments_paid.log"
316-
),
314+
fallback=os.path.join(LOG_DIR, "mark_payments_paid.log"),
317315
),
318316
},
319317
"send_expired_emails": {
@@ -383,8 +381,8 @@
383381
"level": "INFO",
384382
"propagate": True,
385383
},
386-
"bevillingsplatform.mark_fictive_payments_paid": {
387-
"handlers": ["mark_fictive_payments_paid"],
384+
"bevillingsplatform.mark_payments_paid": {
385+
"handlers": ["mark_payments_paid"],
388386
"level": "INFO",
389387
"propagate": True,
390388
},

backend/core/management/commands/mark_fictive_payments_paid.py renamed to backend/core/management/commands/mark_payments_paid.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,25 @@
1212

1313
from django.db import transaction
1414
from django.core.management.base import BaseCommand
15-
from core.models import Payment, STATUS_GRANTED, SD
15+
from core.models import Payment, STATUS_GRANTED, SD, CASH, PaymentSchedule
1616

17-
logger = logging.getLogger("bevillingsplatform.mark_fictive_payments_paid")
17+
logger = logging.getLogger("bevillingsplatform.mark_payments_paid")
1818

1919

2020
class Command(BaseCommand):
21-
help = "Marks fictive payments paid on the given date."
21+
help = "Marks payments paid on the given date."
2222

2323
def add_arguments(self, parser):
2424
parser.add_argument(
2525
"-d",
2626
"--date",
27-
help=("Mark payments fictive for date"),
27+
help=("Mark payments for date"),
2828
default=None,
2929
)
3030

3131
@transaction.atomic
3232
def handle(self, *args, **options):
33-
"""Mark fictive payments paid for the given date."""
33+
"""Mark payments paid for the given date."""
3434
date = options["date"]
3535
if date is not None:
3636
try:
@@ -45,19 +45,22 @@ def handle(self, *args, **options):
4545
date = datetime.now().date()
4646

4747
try:
48-
fictive_payments = Payment.objects.filter(
48+
# Filter cash payments except for PERSON payments as
49+
# those are handled by the PRISM export management command.
50+
non_person_cash_payments = Payment.objects.filter(
4951
date=date,
50-
payment_schedule__fictive=True,
52+
payment_method=CASH,
5153
paid=False,
5254
payment_schedule__activity__status=STATUS_GRANTED,
53-
)
55+
).exclude(recipient_type=PaymentSchedule.PERSON)
56+
5457
sd_payments = Payment.objects.filter(
5558
date=date,
5659
payment_schedule__payment_method=SD,
5760
paid=False,
5861
payment_schedule__activity__status=STATUS_GRANTED,
5962
)
60-
payments = list(fictive_payments) + list(sd_payments)
63+
payments = list(non_person_cash_payments) + list(sd_payments)
6164
payment_ids = [payment.id for payment in payments]
6265
for payment in payments:
6366
print(payment)
@@ -71,5 +74,5 @@ def handle(self, *args, **options):
7174
)
7275
except Exception:
7376
logger.exception(
74-
"An exception occurred during marking payments fictive."
77+
"An exception occurred during marking payments paid."
7578
)
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
from django.db import migrations, models
2+
from django.db.models import Q
3+
4+
def mark_fictive_internal_and_invoice_payments_not_paid(apps, schema_editor):
5+
Payment = apps.get_model("core", "Payment")
6+
7+
payments = Payment.objects.filter(
8+
Q(payment_method="INVOICE")|Q(payment_method="INTERNAL"),
9+
payment_schedule__fictive=True,
10+
paid=True,
11+
)
12+
13+
for payment in payments:
14+
print(f"Marking payment with id: {payment.id} not paid")
15+
payment.paid = False
16+
payment.paid_date = None
17+
payment.paid_amount = None
18+
payment.save()
19+
20+
21+
class Migration(migrations.Migration):
22+
23+
dependencies = [
24+
('core', '0086_auto_20200918_1106'),
25+
]
26+
27+
operations = [migrations.RunPython(mark_fictive_internal_and_invoice_payments_not_paid)]

backend/core/models.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2103,7 +2103,7 @@ def save(self, *args, **kwargs):
21032103
def is_valid_activity_start_date(self):
21042104
"""Determine if a date is valid for a activity start_date."""
21052105
# A start_date is valid for cash activities if at least two
2106-
# consecutive days without payment date exclusions exist between
2106+
# days without payment date exclusions exist between
21072107
# today and the start_date.
21082108
if (
21092109
self.payment_plan.payment_method == CASH
@@ -2130,14 +2130,12 @@ def is_valid_activity_start_date(self):
21302130
)
21312131
]
21322132

2133-
consecutive_days = 0
2133+
days_without_exclusions = 0
21342134
for day_date in tomorrow_to_start_date_in_days:
2135-
if exclusions.filter(date=day_date).exists():
2136-
consecutive_days = 0
2137-
else:
2138-
consecutive_days += 1
2135+
if not exclusions.filter(date=day_date).exists():
2136+
days_without_exclusions += 1
21392137

2140-
if consecutive_days == 2:
2138+
if days_without_exclusions == 2:
21412139
return True
21422140

21432141
return False

backend/core/serializers.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@ class PaymentSerializer(serializers.ModelSerializer):
158158
case__cpr_number = serializers.ReadOnlyField(
159159
source="payment_schedule.activity.appropriation.case.cpr_number"
160160
)
161+
case__name = serializers.ReadOnlyField(
162+
source="payment_schedule.activity.appropriation.case.name"
163+
)
161164
activity__id = serializers.ReadOnlyField(
162165
source="payment_schedule.activity.id"
163166
)
@@ -575,7 +578,7 @@ def validate(self, data):
575578
raise serializers.ValidationError(
576579
_(
577580
"Startdato skal være i fremtiden og "
578-
"der skal være mindst to udbetalingsdage i række"
581+
"der skal være mindst to udbetalingsdage"
579582
" fra nu og til startdatoen"
580583
)
581584
)

0 commit comments

Comments
 (0)