implement hosting package option choice view

- implement new hostingpackages.views.HostingOptionChoices
- add URL pattern 'hosting_option_choices' to hostingpackages.urls
- add template hostingpackages/customerhostingpackage_option_choices.html
- link from hostingpackages/customerhostingpackage_detail.html to
  'hosting_package_choices'
This commit is contained in:
Jan Dittberner 2015-01-25 14:04:32 +01:00
parent 353ea7ad90
commit 9815bd1f5b
4 changed files with 64 additions and 3 deletions

View file

@ -8,9 +8,10 @@ from django.conf.urls import patterns, url
from .views import ( from .views import (
AllCustomerHostingPackageList, AllCustomerHostingPackageList,
CreateHostingPackage,
CreateCustomerHostingPackage, CreateCustomerHostingPackage,
CreateHostingPackage,
CustomerHostingPackageDetails, CustomerHostingPackageDetails,
HostingOptionChoices,
) )
@ -27,4 +28,7 @@ urlpatterns = patterns(
url(r'^allpackages/', url(r'^allpackages/',
AllCustomerHostingPackageList.as_view(), AllCustomerHostingPackageList.as_view(),
name='all_hosting_packages'), name='all_hosting_packages'),
url(r'^(?P<pk>\d+)/option-choices$',
HostingOptionChoices.as_view(),
name='hosting_option_choices'),
) )

View file

@ -26,7 +26,12 @@ from .forms import (
CreateCustomerHostingPackageForm, CreateCustomerHostingPackageForm,
CreateHostingPackageForm, CreateHostingPackageForm,
) )
from .models import CustomerHostingPackage from .models import (
CustomerHostingPackage,
DiskSpaceOption,
MailboxOption,
UserDatabaseOption,
)
class CreateHostingPackage( class CreateHostingPackage(
@ -111,3 +116,32 @@ class AllCustomerHostingPackageList(
): ):
model = CustomerHostingPackage model = CustomerHostingPackage
template_name_suffix = '_admin_list' template_name_suffix = '_admin_list'
class HostingOptionChoices(
LoginRequiredMixin, StaffuserRequiredMixin, DetailView
):
"""
This view displays choices of hosting options for a customer hosting
package.
"""
model = CustomerHostingPackage
context_object_name = 'hostingpackage'
template_name_suffix = '_option_choices'
def get_context_data(self, **kwargs):
context = super(HostingOptionChoices, self).get_context_data(
**kwargs)
context.update({
'customer': self.get_object().customer,
'hosting_options': (
(_('Disk space'),
DiskSpaceOption.objects.all()),
(_('Mailboxes'),
MailboxOption.objects.all()),
(_('Databases'),
UserDatabaseOption.objects.all())
),
})
return context

View file

@ -58,7 +58,7 @@
<p class="panel-body text-info">{% trans "No options booked" %}</p> <p class="panel-body text-info">{% trans "No options booked" %}</p>
{% endif %} {% endif %}
{% if user.is_staff %} {% if user.is_staff %}
<p class="panel-body"><a class="btn btn-primary" href="#" title="{% trans "Add another hosting option" %}">{% trans "Add option" %}</a></p> <p class="panel-body"><a class="btn btn-primary" href="{% url 'hosting_option_choices' pk=hostingpackage.id %}" title="{% trans "Add another hosting option" %}">{% trans "Add option" %}</a></p>
{% endif %} {% endif %}
</div> </div>
</div> </div>

View file

@ -0,0 +1,23 @@
{% extends "hostingpackages/base.html"%}
{% load i18n %}
{% block title %}{{ block.super }} - {% blocktrans with package=hostingpackage.name full_name=customer.get_full_name %}Choose new Option for Hosting Package {{ package }} of Customer {{ full_name }}{% endblocktrans %}{% endblock title %}
{% block page_title %}{% blocktrans with package=hostingpackage.name full_name=customer.get_full_name %}Choose new Option for Hosting Package {{ package }} of Customer {{ full_name }}{% endblocktrans %}{% endblock page_title %}
{% block content %}
<div class="row">
{% for label, items in hosting_options %}
<div class="col-lg-4 col-md-4 col-xs-12">
<div class="panel panel-default">
<div class="panel-heading">{{ label }}</div>
<ul class="list-group">
{% for item in items %}
<li class="list-group-item"><a href="#"><i class="glyphicon glyphicon-plus-sign"></i> {{ item }}</a></li>
{% endfor %}
</ul>
</div>
</div>
{% endfor %}
</div>
{% endblock %}