diff options
-rw-r--r-- | apps/core/admin.py | 3 | ||||
-rw-r--r-- | apps/issues/admin.py | 6 | ||||
-rw-r--r-- | apps/issues/models.py | 6 | ||||
-rw-r--r-- | apps/issues/views.py | 46 | ||||
-rw-r--r-- | motor/settings.py | 2 | ||||
-rw-r--r-- | motor/urls.py | 13 | ||||
-rw-r--r-- | templates/issues/customer.html | 13 | ||||
-rw-r--r-- | templates/issues/device.html | 7 | ||||
-rw-r--r-- | templates/issues/index.html | 6 | ||||
-rw-r--r-- | templates/issues/thanks.html | 0 | ||||
-rw-r--r-- | templates/issues/warranty.html | 28 | ||||
-rw-r--r-- | templates/issues/welcome.html | 15 |
12 files changed, 130 insertions, 15 deletions
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()) diff --git a/motor/settings.py b/motor/settings.py index 612efee..c752b59 100644 --- a/motor/settings.py +++ b/motor/settings.py @@ -127,7 +127,7 @@ INSTALLED_APPS = ( 'django.contrib.messages', 'django.contrib.staticfiles', # Uncomment the next line to enable the admin: - #'django.contrib.admin', + 'django.contrib.admin', # Uncomment the next line to enable admin documentation: # 'django.contrib.admindocs', 'bootstrap3', diff --git a/motor/urls.py b/motor/urls.py index 9ec4845..394a7fd 100644 --- a/motor/urls.py +++ b/motor/urls.py @@ -3,11 +3,18 @@ from django.views.generic import TemplateView from apps.core.views import * from apps.issues.views import * +from django.contrib import admin +admin.autodiscover() + urlpatterns = patterns( '', #url(r'^$', 'docs.views.index', name='docs-index'), - url(r'^$', list_issues, name='issues-index'), - url(r'^(\d+)/$', list_issues, name='issues-index'), + url(r'^$', welcome, name='issues-welcome'), + url(r'^issues/(\d+)/$', list_issues, name='issues-index'), + url(r'^issues/device/$', choose_device, name='issues-choose_device'), + url(r'^issues/device/([A-Z]+)/$', choose_device, name='issues-choose_device'), + url(r'^issues/warranty/$', warranty, name='issues-warranty'), + url(r'^issues/customer/$', customer, name='issues-customer'), url(r'^manage/$', LoginView.as_view(), name='core-login'), url(r'^manage/logout/$', logout, name='core-logout'), url(r'^manage/docs/$', ArticleListView.as_view(), name='core-list_docs'), @@ -23,6 +30,6 @@ urlpatterns = patterns( url(r'^manage/issues/add/$', IssueCreateView.as_view(), name='issues-add_issue'), url(r'^manage/issues/(?P<pk>\d+)/$', IssueEditView.as_view(), name='issues-edit_issue'), url(r'^terms/$', TemplateView.as_view(template_name="terms.html"), {'title': 'ServoApp Terms of Service'}), - #(r'^admin/', include(admin.site.urls)), + (r'^admin/', include(admin.site.urls)), #url(r'^([\w\-]+)/$', 'docs.views.view_article', name='docs-view'), ) diff --git a/templates/issues/customer.html b/templates/issues/customer.html new file mode 100644 index 0000000..a47ba32 --- /dev/null +++ b/templates/issues/customer.html @@ -0,0 +1,13 @@ +{% extends "issues/index.html" %} +{% load bootstrap3 %} +{% load i18n %} + +{% block main %} + <form method="post" action=""> + {% csrf_token %} + {% bootstrap_form form %} + {% buttons %} + <button type="submit" class="btn btn-primary">{% trans "Submit" %}</button> + {% endbuttons %} + </form> +{% endblock main %} diff --git a/templates/issues/device.html b/templates/issues/device.html new file mode 100644 index 0000000..def5b8b --- /dev/null +++ b/templates/issues/device.html @@ -0,0 +1,7 @@ +{% extends "issues/index.html" %} + +{% block main %} + {% for k, v in models.items %} + <a href="{% url 'issues-choose_device' k %}">{{ v.name }}</a> + {% endfor %} +{% endblock main %} diff --git a/templates/issues/index.html b/templates/issues/index.html index 15b341f..70a84e7 100644 --- a/templates/issues/index.html +++ b/templates/issues/index.html @@ -14,11 +14,11 @@ <script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script> <![endif]--> </head> - <body style="padding-top:50px"> + <body> <div class="container-fluid"> {% block main %} - <h2>{{ question }}</h2> - {% for i in choices %} + <h2>{{ question.question }}</h2> + {% for i in question.choice_set.all %} <a class="btn btn-default" href="{% url 'issues-index' i.pk %}">{{ i.choice }}</a> {% endfor %} <blockquote>{{ dump }}</blockquote> diff --git a/templates/issues/thanks.html b/templates/issues/thanks.html new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/templates/issues/thanks.html diff --git a/templates/issues/warranty.html b/templates/issues/warranty.html new file mode 100644 index 0000000..b944ea5 --- /dev/null +++ b/templates/issues/warranty.html @@ -0,0 +1,28 @@ +{% extends "issues/index.html" %} +{% load i18n %} + +{% block main %} + <div class="row"> + <div class="col-md-5"> + <img src="http://service.info.apple.com/parts/service_parts/products/imac_27_mid2011.jpg" alt="iMac (27-inch, Mid 2011)" title="iMac (27-inch, Mid 2011)"> + </div> + <div class="col-md-7"> + <h3>iMac (27-inch, Mid 2011)</h3> + <dl class="dl-horizontal"> + <dt>{% trans "Warranty" %}</dt> + <dd>Out Of Warranty (No Coverage)</dd> + <dt>{% trans "Purchased" %}</dt> + <dd>2.6.2011, Sweden</dd> + <dt>{% trans "Serial Number" %}</dt> + <dd>DGKFL06JDHJP</dd> + <dt>{% trans "Configuration" %}</dt> + <dd>IMAC 27"/2.7QC/2X2GB/1TB/6770M</dd> + </dl> + </div> + </div> + <div class="row"> + <div class="col-md-12"> + <a class="btn btn-default" href="{% url 'issues-index' 0 %}">{% trans "Continue" %}</a> + </div> + </div> +{% endblock main %} diff --git a/templates/issues/welcome.html b/templates/issues/welcome.html new file mode 100644 index 0000000..38c0dcd --- /dev/null +++ b/templates/issues/welcome.html @@ -0,0 +1,15 @@ +{% extends "issues/index.html" %} +{% load i18n %} + +{% block main %} + <form method="post" action="{% url 'issues-warranty' %}"> + {% csrf_token %} + <div class="form-group"> + <label for="exampleInputEmail1">Serial Number</label> + <input type="email" class="form-control" id="exampleInputEmail1" placeholder="{% trans "Serial Number" %}" value="DGKFL06JDHJP"> + </div> + <div class="form-group"> + <a href="{% url 'issues-choose_device' %}" class="btn btn-default">{% trans "Skip" %}</a> + </div> + </form> +{% endblock main %} |