mirror of
https://github.com/Rushilwiz/HiLo.git
synced 2025-04-09 14:40:16 -04:00
working poll, models, and options
This commit is contained in:
parent
80aae0f41c
commit
c0adf2fa30
|
@ -38,6 +38,7 @@ INSTALLED_APPS = [
|
|||
'django.contrib.sessions',
|
||||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
'widget_tweaks',
|
||||
]
|
||||
|
||||
MIDDLEWARE = [
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
from django.contrib import admin
|
||||
from .models import Poll
|
||||
from .models import Poll, Answer
|
||||
|
||||
# Register your models here.
|
||||
|
||||
admin.site.register(Poll)
|
||||
admin.site.register(Poll)
|
||||
admin.site.register(Answer)
|
|
@ -1,6 +1,7 @@
|
|||
# Generated by Django 3.1 on 2020-08-18 22:01
|
||||
# Generated by Django 3.0.8 on 2020-08-25 21:41
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
@ -15,11 +16,30 @@ class Migration(migrations.Migration):
|
|||
name='Poll',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('question1', models.CharField(max_length=200)),
|
||||
('question2', models.CharField(max_length=200)),
|
||||
('question3', models.CharField(max_length=200)),
|
||||
('askHi', models.BooleanField(default=True)),
|
||||
('HiText', models.CharField(blank=True, max_length=50, null=True)),
|
||||
('askLo', models.BooleanField(default=True)),
|
||||
('LoText', models.CharField(blank=True, max_length=50, null=True)),
|
||||
('askEmotion', models.BooleanField(default=True)),
|
||||
('EmotionText', models.CharField(blank=True, max_length=50, null=True)),
|
||||
('askName', models.BooleanField(default=True)),
|
||||
('NameText', models.CharField(blank=True, max_length=50, null=True)),
|
||||
('askPlace', models.BooleanField(default=True)),
|
||||
('PlaceText', models.CharField(blank=True, max_length=50, null=True)),
|
||||
('askQuestion', models.BooleanField(default=True)),
|
||||
('QuestionText', models.CharField(blank=True, max_length=50, null=True)),
|
||||
('pub_date', models.DateTimeField(verbose_name='date published')),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Answer',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('hi', models.CharField(blank=True, max_length=200, null=True)),
|
||||
('lo', models.CharField(blank=True, max_length=200, null=True)),
|
||||
('name', models.CharField(blank=True, max_length=200, null=True)),
|
||||
('place', models.CharField(blank=True, max_length=200, null=True)),
|
||||
('poll', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='homepage.Poll')),
|
||||
],
|
||||
),
|
||||
]
|
||||
|
|
|
@ -3,11 +3,45 @@ from django.db import models
|
|||
# Create your models here.
|
||||
|
||||
class Poll (models.Model):
|
||||
askHi = models.BooleanField(default=True)
|
||||
askLo = models.BooleanField(default=True)
|
||||
askEmotion = models.BooleanField(default=True)
|
||||
askEmotion = models.BooleanField(default=True)
|
||||
ask_hi = models.BooleanField(default=True)
|
||||
hi_text = models.CharField(max_length=50, blank=True, null=True)
|
||||
|
||||
ask_lo = models.BooleanField(default=True)
|
||||
lo_text = models.CharField(max_length=50, blank=True, null=True)
|
||||
|
||||
ask_emotion = models.BooleanField(default=True)
|
||||
emotion_text = models.CharField(max_length=50, blank=True, null=True)
|
||||
|
||||
ask_name = models.BooleanField(default=True)
|
||||
name_text = models.CharField(max_length=50, blank=True, null=True)
|
||||
|
||||
ask_place = models.BooleanField(default=True)
|
||||
place_text = models.CharField(max_length=50, blank=True, null=True)
|
||||
|
||||
ask_question = models.BooleanField(default=False)
|
||||
question_text = models.CharField(max_length=50, blank=True, null=True)
|
||||
|
||||
pub_date = models.DateTimeField('date published')
|
||||
extraQuestion1 = models.CharField(max_length=50, blank=True, null=True)
|
||||
extraQuestion2 = models.CharField(max_length=50, blank=True, null=True)
|
||||
extraQuestion3 = models.CharField(max_length=50, blank=True, null=True)
|
||||
|
||||
def __str__(self):
|
||||
return 'Current Poll'
|
||||
|
||||
|
||||
|
||||
EMOTION_CHOICES= [
|
||||
('happy', 'Happy'),
|
||||
('meh', 'Meh'),
|
||||
('sad', 'Sad'),
|
||||
]
|
||||
|
||||
class Answer (models.Model):
|
||||
poll = models.ForeignKey(Poll, on_delete=models.CASCADE)
|
||||
hi = models.CharField(max_length=200, blank=True, null=True)
|
||||
lo = models.CharField(max_length=200, blank=True, null=True)
|
||||
emotion = models.CharField(max_length=8, default='meh', choices=EMOTION_CHOICES, blank=True, null=True)
|
||||
name = models.CharField(max_length=100, blank=True, null=True)
|
||||
place = models.CharField(max_length=100, blank=True, null=True)
|
||||
question = models.CharField(max_length=200, blank=True, null=True)
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
|
@ -1,34 +1,9 @@
|
|||
{% extends 'homepage/base.html' %}
|
||||
{% load static %}
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" dir="ltr">
|
||||
<head>
|
||||
<!-- Required meta tags -->
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
{% load widget_tweaks %}
|
||||
|
||||
<!-- Bootstrap CSS -->
|
||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
|
||||
|
||||
<!-- Stylesheet -->
|
||||
<link rel="stylesheet" type="text/css" href="{% static 'css/styles.css' %}">
|
||||
|
||||
<!-- Favicon -->
|
||||
<link rel="shortcut icon" href="{% static 'icon/favicon.ico' %}" type="image/x-icon">
|
||||
<link rel="icon" href="{% static 'icon/favicon.ico' %}" type="image/x-icon">
|
||||
|
||||
<!-- Font Awesome -->
|
||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
|
||||
|
||||
<title>HiLo Arlington</title>
|
||||
|
||||
<script src="https://www.google.com/recaptcha/api.js" async defer></script>
|
||||
<script>
|
||||
function onSubmit(token) {
|
||||
document.getElementById("demo-form").submit();
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
{% block content %}
|
||||
<section class="jumbotron hero jumbotron-fluid m-0">
|
||||
<div class="container">
|
||||
<div class="arrow" id="arrow"></div>
|
||||
|
@ -77,61 +52,91 @@
|
|||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Insta info
|
||||
these responses are not being used in any negative way
|
||||
, just to hear stories and see how cool people are all over! you do not
|
||||
have to share your name or where you live, it just makes your
|
||||
responses more identifiable if you see them on the instagram.
|
||||
every two weeks or so there will be a new question put out via
|
||||
QR, and if you follow the instagram handle, you will know when it
|
||||
has been posted. so, please hit the trails and head out into
|
||||
your community and share a new tidbit about yourself.
|
||||
i hope to publish some stories via instagram and share
|
||||
the journeys taking place all over our country!
|
||||
|
||||
-->
|
||||
|
||||
<section>
|
||||
<div style="height=50px!important;" class="jumbotron poll jumbotron-fluid m-0">
|
||||
<div class="jumbotron poll jumbotron-fluid m-0">
|
||||
<div class="container">
|
||||
<form method="post">
|
||||
{% csrf_token %}
|
||||
{% if messages %}
|
||||
{% for message in messages %}
|
||||
<div class="alert alert-{{ message.tags }} alert-dismissible fade show">
|
||||
{{ message }}
|
||||
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
<form id='poll' method="POST">
|
||||
{% csrf_token %}
|
||||
{% for hidden in form.hidden_fields %}
|
||||
{{ hidden }}
|
||||
{% endfor %}
|
||||
<div class="row title pb-3 ">
|
||||
<p for="test" class="mx-auto subtitle">NOW IS YOUR TIME TO SHINE</p>
|
||||
</div>
|
||||
{% if hi_text %}
|
||||
<div class="row pb-3 short-answer">
|
||||
<label class="mx-auto" for="{{ form.hi.id_for_label }}">{{ hi_text|safe }}</label>
|
||||
{{ form.hi|add_class:'w-75 mx-auto rounded' }}
|
||||
{% for error in form.hi.errors %}
|
||||
<span class="help-block">{{ error }}</span>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if lo_text %}
|
||||
<div class="row pb-3 short-answer">
|
||||
<label for="test" class="mx-auto">What was the <span class="hi">Hi</span> of this week?</label>
|
||||
<input class="w-75 mx-auto rounded" type="text" name="test" value="">
|
||||
</div>
|
||||
<div class="row pb-3 short-answer">
|
||||
<label for="test" class="mx-auto">What was the <span class="lo">Lo</span> of this week?</label>
|
||||
<input class="w-75 mx-auto rounded" type="text" name="test" value="">
|
||||
<label class="mx-auto" for="{{ form.lo.id_for_label }}">What was the <span class="lo">Lo</span> of this week?</label>
|
||||
{{ form.lo|add_class:'w-75 mx-auto rounded' }}
|
||||
{% for error in form.lo.errors %}
|
||||
<span class="help-block">{{ error }}</span>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="row pb-1 subtitle">
|
||||
<p class="mx-auto">SOME MORE QUESTIONS FOR THE SOUL</p>
|
||||
</div>
|
||||
{% if emotion_text %}
|
||||
<div class="row pb-3 short-answer">
|
||||
<label for="test" class="mx-auto">how are you feeling today?</label>
|
||||
</div>
|
||||
<div class="row pb-5">
|
||||
<div class="row pb-3">
|
||||
|
||||
{% for radio in form.emotion %}
|
||||
<div class="col emote">
|
||||
<img src="{% static 'css/res/happy.svg' %}" alt="">
|
||||
</div>
|
||||
<div class="col emote">
|
||||
<img src="{% static 'css/res/meh.svg' %}" alt="">
|
||||
</div>
|
||||
<div class="col emote">
|
||||
<img src="{% static 'css/res/sad.svg' %}" alt="">
|
||||
<label for="{{ radio.id_for_label }}">
|
||||
{{ radio.tag }}
|
||||
<img src="{% static 'css/res/'|add:radio.choice_label|add:'.svg' %}" alt="">
|
||||
</label>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
<div class="row short-answer pb-3">
|
||||
<label for="test" class="mx-auto">what's your name?</label>
|
||||
<input class="w-75 mx-auto rounded" type="text" name="test" value="">
|
||||
</div>
|
||||
<div class="row short-answer pt-1 pb-3">
|
||||
<label for="test" class="mx-auto">where are you from?</label>
|
||||
<input class="w-75 mx-auto rounded" type="text" name="test" value="">
|
||||
{% endif %}
|
||||
{% if name_text %}
|
||||
<div class="row pb-3 short-answer">
|
||||
<label class="mx-auto" for="{{ form.name.id_for_label }}">{{ name_text|safe }}</label>
|
||||
{{ form.name|add_class:'w-75 mx-auto rounded' }}
|
||||
{% for error in form.name.errors %}
|
||||
<span class="help-block">{{ error }}</span>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if place_text %}
|
||||
<div class="row pb-3 short-answer">
|
||||
<label class="mx-auto" for="{{ form.place.id_for_label }}">{{ place_text|safe }}</label>
|
||||
{{ form.place|add_class:'w-75 mx-auto rounded' }}
|
||||
{% for error in form.place.errors %}
|
||||
<span class="help-block">{{ error }}</span>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if question_text %}
|
||||
<div class="row pb-3 short-answer">
|
||||
<label class="mx-auto" for="{{ form.question.id_for_label }}">{{ question_text|safe }}</label>
|
||||
{{ form.question|add_class:'w-75 mx-auto rounded' }}
|
||||
{% for error in form.question.errors %}
|
||||
<span class="help-block">{{ error }}</span>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="row">
|
||||
<button type="submit" class="mx-auto btn text-uppercase">
|
||||
<img src="{% static 'css/res/submit.png' %}">
|
||||
|
@ -141,9 +146,4 @@
|
|||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<script src="https://code.jquery.com/jquery-3.5.1.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
|
||||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI" crossorigin="anonymous"></script>
|
||||
<script src="{% static 'js/main.js' %}" type="text/javascript"></script>
|
||||
</body>
|
||||
</html>
|
||||
{% endblock %}
|
|
@ -2,5 +2,6 @@ from django.urls import path
|
|||
from . import views
|
||||
|
||||
urlpatterns = [
|
||||
path ('', views.homepage, name="homepage")
|
||||
path ('', views.homepage, name="homepage"),
|
||||
path ('finish/', views.finish, name="finish")
|
||||
]
|
||||
|
|
|
@ -1,6 +1,72 @@
|
|||
from django.shortcuts import render
|
||||
from django.shortcuts import render, redirect
|
||||
from django.contrib import messages
|
||||
from django.shortcuts import get_object_or_404
|
||||
|
||||
from .forms import PollForm
|
||||
from .models import Poll
|
||||
|
||||
# Create your views here.
|
||||
|
||||
def homepage (request):
|
||||
return render(request, 'homepage/index.html')
|
||||
poll = get_object_or_404(Poll)
|
||||
|
||||
if poll.ask_hi:
|
||||
hi_text = poll.hi_text
|
||||
else:
|
||||
hi_text = None
|
||||
|
||||
if poll.ask_lo:
|
||||
lo_text = poll.lo_text
|
||||
else:
|
||||
lo_text = None
|
||||
|
||||
if poll.ask_emotion:
|
||||
emotion_text = poll.emotion_text
|
||||
else:
|
||||
emotion_text = None
|
||||
|
||||
if poll.ask_name:
|
||||
name_text = poll.name_text
|
||||
else:
|
||||
name_text = None
|
||||
|
||||
if poll.ask_place:
|
||||
place_text = poll.place_text
|
||||
else:
|
||||
place_text = None
|
||||
|
||||
if poll.ask_question:
|
||||
question_text = poll.question_text
|
||||
else:
|
||||
question_text = None
|
||||
|
||||
if request.method == 'POST':
|
||||
print(request.POST)
|
||||
form = PollForm(request.POST)
|
||||
if form.is_valid():
|
||||
print("valid form!")
|
||||
instance = form.save(commit=False)
|
||||
instance.poll = poll
|
||||
instance.save()
|
||||
print(instance.pk)
|
||||
return redirect('finish')
|
||||
else:
|
||||
messages.error(request, 'Looks like there were some problems with your form!', extra_tags='danger')
|
||||
print("invalid form!")
|
||||
else:
|
||||
form = PollForm()
|
||||
|
||||
context = {
|
||||
'form': form,
|
||||
'hi_text': hi_text,
|
||||
'lo_text': lo_text,
|
||||
'emotion_text': emotion_text,
|
||||
'place_text': place_text,
|
||||
'name_text': name_text,
|
||||
'question_text': question_text,
|
||||
}
|
||||
|
||||
return render(request, 'homepage/index.html', context=context)
|
||||
|
||||
def finish (request):
|
||||
pass
|
|
@ -1,5 +1,6 @@
|
|||
argparse==1.2.1
|
||||
django==1.11.29
|
||||
pip-chill==1.0.0
|
||||
python==2.7.17
|
||||
wsgiref==0.1.2
|
||||
argparse
|
||||
django
|
||||
django-widget-tweaks
|
||||
pip-chill
|
||||
python
|
||||
wsgiref
|
||||
|
|
|
@ -2,6 +2,9 @@
|
|||
@font-face {
|
||||
src: url("./fonts/Hanson-Bold.ttf");
|
||||
font-family: "Hanson-Bold"; }
|
||||
@font-face {
|
||||
src: url("./fonts/WildYouth-Regular.otf");
|
||||
font-family: "WildYouth"; }
|
||||
@font-face {
|
||||
src: url("./fonts/FuturaPTMedium.otf");
|
||||
font-family: "Futura";
|
||||
|
@ -152,9 +155,25 @@ label {
|
|||
border-image-repeat: none; }
|
||||
|
||||
.hi {
|
||||
color: #48B93E; }
|
||||
color: #48B93E;
|
||||
font-family: "WildYouth", "Hanson-Bold", "Arial", sans-serif; }
|
||||
|
||||
.lo {
|
||||
color: #E34848; }
|
||||
color: #E34848;
|
||||
font-family: "WildYouth", "Hanson-Bold", "Arial", sans-serif; }
|
||||
|
||||
[type=radio] {
|
||||
position: absolute;
|
||||
opacity: 0;
|
||||
width: 0;
|
||||
height: 0; }
|
||||
|
||||
/* IMAGE STYLES */
|
||||
[type=radio] + img {
|
||||
cursor: pointer; }
|
||||
|
||||
/* CHECKED STYLES */
|
||||
[type=radio]:checked + img {
|
||||
outline: 2px solid #2b5291; }
|
||||
|
||||
/*# sourceMappingURL=styles.css.map */
|
||||
|
|
|
@ -19,6 +19,11 @@ $font-stack: 'Hanson-Bold','Arial',sans-serif;
|
|||
font-family: "Hanson-Bold";
|
||||
}
|
||||
|
||||
@font-face {
|
||||
src: url("./fonts/WildYouth-Regular.otf");
|
||||
font-family: "WildYouth";
|
||||
}
|
||||
|
||||
@font-face {
|
||||
src: url("./fonts/FuturaPTMedium.otf");
|
||||
font-family: "Futura";
|
||||
|
@ -234,8 +239,27 @@ label {
|
|||
|
||||
.hi {
|
||||
color: $green;
|
||||
font-family: "WildYouth", $font-stack;
|
||||
}
|
||||
|
||||
.lo {
|
||||
color: $red;
|
||||
font-family: "WildYouth", $font-stack;
|
||||
}
|
||||
|
||||
[type=radio] {
|
||||
position: absolute;
|
||||
opacity: 0;
|
||||
width: 0;
|
||||
height: 0;
|
||||
}
|
||||
|
||||
/* IMAGE STYLES */
|
||||
[type=radio] + img {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
/* CHECKED STYLES */
|
||||
[type=radio]:checked + img {
|
||||
outline: 2px solid $text;
|
||||
}
|
Loading…
Reference in New Issue
Block a user