tickets backend

pull/1/head
nathaniel smith 2016-12-18 23:20:48 -08:00
parent 404944572b
commit 7516e6736c
9 changed files with 81 additions and 15 deletions

View File

@ -0,0 +1,6 @@
from django.contrib import admin
from .models import Ticket
@admin.register(Ticket)
class TicketAdmin(admin.ModelAdmin):
pass

View File

@ -3,14 +3,7 @@ from django.forms import Form, CharField, EmailField, Textarea, ChoiceField
from common.forms import CaptchaField from common.forms import CaptchaField
ISSUE_TYPE_CHOICES = ( from .models import ISSUE_TYPE_CHOICES
('logging_in', 'help logging in'),
('concern_site', 'concern about the site'),
('concern_user', 'concern about another user'),
('package', 'install a package'),
('question', 'just a question',),
('other', 'something else'),
)
def validate_issue_text(text): def validate_issue_text(text):
if len(text) == 0: if len(text) == 0:

View File

@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.2 on 2016-12-19 06:40
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Ticket',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.TextField()),
('email', models.EmailField(max_length=254)),
('issue_type', models.CharField(choices=[('logging_in', 'help logging in'), ('concern_site', 'concern about the site'), ('concern_user', 'concern about another user'), ('package', 'install a package'), ('question', 'just a question'), ('other', 'something else')], max_length=50)),
('issue_text', models.TextField()),
],
),
]

View File

@ -1,4 +1,23 @@
from django.db.models import Model from django.db.models import Model, TextField, EmailField, CharField
ISSUE_TYPE_CHOICES = (
('logging_in', 'help logging in'),
('concern_site', 'concern about the site'),
('concern_user', 'concern about another user'),
('package', 'install a package'),
('question', 'just a question',),
('other', 'something else'),
)
class Ticket(Model): class Ticket(Model):
pass name = TextField(blank=False, null=False)
email = EmailField(blank=False, null=False)
issue_type = CharField(choices=ISSUE_TYPE_CHOICES,
blank=False,
null=False,
max_length=50)
issue_text = TextField(blank=False, null=False)
def __str__(self):
return '{} from {}'.format(self.issue_type, self.name)

View File

@ -0,0 +1,17 @@
<!DOCTYPE html>
<html>
<head>
<title>thanks for the ticket!</title>
<meta charset="UTF-8">
<style type="text/css">
body {
background-color: #E0B0FF;
}
</style>
</head>
<body>
<h1>thanks for the ticket <3</h1>
<p>a human will respond soon! hopefully within a day, but possibly in 3-4 days.</p>
<p>head <a href="https://tilde.town">home...</a></p>
</body>
</html>

View File

@ -1,8 +1,9 @@
from django.conf.urls import url from django.conf.urls import url
from .views import TicketView from .views import TicketView, TicketSubmittedView
app_name = 'help' app_name = 'help'
urlpatterns = [ urlpatterns = [
url(r'^tickets/?$', TicketView.as_view(), name='tickets'), url(r'^tickets/?$', TicketView.as_view(), name='tickets'),
url(r'^tickets/submitted/?$', TicketSubmittedView.as_view(), name='ticket_submitted'),
] ]

View File

@ -1,3 +1,5 @@
from django.shortcuts import redirect
from django.views.generic import TemplateView
from django.views.generic.edit import FormView from django.views.generic.edit import FormView
from .forms import TicketForm from .forms import TicketForm
@ -8,5 +10,9 @@ class TicketView(FormView):
template_name = 'help/tickets.html' template_name = 'help/tickets.html'
def form_valid(self, form): def form_valid(self, form):
# TODO del form.cleaned_data['captcha']
pass t = Ticket.objects.create(**form.cleaned_data)
return redirect('help:ticket_submitted')
class TicketSubmittedView(TemplateView):
template_name = 'help/ticket_submitted.html'

View File

@ -80,5 +80,3 @@ class TownieForm(Form):
if self.errors: if self.errors:
raise ValidationError('oops, looks like there were some problems below.') raise ValidationError('oops, looks like there were some problems below.')
return result return result