From 1bbfb4a44d42aca151f60a614ebeffbd44ef6e4d Mon Sep 17 00:00:00 2001 From: Filipp Lepalaan Date: Wed, 27 Nov 2013 13:35:55 +0200 Subject: A bunch of fixes --- TODO.rst | 3 ++ apps/docs/admin.py | 2 +- apps/issues/models.py | 8 ++++ apps/issues/views.py | 77 +++++++++++++++++++++++++----- motor/urls.py | 12 +++-- static/img/products/display.png | Bin 0 -> 43144 bytes static/img/products/done.png | Bin 0 -> 26604 bytes static/img/products/imac.jpg | Bin 0 -> 6505 bytes static/img/products/imac.png | Bin 0 -> 62993 bytes static/img/products/ipad.png | Bin 0 -> 24963 bytes static/img/products/iphone.png | Bin 0 -> 23582 bytes static/img/products/ipod.png | Bin 0 -> 21554 bytes static/img/products/ipod_classic_2011.jpg | Bin 0 -> 2742 bytes static/img/products/ipod_nano_2011.jpg | Bin 0 -> 4472 bytes static/img/products/ipod_nano_7thgen.jpg | Bin 0 -> 2871 bytes static/img/products/ipod_shuffle_2012.jpg | Bin 0 -> 3957 bytes static/img/products/ipodnano2009-72.png | Bin 0 -> 4995 bytes static/img/products/ipodtouch.png | Bin 0 -> 10073 bytes static/img/products/keyboard_mouse.jpg | Bin 0 -> 7969 bytes static/img/products/mac.png | Bin 0 -> 35119 bytes static/img/products/macbook.png | Bin 0 -> 73654 bytes static/img/products/macbookair.png | Bin 0 -> 80978 bytes static/img/products/macbookpro.png | Bin 0 -> 186645 bytes static/img/products/macmini.png | Bin 0 -> 38111 bytes static/img/products/macpro.jpg | Bin 0 -> 15079 bytes static/img/products/other.png | Bin 0 -> 20686 bytes static/img/products/wifi.png | Bin 0 -> 35930 bytes templates/issues/customer.html | 10 +++- templates/issues/details.html | 15 ++++++ templates/issues/device.html | 44 +++++++++++++++-- templates/issues/index.html | 41 +++++++++++----- templates/issues/ipad.html | 0 templates/issues/iphone.html | 1 + templates/issues/ipod.html | 20 ++++++++ templates/issues/mac.html | 49 +++++++++++++++++++ templates/issues/other.html | 29 +++++++++++ templates/issues/question.html | 12 +++++ templates/issues/thanks.html | 18 +++++++ templates/issues/warranty.html | 35 +++++++++----- templates/issues/welcome.html | 25 ++++++---- 40 files changed, 346 insertions(+), 55 deletions(-) create mode 100644 TODO.rst create mode 100644 static/img/products/display.png create mode 100755 static/img/products/done.png create mode 100644 static/img/products/imac.jpg create mode 100644 static/img/products/imac.png create mode 100644 static/img/products/ipad.png create mode 100644 static/img/products/iphone.png create mode 100644 static/img/products/ipod.png create mode 100644 static/img/products/ipod_classic_2011.jpg create mode 100644 static/img/products/ipod_nano_2011.jpg create mode 100644 static/img/products/ipod_nano_7thgen.jpg create mode 100644 static/img/products/ipod_shuffle_2012.jpg create mode 100644 static/img/products/ipodnano2009-72.png create mode 100644 static/img/products/ipodtouch.png create mode 100644 static/img/products/keyboard_mouse.jpg create mode 100644 static/img/products/mac.png create mode 100644 static/img/products/macbook.png create mode 100644 static/img/products/macbookair.png create mode 100644 static/img/products/macbookpro.png create mode 100644 static/img/products/macmini.png create mode 100644 static/img/products/macpro.jpg create mode 100644 static/img/products/other.png create mode 100644 static/img/products/wifi.png create mode 100644 templates/issues/details.html create mode 100644 templates/issues/ipad.html create mode 100644 templates/issues/iphone.html create mode 100644 templates/issues/ipod.html create mode 100644 templates/issues/mac.html create mode 100644 templates/issues/other.html create mode 100644 templates/issues/question.html diff --git a/TODO.rst b/TODO.rst new file mode 100644 index 0000000..57d8db9 --- /dev/null +++ b/TODO.rst @@ -0,0 +1,3 @@ +- tie checkin to a service location +- add user menu to checkin (list location's users) +- lookup case status with order number diff --git a/apps/docs/admin.py b/apps/docs/admin.py index 4902ccc..8ab5731 100644 --- a/apps/docs/admin.py +++ b/apps/docs/admin.py @@ -1,5 +1,5 @@ from django.contrib import admin -from docs.models import Article, Image +from apps.docs.models import Article, Image admin.site.register(Article) admin.site.register(Image) 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) diff --git a/motor/urls.py b/motor/urls.py index 394a7fd..85ec915 100644 --- a/motor/urls.py +++ b/motor/urls.py @@ -10,9 +10,12 @@ urlpatterns = patterns( '', #url(r'^$', 'docs.views.index', name='docs-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/thanks/$', thanks, name='issues-thanks'), + url(r'^issues/notes/$', details, name='issues-details'), + url(r'^issues/notes/([a-z]+)/$', details, name='issues-details'), + url(r'^issues/(\d+)?/$', list_issues, name='issues-index'), + url(r'^issues/devices/$', choose_device, name='issues-choose_device'), + url(r'^issues/devices/([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'), @@ -29,7 +32,8 @@ urlpatterns = patterns( url(r'^manage/issues/$', IssueListView.as_view(), name='issues-list_issues'), url(r'^manage/issues/add/$', IssueCreateView.as_view(), name='issues-add_issue'), url(r'^manage/issues/(?P\d+)/$', IssueEditView.as_view(), name='issues-edit_issue'), - url(r'^terms/$', TemplateView.as_view(template_name="terms.html"), {'title': 'ServoApp Terms of Service'}), + url(r'^terms/$', TemplateView.as_view(template_name="terms.html"), + {'title': 'ServoApp Terms of Service'}), (r'^admin/', include(admin.site.urls)), #url(r'^([\w\-]+)/$', 'docs.views.view_article', name='docs-view'), ) diff --git a/static/img/products/display.png b/static/img/products/display.png new file mode 100644 index 0000000..4dd759b Binary files /dev/null and b/static/img/products/display.png differ diff --git a/static/img/products/done.png b/static/img/products/done.png new file mode 100755 index 0000000..a43ff28 Binary files /dev/null and b/static/img/products/done.png differ diff --git a/static/img/products/imac.jpg b/static/img/products/imac.jpg new file mode 100644 index 0000000..f0824f6 Binary files /dev/null and b/static/img/products/imac.jpg differ diff --git a/static/img/products/imac.png b/static/img/products/imac.png new file mode 100644 index 0000000..7824d37 Binary files /dev/null and b/static/img/products/imac.png differ diff --git a/static/img/products/ipad.png b/static/img/products/ipad.png new file mode 100644 index 0000000..658c93f Binary files /dev/null and b/static/img/products/ipad.png differ diff --git a/static/img/products/iphone.png b/static/img/products/iphone.png new file mode 100644 index 0000000..6432059 Binary files /dev/null and b/static/img/products/iphone.png differ diff --git a/static/img/products/ipod.png b/static/img/products/ipod.png new file mode 100644 index 0000000..4826c08 Binary files /dev/null and b/static/img/products/ipod.png differ diff --git a/static/img/products/ipod_classic_2011.jpg b/static/img/products/ipod_classic_2011.jpg new file mode 100644 index 0000000..8be2b35 Binary files /dev/null and b/static/img/products/ipod_classic_2011.jpg differ diff --git a/static/img/products/ipod_nano_2011.jpg b/static/img/products/ipod_nano_2011.jpg new file mode 100644 index 0000000..e07f717 Binary files /dev/null and b/static/img/products/ipod_nano_2011.jpg differ diff --git a/static/img/products/ipod_nano_7thgen.jpg b/static/img/products/ipod_nano_7thgen.jpg new file mode 100644 index 0000000..11bf41c Binary files /dev/null and b/static/img/products/ipod_nano_7thgen.jpg differ diff --git a/static/img/products/ipod_shuffle_2012.jpg b/static/img/products/ipod_shuffle_2012.jpg new file mode 100644 index 0000000..6fc963c Binary files /dev/null and b/static/img/products/ipod_shuffle_2012.jpg differ diff --git a/static/img/products/ipodnano2009-72.png b/static/img/products/ipodnano2009-72.png new file mode 100644 index 0000000..1d95bfa Binary files /dev/null and b/static/img/products/ipodnano2009-72.png differ diff --git a/static/img/products/ipodtouch.png b/static/img/products/ipodtouch.png new file mode 100644 index 0000000..cd2035f Binary files /dev/null and b/static/img/products/ipodtouch.png differ diff --git a/static/img/products/keyboard_mouse.jpg b/static/img/products/keyboard_mouse.jpg new file mode 100644 index 0000000..5f67c9e Binary files /dev/null and b/static/img/products/keyboard_mouse.jpg differ diff --git a/static/img/products/mac.png b/static/img/products/mac.png new file mode 100644 index 0000000..0d6a666 Binary files /dev/null and b/static/img/products/mac.png differ diff --git a/static/img/products/macbook.png b/static/img/products/macbook.png new file mode 100644 index 0000000..34bbfdf Binary files /dev/null and b/static/img/products/macbook.png differ diff --git a/static/img/products/macbookair.png b/static/img/products/macbookair.png new file mode 100644 index 0000000..b0f98d7 Binary files /dev/null and b/static/img/products/macbookair.png differ diff --git a/static/img/products/macbookpro.png b/static/img/products/macbookpro.png new file mode 100644 index 0000000..dbbf493 Binary files /dev/null and b/static/img/products/macbookpro.png differ diff --git a/static/img/products/macmini.png b/static/img/products/macmini.png new file mode 100644 index 0000000..fb4233c Binary files /dev/null and b/static/img/products/macmini.png differ diff --git a/static/img/products/macpro.jpg b/static/img/products/macpro.jpg new file mode 100644 index 0000000..d841424 Binary files /dev/null and b/static/img/products/macpro.jpg differ diff --git a/static/img/products/other.png b/static/img/products/other.png new file mode 100644 index 0000000..d408859 Binary files /dev/null and b/static/img/products/other.png differ diff --git a/static/img/products/wifi.png b/static/img/products/wifi.png new file mode 100644 index 0000000..a34be0c Binary files /dev/null and b/static/img/products/wifi.png differ diff --git a/templates/issues/customer.html b/templates/issues/customer.html index a47ba32..ae5eff6 100644 --- a/templates/issues/customer.html +++ b/templates/issues/customer.html @@ -2,9 +2,17 @@ {% load bootstrap3 %} {% load i18n %} +{% block nav %} +
  • {% trans "Product" %}
  • +
  • {% trans "Issue" %}
  • +
  • {% trans "Your info" %}
  • +
  • {% trans "Done" %}
  • +{% endblock nav %} + {% block main %} +

    3. {% trans "Your info" %}

    - {% csrf_token %} + {% csrf_token %} {% bootstrap_form form %} {% buttons %} diff --git a/templates/issues/details.html b/templates/issues/details.html new file mode 100644 index 0000000..479eeeb --- /dev/null +++ b/templates/issues/details.html @@ -0,0 +1,15 @@ +{% extends "issues/index.html" %} +{% load bootstrap3 %} +{% load i18n %} + +{% block main %} +

    2. {% trans "The Issue" %}

    +

    Please describe the issue you're having with the product.

    + + {% csrf_token %} + {% bootstrap_form form %} +
    + +
    +
    +{% endblock main %} diff --git a/templates/issues/device.html b/templates/issues/device.html index def5b8b..66830d3 100644 --- a/templates/issues/device.html +++ b/templates/issues/device.html @@ -1,7 +1,43 @@ -{% extends "issues/index.html" %} +{% extends "issues/warranty.html" %} +{% load i18n %} {% block main %} - {% for k, v in models.items %} - {{ v.name }} - {% endfor %} +

    {% trans "Choose Your Device" %}

    +

    Help text..

    + {% endblock main %} diff --git a/templates/issues/index.html b/templates/issues/index.html index 70a84e7..eac766d 100644 --- a/templates/issues/index.html +++ b/templates/issues/index.html @@ -1,32 +1,51 @@ +{% load i18n %} - + {{ title }} - + -
    - {% block main %} -

    {{ question.question }}

    - {% for i in question.choice_set.all %} - {{ i.choice }} - {% endfor %} -
    {{ dump }}
    - {% endblock main %} +
    + + {% block main %} + {% endblock main %}
    - + diff --git a/templates/issues/ipad.html b/templates/issues/ipad.html new file mode 100644 index 0000000..e69de29 diff --git a/templates/issues/iphone.html b/templates/issues/iphone.html new file mode 100644 index 0000000..3f5faf2 --- /dev/null +++ b/templates/issues/iphone.html @@ -0,0 +1 @@ +{% extends "issues/device.html" %} diff --git a/templates/issues/ipod.html b/templates/issues/ipod.html new file mode 100644 index 0000000..0c34c5b --- /dev/null +++ b/templates/issues/ipod.html @@ -0,0 +1,20 @@ +{% extends "issues/device.html" %} +{% load i18n %} + +{% block main %} +

    {% trans "iPod" %}

    + +{% endblock main %} diff --git a/templates/issues/mac.html b/templates/issues/mac.html new file mode 100644 index 0000000..97bd6f9 --- /dev/null +++ b/templates/issues/mac.html @@ -0,0 +1,49 @@ +{% extends "issues/device.html" %} +{% load i18n %} + +{% block main %} +

    {% trans "Mac" %}

    +

    {% trans "Choose your Mac" %}

    + +{% endblock main %} diff --git a/templates/issues/other.html b/templates/issues/other.html new file mode 100644 index 0000000..2d4d0ee --- /dev/null +++ b/templates/issues/other.html @@ -0,0 +1,29 @@ +{% extends "issues/device.html" %} +{% load i18n %} + +{% block main %} +

    {% trans "Other" %}

    +

    {% trans "Choose your product" %}

    + +{% endblock main %} diff --git a/templates/issues/question.html b/templates/issues/question.html new file mode 100644 index 0000000..8da6e10 --- /dev/null +++ b/templates/issues/question.html @@ -0,0 +1,12 @@ +{% extends "issues/index.html" %} +{% load i18n %} + +{% block main %} +
    +

    {{ question.question }}

    +

    {{ question.description|default:"" }}

    + {% for i in question.choice_set.all %} + {{ i.choice }} + {% endfor %} +
    +{% endblock main %} diff --git a/templates/issues/thanks.html b/templates/issues/thanks.html index e69de29..0803d57 100644 --- a/templates/issues/thanks.html +++ b/templates/issues/thanks.html @@ -0,0 +1,18 @@ +{% extends "issues/index.html" %} +{% load i18n %} + +{% block nav %} +
  • {% trans "Product" %}
  • +
  • {% trans "Issue" %}
  • +
  • {% trans "Your info" %}
  • +
  • {% trans "Done" %}
  • +{% endblock nav %} + +{% block main %} +
    +

    {% trans "Thanks!" %}

    +
    +

    Put description here...

    + {% trans "Restart" %} +
    +{% endblock main %} diff --git a/templates/issues/warranty.html b/templates/issues/warranty.html index b944ea5..2e0be24 100644 --- a/templates/issues/warranty.html +++ b/templates/issues/warranty.html @@ -1,28 +1,37 @@ {% extends "issues/index.html" %} {% load i18n %} +{% block nav %} +
  • {% trans "Product" %}
  • +
  • {% trans "Issue" %}
  • +
  • {% trans "Your info" %}
  • +
  • {% trans "Done" %}
  • +{% endblock nav %} + {% block main %}
    iMac (27-inch, Mid 2011)
    -

    iMac (27-inch, Mid 2011)

    -
    -
    {% trans "Warranty" %}
    -
    Out Of Warranty (No Coverage)
    -
    {% trans "Purchased" %}
    -
    2.6.2011, Sweden
    -
    {% trans "Serial Number" %}
    -
    DGKFL06JDHJP
    -
    {% trans "Configuration" %}
    -
    IMAC 27"/2.7QC/2X2GB/1TB/6770M
    -
    +
    +

    iMac (27-inch, Mid 2011)

    +
    +
    {% trans "Warranty" %}
    +
    Out Of Warranty (No Coverage)
    +
    {% trans "Purchased" %}
    +
    2.6.2011, Sweden
    +
    {% trans "Serial Number" %}
    +
    DGKFL06JDHJP
    +
    {% trans "Configuration" %}
    +
    IMAC 27"/2.7QC/2X2GB/1TB/6770M
    +
    +
    - {% endblock main %} diff --git a/templates/issues/welcome.html b/templates/issues/welcome.html index 38c0dcd..daef11b 100644 --- a/templates/issues/welcome.html +++ b/templates/issues/welcome.html @@ -1,15 +1,22 @@ {% extends "issues/index.html" %} +{% load bootstrap3 %} {% load i18n %} +{% block nav %} +
  • {% trans "Product" %}
  • +
  • {% trans "Issue" %}
  • +
  • {% trans "Your info" %}
  • +
  • {% trans "Done" %}
  • +{% endblock nav %} + {% block main %} -
    - {% csrf_token %} -
    - - -
    -
    +

    1. {% trans "Product" %}

    +

    Let's start by identifying your device. Please enter your serial number or click Skip.

    + + {% csrf_token %} + {% bootstrap_form form %} + - +
    + {% endblock main %} -- cgit v1.2.3