Skip to content

Commit

Permalink
Merge pull request #381 from City-of-Turku/develop
Browse files Browse the repository at this point in the history
Release tku-v1.12

Notable changes:
- updated Django to version 4
- new vat and decimal support
- ability to save users' order of admin resources
- show login method of users in user management view
  • Loading branch information
SanttuA authored Aug 26, 2024
2 parents 22c2d93 + ccd835d commit 4063eb3
Show file tree
Hide file tree
Showing 60 changed files with 1,230 additions and 142 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/respa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: [ ubuntu-20.04 ]
services:
postgres:
image: postgis/postgis:11-2.5
image: postgis/postgis:14-3.4
env:
POSTGRES_USER: respa
POSTGRES_PASSWORD: respa
Expand Down
56 changes: 56 additions & 0 deletions accessibility/migrations/0004_missing_migrations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Generated by Django 4.2.13 on 2024-08-14 06:52

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('accessibility', '0003_django_3_update'),
]

operations = [
migrations.AlterField(
model_name='serviceentrance',
name='created_by',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='%(class)s_created', to=settings.AUTH_USER_MODEL, verbose_name='Created by'),
),
migrations.AlterField(
model_name='serviceentrance',
name='modified_by',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='%(class)s_modified', to=settings.AUTH_USER_MODEL, verbose_name='Modified by'),
),
migrations.AlterField(
model_name='servicerequirement',
name='created_by',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='%(class)s_created', to=settings.AUTH_USER_MODEL, verbose_name='Created by'),
),
migrations.AlterField(
model_name='servicerequirement',
name='modified_by',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='%(class)s_modified', to=settings.AUTH_USER_MODEL, verbose_name='Modified by'),
),
migrations.AlterField(
model_name='servicesentence',
name='created_by',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='%(class)s_created', to=settings.AUTH_USER_MODEL, verbose_name='Created by'),
),
migrations.AlterField(
model_name='servicesentence',
name='modified_by',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='%(class)s_modified', to=settings.AUTH_USER_MODEL, verbose_name='Modified by'),
),
migrations.AlterField(
model_name='serviceshortage',
name='created_by',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='%(class)s_created', to=settings.AUTH_USER_MODEL, verbose_name='Created by'),
),
migrations.AlterField(
model_name='serviceshortage',
name='modified_by',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='%(class)s_modified', to=settings.AUTH_USER_MODEL, verbose_name='Modified by'),
),
]
21 changes: 21 additions & 0 deletions comments/migrations/0004_missing_migrations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Generated by Django 4.2.13 on 2024-08-14 06:52

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('comments', '0003_refactor_content_type_choices'),
]

operations = [
migrations.AlterField(
model_name='comment',
name='created_by',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='%(class)s_created', to=settings.AUTH_USER_MODEL, verbose_name='Created by'),
),
]
35 changes: 27 additions & 8 deletions locale/en/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -2374,14 +2374,6 @@ msgstr ""
msgid "Change password: %s"
msgstr ""

#: users/models.py:11
msgid "First name"
msgstr ""

#: users/models.py:12
msgid "Last name"
msgstr ""

#: users/models.py:14
msgid "Birthdate"
msgstr ""
Expand Down Expand Up @@ -2913,3 +2905,30 @@ msgstr ""

msgid "The reservation deadline is the start time. For example, if the start time is 6:00 PM, same-day bookings must be made before 6:00 PM."
msgstr ""

msgid "Users"
msgstr ""

msgid "Login method"
msgstr ""

msgid "Login methods"
msgstr ""

msgid "Icon"
msgstr ""

msgid "Strong authentication"
msgstr ""

msgid "First name"
msgstr ""

msgid "Last name"
msgstr ""

msgid "Unknown login method"
msgstr ""

msgid "Upload SVG file or paste SVG code."
msgstr ""
30 changes: 27 additions & 3 deletions locale/fi/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -1725,9 +1725,6 @@ msgstr "Tarvitsee avustusta"
msgid "Require workstation"
msgstr "Tarvitsee työaseman"

msgid "Users"
msgstr "Käyttäjät"

msgid "Turku Users"
msgstr "Turku käyttäjät"

Expand Down Expand Up @@ -2298,3 +2295,30 @@ msgstr "Varauksen alkamisajan ja päättymisajan on vastattava annettuja yön yl

msgid "The reservation deadline is the start time. For example, if the start time is 6:00 PM, same-day bookings must be made before 6:00 PM."
msgstr "Varausten takaraja on aloitusaika. Esim. jos aloitusaika on klo 18.00, saman päivän varaus on tehtävä ennen klo 18.00."

msgid "Users"
msgstr "Käyttäjät"

msgid "Login method"
msgstr "Kirjautumistapa"

msgid "Login methods"
msgstr "Kirjautumistavat"

msgid "Icon"
msgstr "Kuvake"

msgid "Strong authentication"
msgstr "Vahva tunnistautuminen"

msgid "First name"
msgstr "Etunimi"

msgid "Last name"
msgstr "Sukunimi"

msgid "Unknown login method"
msgstr "Tuntematon kirjautumistapa"

msgid "Upload SVG file or paste SVG code."
msgstr "Lataa SVG-tiedosto tai liitä SVG-koodi."
24 changes: 24 additions & 0 deletions locale/sv/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -2239,3 +2239,27 @@ msgstr "Reservationsstart och reservationsslut måste överensstämma med de ang

msgid "The reservation deadline is the start time. For example, if the start time is 6:00 PM, same-day bookings must be made before 6:00 PM."
msgstr "Bokningsfristen är starttiden. Till exempel, om starttiden är 18.00, måste bokningar för samma dag göras före 18.00."

msgid "Users"
msgstr "Användare"

msgid "Login method"
msgstr "Inloggningsmetod"

msgid "Login methods"
msgstr "Inloggningsmetoder"

msgid "Icon"
msgstr "Ikon"

msgid "First name"
msgstr "Förnamn"

msgid "Last name"
msgstr "Efternamn"

msgid "Unknown login method"
msgstr "Okänd inloggningsmetod"

msgid "Upload SVG file or paste SVG code."
msgstr "Ladda upp SVG-fil eller klistra in SVG-kod."
36 changes: 36 additions & 0 deletions maintenance/migrations/0002_missing_migrations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Generated by Django 4.2.13 on 2024-08-14 06:52

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('maintenance', '0001_create_maintenance_app'),
]

operations = [
migrations.AlterField(
model_name='maintenancemessage',
name='created_by',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='%(class)s_created', to=settings.AUTH_USER_MODEL, verbose_name='Created by'),
),
migrations.AlterField(
model_name='maintenancemessage',
name='modified_by',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='%(class)s_modified', to=settings.AUTH_USER_MODEL, verbose_name='Modified by'),
),
migrations.AlterField(
model_name='maintenancemode',
name='created_by',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='%(class)s_created', to=settings.AUTH_USER_MODEL, verbose_name='Created by'),
),
migrations.AlterField(
model_name='maintenancemode',
name='modified_by',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='%(class)s_modified', to=settings.AUTH_USER_MODEL, verbose_name='Modified by'),
),
]
26 changes: 26 additions & 0 deletions notifications/migrations/0020_missing_migrations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Generated by Django 4.2.13 on 2024-08-14 06:52

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('notifications', '0019_add_type_reservation_reminder'),
]

operations = [
migrations.AlterField(
model_name='notificationtemplategroup',
name='created_by',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='%(class)s_created', to=settings.AUTH_USER_MODEL, verbose_name='Created by'),
),
migrations.AlterField(
model_name='notificationtemplategroup',
name='modified_by',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='%(class)s_modified', to=settings.AUTH_USER_MODEL, verbose_name='Modified by'),
),
]
2 changes: 2 additions & 0 deletions payments/api/order.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from resources.api.base import register_view
from resources.models import Reservation
from random import randint

from ..api.base import OrderLineSerializer, OrderSerializerBase
from ..models import CustomerGroup, Order, OrderCustomerGroupData, OrderLine, Product, ProductCustomerGroup
Expand Down Expand Up @@ -67,6 +68,7 @@ def check_price(self, request):
end = order_data.pop('end')
order_data['state'] = 'price_check'
order = Order(**order_data)
order.id = randint(99999999, 999999999)
order_lines = [OrderLine(order=order, **data) for data in order_lines_data]

# store the OrderLine objects in the Order object so that we can use
Expand Down
2 changes: 1 addition & 1 deletion payments/api/reservation.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def validate(self, attrs):
customer_group = attrs.get('customer_group', None)
resource = self.context.get('resource')

login_method = getattr(request.user, 'amr', None)
login_method = request.user.amr.id if request.user.amr else None
if login_method:
for order_line in attrs.get('order_lines', []):
product = order_line.get('product')
Expand Down
19 changes: 19 additions & 0 deletions payments/migrations/0015_new_tax_percentage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 4.2.15 on 2024-08-14 10:01

from decimal import Decimal
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('payments', '0014_customer_group_login_methods'),
]

operations = [
migrations.AlterField(
model_name='product',
name='tax_percentage',
field=models.DecimalField(choices=[(Decimal('0.00'), '0.00'), (Decimal('10.00'), '10.00'), (Decimal('14.00'), '14.00'), (Decimal('24.00'), '24.00'), (Decimal('25.50'), '25.50')], decimal_places=2, default=Decimal('24.00'), max_digits=5, verbose_name='tax percentage'),
),
]
1 change: 1 addition & 0 deletions payments/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
'10.00',
'14.00',
'24.00',
'25.50',
)]

DEFAULT_TAX_PERCENTAGE = Decimal('24.00')
Expand Down
4 changes: 1 addition & 3 deletions payments/providers/turku_payment_provider_v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,12 +222,10 @@ def payload_add_products(self, payload, order):
order_line.order._in_memory_customer_group_id = order.customer_group.id

product = order_line.product
int_tax = int(product.tax_percentage)
assert int_tax == product.tax_percentage
product_data = {
'unitPrice': self.convert_price_to_cents(round_price(order_line.get_unit_price())),
'units': str(order_line.quantity),
'vatPercentage': str(int_tax),
'vatPercentage': str(product.tax_percentage),
'productCode': product.sku,
'description': product.name,
}
Expand Down
10 changes: 5 additions & 5 deletions payments/templates/admin/productcustomergroup/change_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
(function ($) {
function changeTaxfreeValue(edit = false) {
// value of the read-only field that contains tax % when editing a pcg.
const percValue = parseInt($("div[class='grp-readonly']").text());
const percValue = parseFloat($("div[class='grp-readonly']").text());
// stop if percValue doesn't exist because this only works when editing a pcg.
if (!percValue) { return; }
// current price_tax_free value
Expand All @@ -16,12 +16,12 @@
// unrounded taxfree price value.
const sum = 100 * priceValue / (100 + percValue);
// set price_tax_free input value to a rounded version of sum
$("#id_price_tax_free").val(Math.round(sum * 100) / 100);
$("#id_price_tax_free").val((Math.round((sum + Number.EPSILON) * 100) / 100).toFixed(2));
}
};
function changePriceValue(edit = false) {
// value of the read-only field that contains tax % when editing a pcg.
const percValue = parseInt($("div[class='grp-readonly']").text());
const percValue = parseFloat($("div[class='grp-readonly']").text());
// stop if percValue doesn't exist because this only works when editing a pcg.
if (!percValue) { return; }
// current price_tax_free value
Expand All @@ -32,7 +32,7 @@
// unrounded taxfree price value.
const sum = (taxValue * percValue / 100) + taxValue;
// set price_tax_free input value to a rounded version of sum
$("#id_price").val(Math.round(sum * 100) / 100);
$("#id_price").val((Math.round((sum + Number.EPSILON) * 100) / 100).toFixed(2));
}
};
$(document).ready(function () {
Expand All @@ -49,4 +49,4 @@
})(grp.jQuery);
</script>
{{ block.super }}
{% endblock%}
{% endblock%}
Loading

0 comments on commit 4063eb3

Please sign in to comment.