aboutsummaryrefslogtreecommitdiffstats
path: root/apps/issues
diff options
context:
space:
mode:
authorFilipp Lepalaan <f@230.to>2013-11-19 16:44:56 +0200
committerFilipp Lepalaan <f@230.to>2013-11-19 16:44:56 +0200
commit8782fbe4766dc57e517eec622879d672d6d68378 (patch)
treebec35a5bbddedba04c0a1ac34e105d6da7dc5ab4 /apps/issues
parent1c760af665e388f921b770d9c5c3ded1fc11f626 (diff)
downloadmotor.old-8782fbe4766dc57e517eec622879d672d6d68378.tar.gz
motor.old-8782fbe4766dc57e517eec622879d672d6d68378.tar.bz2
motor.old-8782fbe4766dc57e517eec622879d672d6d68378.zip
switch
Diffstat (limited to 'apps/issues')
-rw-r--r--apps/issues/admin.py6
-rw-r--r--apps/issues/models.py6
-rw-r--r--apps/issues/views.py46
3 files changed, 51 insertions, 7 deletions
diff --git a/apps/issues/admin.py b/apps/issues/admin.py
new file mode 100644
index 0000000..5d91777
--- /dev/null
+++ b/apps/issues/admin.py
@@ -0,0 +1,6 @@
+from django.contrib import admin
+from apps.issues.models import Issue, Question, Choice
+
+admin.site.register(Issue)
+admin.site.register(Question)
+admin.site.register(Choice)
diff --git a/apps/issues/models.py b/apps/issues/models.py
index bcded0c..f2e162d 100644
--- a/apps/issues/models.py
+++ b/apps/issues/models.py
@@ -21,11 +21,17 @@ class Question(models.Model):
question = models.CharField(max_length=256)
required = models.BooleanField(default=True)
+ def __unicode__(self):
+ return self.question
+
class Choice(models.Model):
question = models.ForeignKey(Question)
choice = models.CharField(max_length=256)
+ def __unicode__(self):
+ return self.choice
+
class Answer(models.Model):
choice = models.ForeignKey(Choice)
diff --git a/apps/issues/views.py b/apps/issues/views.py
index 565bc6e..374c74e 100644
--- a/apps/issues/views.py
+++ b/apps/issues/views.py
@@ -1,9 +1,20 @@
-import json
+from django import forms
+from gsxws import products
from django.shortcuts import render
from django.views.generic.list import ListView
from django.views.generic.edit import FormView, CreateView, UpdateView
from apps.core.views import DefaultEditView, DefaultListView
-from apps.issues.models import Issue
+from apps.issues.models import Issue, Question, Choice
+
+
+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()
class IssueListView(DefaultListView):
@@ -20,8 +31,29 @@ class IssueEditView(DefaultEditView):
model = Issue
-def list_issues(request, idx=0):
- fh = open('fixtures.json', 'r')
- data = json.loads(fh.read())
- question = data['questions'][int(idx)]
- return render(request, "issues/index.html", question)
+def welcome(request):
+ return render(request, "issues/welcome.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())
+
+
+def choose_device(request, device=None):
+ models = products.models()
+ return render(request, "issues/device.html", locals())
+
+
+def warranty(request):
+ return render(request, "issues/warranty.html", locals())
+
+
+def customer(request):
+ form = CustomerForm()
+ if request.method == "POST":
+ form = CustomerForm(request.POST)
+
+ return render(request, "issues/customer.html", locals())