-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Change PARegistration form (#293) * Add checkbox to PARegistrationForm * Change PARegistration model to allow null values * Add logic to verify address only when needed * Change PARegistrationForm * Add javascript to form * Add 'no_prizes' field to PARegistrationModel --------- Co-authored-by: Mateusz Jacniacki <[email protected]>
- Loading branch information
Showing
6 changed files
with
115 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,4 +46,4 @@ class Migration(migrations.Migration): | |
}, | ||
bases=(models.Model,), | ||
), | ||
] | ||
] |
52 changes: 52 additions & 0 deletions
52
oioioi/pa/migrations/0003_paregistration_no_prizes_and_more.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Generated by Django 4.2.6 on 2023-12-13 15:38 | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
import oioioi.base.fields | ||
import oioioi.participants.fields | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('participants', '0011_alter_onsiteregistration_participant_and_more'), | ||
('pa', '0002_auto_20181117_1141'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='paregistration', | ||
name='no_prizes', | ||
field=models.BooleanField(default=False, verbose_name="I don't want to provide my address (opt out of prizes)"), | ||
), | ||
migrations.AlterField( | ||
model_name='paregistration', | ||
name='address', | ||
field=models.CharField(blank=True, max_length=255, null=True, verbose_name='address'), | ||
), | ||
migrations.AlterField( | ||
model_name='paregistration', | ||
name='city', | ||
field=models.CharField(blank=True, max_length=100, null=True, verbose_name='city'), | ||
), | ||
migrations.AlterField( | ||
model_name='paregistration', | ||
name='job', | ||
field=models.CharField(choices=[('PS', 'Szkoła podstawowa'), ('MS', 'Gimnazjum'), ('HS', 'Szkoła ponadgimnazjalna'), ('OTH', 'Inne'), ('AS', 'Szkoła wyższa - student'), ('AD', 'Szkoła wyższa - doktorant'), ('COM', 'Firma')], max_length=7, verbose_name='job or school kind'), | ||
), | ||
migrations.AlterField( | ||
model_name='paregistration', | ||
name='participant', | ||
field=oioioi.participants.fields.OneToOneBothHandsCascadingParticipantField(on_delete=django.db.models.deletion.CASCADE, related_name='%(app_label)s_%(class)s', to='participants.participant'), | ||
), | ||
migrations.AlterField( | ||
model_name='paregistration', | ||
name='postal_code', | ||
field=oioioi.base.fields.PostalCodeField(blank=True, null=True, verbose_name='postal code'), | ||
), | ||
migrations.AlterField( | ||
model_name='paregistration', | ||
name='t_shirt_size', | ||
field=models.CharField(blank=True, choices=[('S', 'S'), ('M', 'M'), ('L', 'L'), ('XL', 'XL'), ('XXL', 'XXL')], max_length=7, null=True, verbose_name='t-shirt size'), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{% extends "participants/registration.html" %} | ||
{% load i18n %} | ||
|
||
{% block scripts %} | ||
{{ block.super }} | ||
<script> | ||
var prizeFieldsIDs = ["id_address", "id_postal_code", "id_city", "id_t_shirt_size"]; | ||
|
||
function togglePrizeFields() { | ||
var hidePrizeFields = document.getElementById("id_no_prizes").checked; | ||
|
||
prizeFieldsIDs.forEach(function (id) { | ||
var input = document.getElementById(id); | ||
var formGroup = input.closest(".form-group"); | ||
formGroup.style.display = hidePrizeFields ? "none" : "block"; | ||
}); | ||
} | ||
|
||
document.getElementById("id_no_prizes").addEventListener("change", togglePrizeFields); | ||
</script> | ||
{% endblock %} |