diff --git a/ttadmin/help/admin.py b/ttadmin/help/admin.py new file mode 100644 index 0000000..e12a0a5 --- /dev/null +++ b/ttadmin/help/admin.py @@ -0,0 +1,6 @@ +from django.contrib import admin +from .models import Ticket + +@admin.register(Ticket) +class TicketAdmin(admin.ModelAdmin): + pass diff --git a/ttadmin/help/forms.py b/ttadmin/help/forms.py index 670fadb..a043fbb 100644 --- a/ttadmin/help/forms.py +++ b/ttadmin/help/forms.py @@ -3,14 +3,7 @@ from django.forms import Form, CharField, EmailField, Textarea, ChoiceField from common.forms import CaptchaField -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'), -) +from .models import ISSUE_TYPE_CHOICES def validate_issue_text(text): if len(text) == 0: diff --git a/ttadmin/help/migrations/0001_initial.py b/ttadmin/help/migrations/0001_initial.py new file mode 100644 index 0000000..09ef2a3 --- /dev/null +++ b/ttadmin/help/migrations/0001_initial.py @@ -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()), + ], + ), + ] diff --git a/ttadmin/help/migrations/__init__.py b/ttadmin/help/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/ttadmin/help/models.py b/ttadmin/help/models.py index 1564ad2..4b6c4f3 100644 --- a/ttadmin/help/models.py +++ b/ttadmin/help/models.py @@ -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): - 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) diff --git a/ttadmin/help/templates/help/ticket_submitted.html b/ttadmin/help/templates/help/ticket_submitted.html new file mode 100644 index 0000000..10a300d --- /dev/null +++ b/ttadmin/help/templates/help/ticket_submitted.html @@ -0,0 +1,17 @@ + + + + thanks for the ticket! + + + + +

thanks for the ticket <3

+

a human will respond soon! hopefully within a day, but possibly in 3-4 days.

+

head home...

+ + diff --git a/ttadmin/help/urls.py b/ttadmin/help/urls.py index b3a375e..ce2478a 100644 --- a/ttadmin/help/urls.py +++ b/ttadmin/help/urls.py @@ -1,8 +1,9 @@ from django.conf.urls import url -from .views import TicketView +from .views import TicketView, TicketSubmittedView app_name = 'help' urlpatterns = [ url(r'^tickets/?$', TicketView.as_view(), name='tickets'), + url(r'^tickets/submitted/?$', TicketSubmittedView.as_view(), name='ticket_submitted'), ] diff --git a/ttadmin/help/views.py b/ttadmin/help/views.py index cba1270..0c510b6 100644 --- a/ttadmin/help/views.py +++ b/ttadmin/help/views.py @@ -1,3 +1,5 @@ +from django.shortcuts import redirect +from django.views.generic import TemplateView from django.views.generic.edit import FormView from .forms import TicketForm @@ -8,5 +10,9 @@ class TicketView(FormView): template_name = 'help/tickets.html' def form_valid(self, form): - # TODO - pass + del form.cleaned_data['captcha'] + t = Ticket.objects.create(**form.cleaned_data) + return redirect('help:ticket_submitted') + +class TicketSubmittedView(TemplateView): + template_name = 'help/ticket_submitted.html' diff --git a/ttadmin/users/forms.py b/ttadmin/users/forms.py index 2f6fa1f..2efeead 100644 --- a/ttadmin/users/forms.py +++ b/ttadmin/users/forms.py @@ -80,5 +80,3 @@ class TownieForm(Form): if self.errors: raise ValidationError('oops, looks like there were some problems below.') return result - -