-
Notifications
You must be signed in to change notification settings - Fork 24
Convert grant_type to be a multiple choice
#4200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| # Generated by Django 5.1.1 on 2024-12-01 17:59 | ||
|
|
||
| from django.db import migrations, models | ||
| import json | ||
|
|
||
| def forwards_func(apps, schema_editor): | ||
| Grant = apps.get_model('grants', 'Grant') | ||
| for grant in Grant.objects.all(): | ||
| old_value = grant.grant_type | ||
| # Convert the old string value into a list | ||
| grant.grant_type_json = [old_value] if old_value else [] | ||
| grant.save(update_fields=['grant_type_json']) | ||
|
|
||
| def reverse_func(apps, schema_editor): | ||
| Grant = apps.get_model('grants', 'Grant') | ||
| for grant in Grant.objects.all(): | ||
| value_list = grant.grant_type | ||
| # Convert the list back to a single string | ||
| if value_list: | ||
| grant.grant_type = value_list[0] | ||
| else: | ||
| grant.grant_type = '' | ||
| grant.save(update_fields=['grant_type']) | ||
|
|
||
| class Migration(migrations.Migration): | ||
| dependencies = [ | ||
| ("grants", "0022_grant_departure_city_grant_nationality_and_more"), | ||
| ] | ||
|
|
||
| operations = [ | ||
| # Step 1: Add a temporary JSONField | ||
| migrations.AddField( | ||
| model_name='grant', | ||
| name='grant_type_json', | ||
| field=models.JSONField(default=list, verbose_name="grant type"), | ||
| ), | ||
| # Step 2: Backfill data into the temporary field | ||
| migrations.RunPython(forwards_func, reverse_func), | ||
| # Step 3: Remove the old field | ||
| migrations.RemoveField( | ||
| model_name='grant', | ||
| name='grant_type', | ||
| ), | ||
| # Step 4: Rename the temporary field to grant_type | ||
| migrations.RenameField( | ||
| model_name='grant', | ||
| old_name='grant_type_json', | ||
| new_name='grant_type', | ||
| ), | ||
| ] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -696,6 +696,7 @@ We look forward to reading about you and hope to see you at PyCon Italia 2024! | |
| "grants.form.yourGrant": "Your grant", | ||
| "grants.form.travel": "Travel", | ||
| "grants.form.youAndPython": "You and Python", | ||
| "grants.form.validationErrors": "The submitted form is not correct", | ||
|
|
||
| "grants.form.optionalInformation": "Optional information", | ||
| "grants.form.optionalInformation.description": | ||
|
|
@@ -730,9 +731,10 @@ We look forward to reading about you and hope to see you at PyCon Italia 2024! | |
| "grants.form.fields.occupation.values.researcher": "Researcher", | ||
| "grants.form.fields.occupation.values.unemployed": "Unemployed", | ||
| "grants.form.fields.occupation.values.other": "Other", | ||
| "grants.form.fields.grantType": "What type of grant are you applying for?", | ||
| "grants.form.fields.grantType.description": | ||
| "Note: If you have submitted a talk/workshop proposal, you do not need to apply for a grant to receive a refund. If your proposal is accepted, we will contact you regarding the ticket refund.", | ||
| "grants.form.fields.grantType": | ||
| "Select all grant categories that apply to you", | ||
| "grants.form.fields.grantType.description": `You can choose more than one option if applicable. | ||
| Note: If you have submitted a talk/workshop proposal, you do not need to apply for a grant to receive a refund. If your proposal is accepted, we will contact you regarding the ticket refund.`, | ||
|
||
| "grants.form.fields.grantType.values.diversity": "Diversity", | ||
| "grants.form.fields.grantType.values.unemployed": "Unemployed", | ||
| "grants.form.fields.grantType.values.speaker": "Speaker", | ||
|
|
@@ -1456,9 +1458,10 @@ Non vediamo l'ora di leggere la tua storia e speriamo di vederti a PyCon Italia | |
| "grants.form.fields.occupation.values.researcher": "Ricerca", | ||
| "grants.form.fields.occupation.values.unemployed": "Disoccupato/a", | ||
| "grants.form.fields.occupation.values.other": "Altro", | ||
| "grants.form.fields.grantType": "Che tipo di grant stai richiedendo?", | ||
| "grants.form.fields.grantType.description": | ||
| "Nota: Se hai inviato una proposta di talk/workshop, non è necessario fare domanda per un grant per ricevere un rimborso. Se la tua proposta viene accettata, ti contatteremo riguardo al rimborso del biglietto.", | ||
| "grants.form.fields.grantType": | ||
| "Seleziona tutte le categorie di grant che si applicano a te", | ||
| "grants.form.fields.grantType.description": `Puoi scegliere più di un'opzione se necessario. | ||
| Nota: Se hai inviato una proposta di talk/workshop, non è necessario fare domanda per un grant per ricevere un rimborso. Se la tua proposta viene accettata, ti contatteremo riguardo al rimborso del biglietto.`, | ||
| "grants.form.fields.grantType.values.diversity": "Diversity", | ||
| "grants.form.fields.grantType.values.unemployed": "Disoccupato", | ||
| "grants.form.fields.grantType.values.speaker": "Speaker", | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why the empty space? maybe a vertical Spacer works better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no was a mistake, think my editor put it somehow