diff --git a/config/settings.py b/config/settings.py index e8d929b..25486fa 100755 --- a/config/settings.py +++ b/config/settings.py @@ -40,6 +40,7 @@ INSTALLED_APPS = [ 'django.contrib.staticfiles', 'widget_tweaks', 'django_cleanup', + 'crispy_forms', 'profanity' ] diff --git a/homepage/forms.py b/homepage/forms.py index 11af0b8..25d3f7e 100644 --- a/homepage/forms.py +++ b/homepage/forms.py @@ -1,7 +1,7 @@ from django import forms from django.contrib.auth.models import User from profanity.validators import validate_is_profane -from .models import Answer, EMOTION_CHOICES +from .models import Answer, Location, Poll, EMOTION_CHOICES class PollForm(forms.ModelForm): hi = forms.CharField(max_length=200, validators=[validate_is_profane], required=False) @@ -18,4 +18,18 @@ class PollForm(forms.ModelForm): class Meta: model = Answer - fields = ['hi', 'lo', 'emotion', 'name', 'place','question'] \ No newline at end of file + fields = ['hi', 'lo', 'emotion', 'name', 'place','question'] + +class LocationForm (forms.ModelForm): + + class Meta: + model = Location + fields = ['name', 'insta'] + +class CreatePollForm (forms.ModelForm): + ask_question = forms.BooleanField(label="Ask extra question", required=False) + question_text = forms.CharField(label="Extra question text (leave blank if no extra question)", max_length=100, required=False) + + class Meta: + model = Poll + fields = ['ask_hi','hi_text','ask_lo','lo_text','ask_emotion','emotion_text','ask_name','name_text','ask_place','place_text','ask_question','question_text'] \ No newline at end of file diff --git a/homepage/migrations/0013_auto_20200827_0028.py b/homepage/migrations/0013_auto_20200827_0028.py new file mode 100644 index 0000000..2c0f14b --- /dev/null +++ b/homepage/migrations/0013_auto_20200827_0028.py @@ -0,0 +1,28 @@ +# Generated by Django 3.1 on 2020-08-27 04:28 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('homepage', '0012_auto_20200826_2354'), + ] + + operations = [ + migrations.AlterField( + model_name='poll', + name='hi_text', + field=models.CharField(blank=True, default='What was the Hi of this week?', max_length=100, null=True), + ), + migrations.AlterField( + model_name='poll', + name='lo_text', + field=models.CharField(blank=True, default='What was the Lo of this week?', max_length=100, null=True), + ), + migrations.AlterField( + model_name='poll', + name='pub_date', + field=models.DateTimeField(blank=True, null=True, verbose_name='date published'), + ), + ] diff --git a/homepage/models.py b/homepage/models.py index e718dfc..adbe308 100755 --- a/homepage/models.py +++ b/homepage/models.py @@ -18,9 +18,10 @@ from PIL import Image, ImageDraw, ImageFont class Location (models.Model): name = models.CharField(max_length=20, blank=True, null=True) - slug = models.CharField(max_length=20, blank=True, null=True) insta = models.CharField(max_length=20, blank=True, null=True) + slug = models.CharField(max_length=20, blank=True, null=True) + hero = models.ImageField(default="hero.png", upload_to='heros') hero_mobile = models.ImageField(default="hero-mobile.png", upload_to='heros') @@ -73,10 +74,10 @@ class Poll (models.Model): location = models.OneToOneField(Location, on_delete=models.CASCADE) ask_hi = models.BooleanField(default=True) - hi_text = models.CharField(max_length=100, blank=True, null=True, default='What was the Hi of this we') + hi_text = models.CharField(max_length=100, blank=True, null=True, default='What was the Hi of this week?') ask_lo = models.BooleanField(default=True) - lo_text = models.CharField(max_length=100, blank=True, null=True, default='What was the Lo of this we') + lo_text = models.CharField(max_length=100, blank=True, null=True, default='What was the Lo of this week?') ask_emotion = models.BooleanField(default=True) emotion_text = models.CharField(max_length=100, blank=True, null=True, default="how are you feeling today?") @@ -90,11 +91,14 @@ class Poll (models.Model): ask_question = models.BooleanField(default=False) question_text = models.CharField(max_length=100, blank=True, null=True) - pub_date = models.DateTimeField('date published') + pub_date = models.DateTimeField('date published', blank=True, null=True) def __str__(self): return f"{self.location.name}'s Poll" + def __save__(self, *args, **kwargs): + self.pub_date = timezone.now() + super().save(self, *args, **kwargs) EMOTION_CHOICES= [ diff --git a/homepage/templates/homepage/create.html b/homepage/templates/homepage/create.html index a16aec7..2f54909 100644 --- a/homepage/templates/homepage/create.html +++ b/homepage/templates/homepage/create.html @@ -1 +1,35 @@ -create.html +{% extends 'homepage/base.html' %} +{% load crispy_forms_tags %} +{% block content %} + + + Back + +
Create a HiLo for your area, and get your own customized page!
+