From 8782fbe4766dc57e517eec622879d672d6d68378 Mon Sep 17 00:00:00 2001 From: Filipp Lepalaan Date: Tue, 19 Nov 2013 16:44:56 +0200 Subject: switch --- apps/core/admin.py | 3 ++- apps/issues/admin.py | 6 ++++++ apps/issues/models.py | 6 ++++++ apps/issues/views.py | 46 +++++++++++++++++++++++++++++++++++++++------- 4 files changed, 53 insertions(+), 8 deletions(-) create mode 100644 apps/issues/admin.py (limited to 'apps') diff --git a/apps/core/admin.py b/apps/core/admin.py index 8c38f3f..35ea185 100644 --- a/apps/core/admin.py +++ b/apps/core/admin.py @@ -1,3 +1,4 @@ from django.contrib import admin +from apps.core.models import ServiceProvider -# Register your models here. +admin.site.register(ServiceProvider) 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()) -- cgit v1.2.3