tickets backend
parent
404944572b
commit
7516e6736c
|
@ -0,0 +1,6 @@
|
|||
from django.contrib import admin
|
||||
from .models import Ticket
|
||||
|
||||
@admin.register(Ticket)
|
||||
class TicketAdmin(admin.ModelAdmin):
|
||||
pass
|
|
@ -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:
|
||||
|
|
|
@ -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()),
|
||||
],
|
||||
),
|
||||
]
|
|
@ -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)
|
||||
|
|
|
@ -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>
|
|
@ -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'),
|
||||
]
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -80,5 +80,3 @@ class TownieForm(Form):
|
|||
if self.errors:
|
||||
raise ValidationError('oops, looks like there were some problems below.')
|
||||
return result
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue