add simple survey support
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
# Generated by Django 6.0.1 on 2026-06-28 20:59
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
('contenttypes', '0002_remove_content_type_name'),
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Survey',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('name', models.CharField(help_text='Title of the survey', max_length=200)),
|
||||
('description', models.TextField(blank=True, help_text='Introductory text or description')),
|
||||
('created_at', models.DateTimeField(auto_now_add=True)),
|
||||
('updated_at', models.DateTimeField(auto_now=True)),
|
||||
('active', models.BooleanField(default=True, help_text='If inactive, users will not be able to fill out the survey.')),
|
||||
('anonymous', models.BooleanField(default=False, help_text='If checked, responses will not link to the user account or candidate details.')),
|
||||
('created_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='created_surveys', to=settings.AUTH_USER_MODEL)),
|
||||
],
|
||||
options={
|
||||
'ordering': ['-created_at'],
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='SurveyQuestion',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('text', models.TextField(help_text='The question text to display to users')),
|
||||
('question_type', models.CharField(choices=[('TEXT', 'Free Text'), ('CHOICE', 'Multiple Choice (Single Option)'), ('RATING', 'Rating (1-5 Likert scale)')], default='TEXT', max_length=20)),
|
||||
('choices', models.TextField(blank=True, help_text='For Multiple Choice questions, enter options separated by a new line.')),
|
||||
('required', models.BooleanField(default=True, help_text='If checked, users must answer this question to submit.')),
|
||||
('position', models.IntegerField(default=0, help_text='Ordering position of the question.')),
|
||||
('survey', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='questions', to='survey.survey')),
|
||||
],
|
||||
options={
|
||||
'ordering': ['position', 'id'],
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='SurveyResponse',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('cid', models.IntegerField(blank=True, help_text='Candidate ID if taken by an anonymous candidate login.', null=True)),
|
||||
('object_id', models.PositiveIntegerField(blank=True, null=True)),
|
||||
('pre_or_post', models.CharField(choices=[('PRE', 'Pre-take survey'), ('POST', 'Post-take survey'), ('GENERAL', 'General feedback')], default='GENERAL', max_length=10)),
|
||||
('created_at', models.DateTimeField(auto_now_add=True)),
|
||||
('content_type', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='contenttypes.contenttype')),
|
||||
('survey', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='responses', to='survey.survey')),
|
||||
('user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='survey_responses', to=settings.AUTH_USER_MODEL)),
|
||||
],
|
||||
options={
|
||||
'ordering': ['-created_at'],
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='SurveyAnswer',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('text_answer', models.TextField(blank=True, null=True)),
|
||||
('choice_answer', models.CharField(blank=True, max_length=255, null=True)),
|
||||
('rating_answer', models.IntegerField(blank=True, null=True)),
|
||||
('question', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='answers', to='survey.surveyquestion')),
|
||||
('response', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='answers', to='survey.surveyresponse')),
|
||||
],
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,25 @@
|
||||
# Generated by Django 6.0.1 on 2026-06-28 21:23
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('survey', '0001_initial'),
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='survey',
|
||||
name='author',
|
||||
field=models.ManyToManyField(blank=True, help_text='Author/Manager(s) of the survey', related_name='surveys', to=settings.AUTH_USER_MODEL),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='survey',
|
||||
name='authors_only',
|
||||
field=models.BooleanField(default=False, help_text='If true, only survey authors will be able to view or manage this survey.'),
|
||||
),
|
||||
]
|
||||
Reference in New Issue
Block a user