Save the form type (long, short) with the case study

This commit is contained in:
Anna Sidwell 2019-03-04 20:41:15 +00:00
parent 3c45e38fd5
commit f8d4cfe755
3 changed files with 24 additions and 0 deletions

View File

@ -0,0 +1,18 @@
# Generated by Django 2.1.1 on 2019-03-04 20:40
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('map', '0075_auto_20190304_2016'),
]
operations = [
migrations.AddField(
model_name='casestudy',
name='form_type',
field=models.CharField(blank=True, max_length=16),
),
]

View File

@ -317,6 +317,9 @@ class CaseStudy(models.Model):
# Language this case study is written in
language = models.CharField(max_length=16, blank=True)
# Long or short case study?
form_type = models.CharField(max_length=16, blank=True)
##
# Territory info
##

View File

@ -119,6 +119,7 @@ class BaseCreateForm(LoginRequiredMixin, FilesHandlerMixin, CreateView):
self.object.author = self.request.user
self.object.language = get_language()
self.object.form_type = self.form_type
self.object.save()
send_email(self.object.id)
@ -130,11 +131,13 @@ class BaseCreateForm(LoginRequiredMixin, FilesHandlerMixin, CreateView):
class CreateShortCaseStudy(BaseCreateForm):
"""View for short version of case study form."""
form_class = ShortCaseStudyForm
form_type = "short"
class CreateLongCaseStudy(BaseCreateForm):
"""View for long version of case study form."""
form_class = LongCaseStudyForm
form_type = "long"
class CreateCaseStudySuccess(TemplateView):