Adding feedback functionality.
This commit is contained in:
parent
d605abcb40
commit
2d58695ee4
|
@ -48,6 +48,7 @@ INSTALLED_APPS = [
|
||||||
'events',
|
'events',
|
||||||
'rideshare',
|
'rideshare',
|
||||||
'tokens',
|
'tokens',
|
||||||
|
'feedback',
|
||||||
|
|
||||||
'allauth',
|
'allauth',
|
||||||
'allauth.account',
|
'allauth.account',
|
||||||
|
|
|
@ -2,15 +2,14 @@ from allauth.account.views import (
|
||||||
LoginView,
|
LoginView,
|
||||||
LogoutView,
|
LogoutView,
|
||||||
)
|
)
|
||||||
from django.conf import settings
|
|
||||||
from django.urls import include, path
|
from django.urls import include, path
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from camps.views import *
|
from camps.views import *
|
||||||
|
from feedback.views import FeedbackCreate
|
||||||
from info.views import *
|
from info.views import *
|
||||||
from villages.views import *
|
from villages.views import *
|
||||||
from program.views import *
|
from program.views import *
|
||||||
from sponsors.views import *
|
from sponsors.views import *
|
||||||
from teams.views import *
|
|
||||||
from people.views import *
|
from people.views import *
|
||||||
from bar.views import MenuView
|
from bar.views import MenuView
|
||||||
|
|
||||||
|
@ -197,6 +196,12 @@ urlpatterns = [
|
||||||
include('backoffice.urls', namespace='backoffice')
|
include('backoffice.urls', namespace='backoffice')
|
||||||
),
|
),
|
||||||
|
|
||||||
|
path(
|
||||||
|
'feedback/',
|
||||||
|
FeedbackCreate.as_view(),
|
||||||
|
name='feedback'
|
||||||
|
),
|
||||||
|
|
||||||
])
|
])
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
|
|
0
src/feedback/__init__.py
Normal file
0
src/feedback/__init__.py
Normal file
8
src/feedback/admin.py
Normal file
8
src/feedback/admin.py
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
from django.contrib import admin
|
||||||
|
|
||||||
|
from .models import Feedback
|
||||||
|
|
||||||
|
|
||||||
|
@admin.register(Feedback)
|
||||||
|
class FeedbackAdmin(admin.ModelAdmin):
|
||||||
|
pass
|
5
src/feedback/apps.py
Normal file
5
src/feedback/apps.py
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
from django.apps import AppConfig
|
||||||
|
|
||||||
|
|
||||||
|
class FeedbackConfig(AppConfig):
|
||||||
|
name = 'feedback'
|
31
src/feedback/migrations/0001_initial.py
Normal file
31
src/feedback/migrations/0001_initial.py
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
# Generated by Django 2.1 on 2018-08-20 13:13
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
import uuid
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
initial = True
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Feedback',
|
||||||
|
fields=[
|
||||||
|
('uuid', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
|
||||||
|
('created', models.DateTimeField(auto_now_add=True)),
|
||||||
|
('updated', models.DateTimeField(auto_now=True)),
|
||||||
|
('feedback', models.TextField()),
|
||||||
|
('user', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to=settings.AUTH_USER_MODEL)),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'abstract': False,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
]
|
0
src/feedback/migrations/__init__.py
Normal file
0
src/feedback/migrations/__init__.py
Normal file
8
src/feedback/models.py
Normal file
8
src/feedback/models.py
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
from django.db import models
|
||||||
|
|
||||||
|
from utils.models import UUIDModel, CreatedUpdatedModel
|
||||||
|
|
||||||
|
|
||||||
|
class Feedback(UUIDModel, CreatedUpdatedModel):
|
||||||
|
user = models.ForeignKey('auth.User', on_delete=models.PROTECT)
|
||||||
|
feedback = models.TextField()
|
28
src/feedback/templates/feedback/feedback_form.html
Normal file
28
src/feedback/templates/feedback/feedback_form.html
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
{% extends "base.html" %}
|
||||||
|
{% load commonmark %}
|
||||||
|
{% load bootstrap3 %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
<div class="page-header">
|
||||||
|
<h1>Feedback <small>Help us make BornHack even better!</small></h1>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-12">
|
||||||
|
<p>
|
||||||
|
BornHack can always improve, but we need your feedback to know how. So write you thoughts on what was good and what wasn't, it's highly appreciated!
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-12">
|
||||||
|
<form method="POST">
|
||||||
|
{% csrf_token %}
|
||||||
|
{% bootstrap_form form %}
|
||||||
|
<button type="submit" class="btn btn-success pull-right">
|
||||||
|
Send feedback
|
||||||
|
</button>
|
||||||
|
<span class="clearfix"></span>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% endblock %}
|
3
src/feedback/tests.py
Normal file
3
src/feedback/tests.py
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
from django.test import TestCase
|
||||||
|
|
||||||
|
# Create your tests here.
|
31
src/feedback/views.py
Normal file
31
src/feedback/views.py
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
from django.contrib import messages
|
||||||
|
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||||
|
from django.http import HttpResponseRedirect
|
||||||
|
from django.urls import reverse
|
||||||
|
from django.views.generic import CreateView
|
||||||
|
|
||||||
|
from camps.mixins import CampViewMixin
|
||||||
|
from tokens.models import Token
|
||||||
|
from .models import Feedback
|
||||||
|
|
||||||
|
|
||||||
|
class FeedbackCreate(LoginRequiredMixin, CampViewMixin, CreateView):
|
||||||
|
model = Feedback
|
||||||
|
fields = ['feedback']
|
||||||
|
|
||||||
|
def form_valid(self, form):
|
||||||
|
feedback = form.save(commit=False)
|
||||||
|
feedback.user = self.request.user
|
||||||
|
thanks_message = "Thank you! Your feedback is highly appreciated!"
|
||||||
|
try:
|
||||||
|
token = Token.objects.get(
|
||||||
|
camp=self.camp,
|
||||||
|
description="Feedback thanks"
|
||||||
|
)
|
||||||
|
thanks_message += " And for your efforts, here is a token: {}".format(token.token)
|
||||||
|
except Token.DoesNotExist:
|
||||||
|
pass
|
||||||
|
|
||||||
|
messages.success(self.request, thanks_message)
|
||||||
|
|
||||||
|
return HttpResponseRedirect(reverse("feedback", kwargs={"camp_slug": self.camp.slug}))
|
|
@ -7,6 +7,7 @@
|
||||||
<a class="btn {% menubuttonclass 'teams' %}" href="{% url 'teams:list' camp_slug=camp.slug %}">Teams</a>
|
<a class="btn {% menubuttonclass 'teams' %}" href="{% url 'teams:list' camp_slug=camp.slug %}">Teams</a>
|
||||||
{% if request.user.is_authenticated %}
|
{% if request.user.is_authenticated %}
|
||||||
<a class="btn {% menubuttonclass 'rideshare' %}" href="{% url 'rideshare:list' camp_slug=camp.slug %}">Rideshare</a>
|
<a class="btn {% menubuttonclass 'rideshare' %}" href="{% url 'rideshare:list' camp_slug=camp.slug %}">Rideshare</a>
|
||||||
|
<a class="btn {% menubuttonclass 'feedback' %}" href="{% url 'feedback' camp_slug=camp.slug %}">Feedback</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if request.user.is_staff or perms.camps.infodesk_permission %}
|
{% if request.user.is_staff or perms.camps.infodesk_permission %}
|
||||||
<a class="btn {% menubuttonclass 'backoffice' %}" href="{% url 'backoffice:index' camp_slug=camp.slug %}">Backoffice</a>
|
<a class="btn {% menubuttonclass 'backoffice' %}" href="{% url 'backoffice:index' camp_slug=camp.slug %}">Backoffice</a>
|
||||||
|
|
Loading…
Reference in a new issue