Merge pull request #1056 from ae-utbm/fixes

Fixes
This commit is contained in:
thomas girod 2025-04-04 11:25:18 +02:00 committed by GitHub
commit 3d40e92958
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 12 additions and 20 deletions

View File

@ -27,7 +27,7 @@
</p>
<fieldset class="required margin-bottom">
{% for field_name in form.admin_fields %}
{% set field = form.pop(field_name) %}
{% set field = form[field_name] %}
<div class="form-group">
{{ field.errors }}
{{ field.label_tag() }}

View File

@ -918,3 +918,14 @@ def test_club_board_member_cannot_edit_club_properties(client: Client):
assert club.name == "old name"
assert club.is_active
assert club.address == "new address"
@pytest.mark.django_db
def test_edit_club_page_doesnt_crash(client: Client):
"""crash test for club:club_edit"""
club = baker.make(Club)
user = subscriber_user.make()
baker.make(Membership, club=club, user=user, role=3)
client.force_login(user)
res = client.get(reverse("club:club_edit", kwargs={"club_id": club.id}))
assert res.status_code == 200

View File

@ -1,23 +1,7 @@
# Generated by Django 4.2.17 on 2025-03-05 14:03
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
from django.db.migrations.state import StateApps
def migrate_cons_balances(apps: StateApps, schema_editor):
ReturnableProduct = apps.get_model("counter", "ReturnableProduct")
Product = apps.get_model("counter", "Product")
cons = Product.objects.filter(pk=settings.SITH_ECOCUP_CONS).first()
dcons = Product.objects.filter(pk=settings.SITH_ECOCUP_DECO).first()
if not cons or not dcons:
return
returnable = ReturnableProduct.objects.create(
product=cons, returned_product=dcons, max_return=settings.SITH_ECOCUP_LIMIT
)
returnable.update_balances()
class Migration(migrations.Migration):
@ -119,8 +103,5 @@ class Migration(migrations.Migration):
name="returnable_product_unique_type_per_customer",
),
),
migrations.RunPython(
migrate_cons_balances, reverse_code=migrations.RunPython.noop, elidable=True
),
migrations.RemoveField(model_name="customer", name="recorded_products"),
]