aboutsummaryrefslogtreecommitdiffstats
path: root/apps/issues
diff options
context:
space:
mode:
Diffstat (limited to 'apps/issues')
-rw-r--r--apps/issues/models.py8
-rw-r--r--apps/issues/views.py77
2 files changed, 73 insertions, 12 deletions
diff --git a/apps/issues/models.py b/apps/issues/models.py
index f2e162d..2306199 100644
--- a/apps/issues/models.py
+++ b/apps/issues/models.py
@@ -7,6 +7,7 @@ from apps.checkin.models import ServiceOrder
class Issue(models.Model):
sp = models.ForeignKey(ServiceProvider)
+ keywords = models.TextField(default='')
description = models.CharField(max_length=256, default=_('No power'))
def __unicode__(self):
@@ -19,8 +20,15 @@ class Issue(models.Model):
class Question(models.Model):
issue = models.ForeignKey(Issue)
question = models.CharField(max_length=256)
+ description = models.TextField(default='')
required = models.BooleanField(default=True)
+ def next(self):
+ return Question.objects.get(issue=self.issue, pk__gt=self.pk)
+
+ def prev(self):
+ return Question.objects.get(issue=self.issue, pk__lt=self.pk)
+
def __unicode__(self):
return self.question
diff --git a/apps/issues/views.py b/apps/issues/views.py
index 374c74e..6bc6d75 100644
--- a/apps/issues/views.py
+++ b/apps/issues/views.py
@@ -1,20 +1,37 @@
from django import forms
from gsxws import products
-from django.shortcuts import render
+from django.shortcuts import render, redirect
from django.views.generic.list import ListView
+from django.utils.translation import ugettext as _
from django.views.generic.edit import FormView, CreateView, UpdateView
from apps.core.views import DefaultEditView, DefaultListView
from apps.issues.models import Issue, Question, Choice
+class WarrantyForm(forms.Form):
+ sn = forms.CharField(
+ required=False,
+ initial='DGKFL06JDHJP',
+ label=_('Serial number')
+ )
+
+
+class IssueForm(forms.Form):
+ description = forms.CharField(
+ required=False,
+ widget=forms.Textarea()
+ )
+ attachment = forms.FileField(required=False)
+
+
class CustomerForm(forms.Form):
- fname = forms.CharField()
- lname = forms.CharField()
- email = forms.EmailField()
- phone = forms.CharField()
- address = forms.CharField()
- city = forms.CharField()
- postal_code = forms.CharField()
+ fname = forms.CharField(label=_('First name'), initial='Filipp')
+ lname = forms.CharField(label=_('Last name'), initial='Lepalaan')
+ email = forms.EmailField(label=_('Email'), initial='filipp@fps.ee')
+ phone = forms.CharField(label=_('Phone number'), initial='451202717')
+ address = forms.CharField(label=_('Address'), initial='Kustaankatu 2 C 96')
+ city = forms.CharField(label=_('City'), initial='Helsinki')
+ postal_code = forms.CharField(label=_('Postal code'), initial='00500')
class IssueListView(DefaultListView):
@@ -32,28 +49,64 @@ class IssueEditView(DefaultEditView):
def welcome(request):
+ form = WarrantyForm()
return render(request, "issues/welcome.html", locals())
+def details(request, device=None):
+ form = IssueForm()
+
+ if request.method == "POST":
+ request.session['details'] = request.POST.get('details')
+ return redirect(list_issues)
+
+ return render(request, "issues/details.html", locals())
+
+
def list_issues(request, idx=None):
questions = Question.objects.filter(issue__sp_id=1)
- question = questions[0]
- dump = {}
- return render(request, "issues/index.html", locals())
+
+ if idx is None:
+ question = questions[0]
+ request.session['choices'] = []
+ else:
+ choice = Choice.objects.get(pk=idx)
+ current = questions.get(choice=idx)
+ current.choice = choice
+ request.session['choices'].append(current)
+ try:
+ question = current.next()
+ except Question.DoesNotExist:
+ return redirect(customer)
+
+ dump = request.session.get('choices')
+ return render(request, "issues/question.html", locals())
def choose_device(request, device=None):
models = products.models()
- return render(request, "issues/device.html", locals())
+ tpl = "issues/%s.html" % (device or 'device')
+ return render(request, tpl, locals())
def warranty(request):
return render(request, "issues/warranty.html", locals())
+def thanks(request):
+ return render(request, "issues/thanks.html", locals())
+
+
def customer(request):
form = CustomerForm()
if request.method == "POST":
form = CustomerForm(request.POST)
+ if form.is_valid():
+ return redirect(thanks)
return render(request, "issues/customer.html", locals())
+
+
+def restart(request):
+ request.session = None
+ return redirect(welcome)