forked from TabbycatDebate/tabbycat
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branches 'master' and 'task/2479' into develop
- Loading branch information
Showing
23 changed files
with
3,219 additions
and
602 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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
294 changes: 294 additions & 0 deletions
294
tabbycat/adjfeedback/migrations/0016_question_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,294 @@ | ||
# Generated by Django 5.0.6 on 2024-07-21 12:42 | ||
|
||
from itertools import chain | ||
|
||
import django.db.models.deletion | ||
import django_better_admin_arrayfield.models.fields | ||
import utils.models | ||
from django.db import migrations, models | ||
|
||
|
||
answer_migrations = [ | ||
[ | ||
migrations.AlterModelOptions( | ||
name=table, | ||
options={ | ||
"verbose_name": f"{name} answer", | ||
"verbose_name_plural": f"{name} answers", | ||
}, | ||
), | ||
migrations.RemoveConstraint( | ||
model_name=table, | ||
name=f"adjfeed_{table}_question__feedback_uniq", | ||
), | ||
migrations.AddField( | ||
model_name=table, | ||
name="content_type", | ||
field=models.ForeignKey( | ||
null=True, | ||
limit_choices_to=models.Q( | ||
("app_label", "adjfeedback"), ("model", "adjudicatorfeedback") | ||
), | ||
on_delete=django.db.models.deletion.CASCADE, | ||
to="contenttypes.contenttype", | ||
verbose_name="content type", | ||
), | ||
), | ||
migrations.RunSQL(f"UPDATE adjfeedback_{table} SET content_type_id=(SELECT id FROM django_content_type WHERE model='adjudicatorfeedback')"), | ||
migrations.AlterField( | ||
model_name=table, | ||
name="content_type", | ||
field=models.ForeignKey( | ||
null=False, | ||
limit_choices_to=models.Q( | ||
("app_label", "adjfeedback"), ("model", "adjudicatorfeedback") | ||
), | ||
on_delete=django.db.models.deletion.CASCADE, | ||
to="contenttypes.contenttype", | ||
verbose_name="content type", | ||
), | ||
), | ||
migrations.RenameField( | ||
model_name=table, | ||
old_name="feedback", | ||
new_name="object", | ||
), | ||
migrations.AlterField( | ||
model_name=table, | ||
name="object_id", | ||
field=models.PositiveIntegerField(verbose_name="object id"), | ||
preserve_default=False, | ||
), | ||
migrations.AlterField( | ||
model_name=table, | ||
name="question", | ||
field=models.ForeignKey( | ||
on_delete=django.db.models.deletion.CASCADE, | ||
to="adjfeedback.question", | ||
verbose_name="question", | ||
), | ||
), | ||
migrations.AddConstraint( | ||
model_name=table, | ||
constraint=utils.models.UniqueConstraint( | ||
fields=("question", "content_type", "object_id"), | ||
name=f"adjfeed_{table}_question__content_type__object_id_uniq", | ||
), | ||
), | ||
migrations.RenameModel(table, table[19:]), | ||
] | ||
for table, name in [ | ||
('adjudicatorfeedbackbooleananswer', 'boolean'), | ||
('adjudicatorfeedbackfloatanswer', 'float'), | ||
('adjudicatorfeedbackmanyanswer', 'multiple select'), | ||
('adjudicatorfeedbackstringanswer', 'string'), | ||
('adjudicatorfeedbackintegeranswer', 'integer'), | ||
] | ||
] | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("adjfeedback", "0015_alter_adjudicatorfeedback_unique_together_and_more"), | ||
("contenttypes", "0002_remove_content_type_name"), | ||
("tournaments", "0013_scheduleevent"), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name="Question", | ||
fields=[ | ||
( | ||
"id", | ||
models.AutoField( | ||
auto_created=True, | ||
primary_key=True, | ||
serialize=False, | ||
verbose_name="ID", | ||
), | ||
), | ||
( | ||
"seq", | ||
models.IntegerField( | ||
help_text="The order in which questions are displayed", | ||
verbose_name="sequence number", | ||
), | ||
), | ||
( | ||
"text", | ||
models.CharField( | ||
help_text='The question displayed to participants, e.g., "Did you agree with the decision?"', | ||
max_length=255, | ||
verbose_name="text", | ||
), | ||
), | ||
( | ||
"name", | ||
models.CharField( | ||
help_text='A short name for the question, e.g., "Agree with decision"', | ||
max_length=30, | ||
verbose_name="name", | ||
), | ||
), | ||
( | ||
"answer_type", | ||
models.CharField( | ||
choices=[ | ||
("bc", "checkbox"), | ||
("bs", "yes/no (dropdown)"), | ||
("i", "integer (textbox)"), | ||
("is", "integer scale"), | ||
("f", "float"), | ||
("t", "text"), | ||
("tl", "long text"), | ||
("ss", "select one"), | ||
("ms", "select multiple"), | ||
], | ||
max_length=2, | ||
verbose_name="answer type", | ||
), | ||
), | ||
( | ||
"required", | ||
models.BooleanField( | ||
default=True, | ||
help_text="Whether participants are required to fill out this field", | ||
verbose_name="required", | ||
), | ||
), | ||
( | ||
"min_value", | ||
models.FloatField( | ||
blank=True, | ||
help_text="Minimum allowed value for numeric fields (ignored for text or boolean fields)", | ||
null=True, | ||
verbose_name="minimum value", | ||
), | ||
), | ||
( | ||
"max_value", | ||
models.FloatField( | ||
blank=True, | ||
help_text="Maximum allowed value for numeric fields (ignored for text or boolean fields)", | ||
null=True, | ||
verbose_name="maximum value", | ||
), | ||
), | ||
( | ||
"choices", | ||
django_better_admin_arrayfield.models.fields.ArrayField( | ||
base_field=models.TextField(), | ||
blank=True, | ||
default=list, | ||
help_text="Permissible choices for select one/multiple fields (ignored for other fields)", | ||
size=None, | ||
verbose_name="choices", | ||
), | ||
), | ||
( | ||
"for_content_type", | ||
models.ForeignKey( | ||
limit_choices_to=models.Q( | ||
("app_label", "adjfeedback"), ("model", "adjudicatorfeedback") | ||
), | ||
on_delete=django.db.models.deletion.CASCADE, | ||
to="contenttypes.contenttype", | ||
verbose_name="for content type", | ||
), | ||
), | ||
( | ||
"tournament", | ||
models.ForeignKey( | ||
on_delete=django.db.models.deletion.CASCADE, | ||
to="tournaments.tournament", | ||
verbose_name="tournament", | ||
), | ||
), | ||
], | ||
options={ | ||
"verbose_name": "question", | ||
"verbose_name_plural": "questions", | ||
}, | ||
), | ||
migrations.RunSQL("INSERT INTO adjfeedback_question (id, seq, tournament_id, text, name, answer_type, required, min_value, max_value, choices, for_content_type_id) SELECT id, seq, tournament_id, text, name, answer_type, required, min_value, max_value, choices, (SELECT id FROM django_content_type WHERE model='adjudicatorfeedback') for_content_type_id FROM adjfeedback_adjudicatorfeedbackquestion", migrations.RunSQL.noop), | ||
migrations.RunSQL("SELECT pg_catalog.setval('public.adjfeedback_question_id_seq', (SELECT last_value FROM adjfeedback_adjudicatorfeedbackquestion_id_seq), true)", migrations.RunSQL.noop), | ||
migrations.RunSQL( | ||
"ALTER TABLE adjfeedback_adjudicatorfeedbackquestion DROP CONSTRAINT adjfeed_adjudicatorfeedbackquestion_tournament__reference_uniq, DROP CONSTRAINT adjfeed_adjudicatorfeedbackquestion_tournament__seq_uniq, DROP COLUMN answer_type, DROP COLUMN choices, DROP COLUMN max_value, DROP COLUMN min_value, DROP COLUMN required, DROP COLUMN seq, DROP COLUMN name, DROP COLUMN text, DROP COLUMN tournament_id", | ||
state_operations=[ | ||
migrations.RemoveConstraint( | ||
model_name="adjudicatorfeedbackquestion", | ||
name="adjfeed_adjudicatorfeedbackquestion_tournament__reference_uniq", | ||
), | ||
migrations.RemoveConstraint( | ||
model_name="adjudicatorfeedbackquestion", | ||
name="adjfeed_adjudicatorfeedbackquestion_tournament__seq_uniq", | ||
), | ||
migrations.RemoveField( | ||
model_name="adjudicatorfeedbackquestion", | ||
name="answer_type", | ||
), | ||
migrations.RemoveField( | ||
model_name="adjudicatorfeedbackquestion", | ||
name="choices", | ||
), | ||
migrations.RemoveField( | ||
model_name="adjudicatorfeedbackquestion", | ||
name="max_value", | ||
), | ||
migrations.RemoveField( | ||
model_name="adjudicatorfeedbackquestion", | ||
name="min_value", | ||
), | ||
migrations.RemoveField( | ||
model_name="adjudicatorfeedbackquestion", | ||
name="name", | ||
), | ||
migrations.RemoveField( | ||
model_name="adjudicatorfeedbackquestion", | ||
name="required", | ||
), | ||
migrations.RemoveField( | ||
model_name="adjudicatorfeedbackquestion", | ||
name="seq", | ||
), | ||
migrations.RemoveField( | ||
model_name="adjudicatorfeedbackquestion", | ||
name="text", | ||
), | ||
migrations.RemoveField( | ||
model_name="adjudicatorfeedbackquestion", | ||
name="tournament", | ||
), | ||
], | ||
), | ||
migrations.RunSQL( | ||
"ALTER TABLE adjfeedback_adjudicatorfeedbackquestion RENAME COLUMN id TO question_ptr", | ||
state_operations=[ | ||
migrations.RemoveField( | ||
model_name="adjudicatorfeedbackquestion", | ||
name="id", | ||
), | ||
migrations.AddField( | ||
model_name="adjudicatorfeedbackquestion", | ||
name="question_ptr", | ||
field=models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'), | ||
), | ||
], | ||
), | ||
migrations.AlterField( | ||
model_name="adjudicatorfeedbackquestion", | ||
name="question_ptr", | ||
field=models.OneToOneField( | ||
auto_created=True, | ||
default=1, | ||
on_delete=django.db.models.deletion.CASCADE, | ||
parent_link=True, | ||
primary_key=True, | ||
serialize=False, | ||
to="adjfeedback.question", | ||
), | ||
preserve_default=False, | ||
), | ||
*chain.from_iterable(answer_migrations), | ||
] |
Oops, something went wrong.