diff --git a/gnuviechadmin/hostingpackages/urls.py b/gnuviechadmin/hostingpackages/urls.py index d8709fd..222ae5d 100644 --- a/gnuviechadmin/hostingpackages/urls.py +++ b/gnuviechadmin/hostingpackages/urls.py @@ -8,9 +8,10 @@ from django.conf.urls import patterns, url from .views import ( AllCustomerHostingPackageList, - CreateHostingPackage, CreateCustomerHostingPackage, + CreateHostingPackage, CustomerHostingPackageDetails, + HostingOptionChoices, ) @@ -27,4 +28,7 @@ urlpatterns = patterns( url(r'^allpackages/', AllCustomerHostingPackageList.as_view(), name='all_hosting_packages'), + url(r'^(?P\d+)/option-choices$', + HostingOptionChoices.as_view(), + name='hosting_option_choices'), ) diff --git a/gnuviechadmin/hostingpackages/views.py b/gnuviechadmin/hostingpackages/views.py index 7917b14..0cb3ccd 100644 --- a/gnuviechadmin/hostingpackages/views.py +++ b/gnuviechadmin/hostingpackages/views.py @@ -26,7 +26,12 @@ from .forms import ( CreateCustomerHostingPackageForm, CreateHostingPackageForm, ) -from .models import CustomerHostingPackage +from .models import ( + CustomerHostingPackage, + DiskSpaceOption, + MailboxOption, + UserDatabaseOption, +) class CreateHostingPackage( @@ -111,3 +116,32 @@ class AllCustomerHostingPackageList( ): model = CustomerHostingPackage 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 diff --git a/gnuviechadmin/templates/hostingpackages/customerhostingpackage_detail.html b/gnuviechadmin/templates/hostingpackages/customerhostingpackage_detail.html index 25c2e3f..cc9632d 100644 --- a/gnuviechadmin/templates/hostingpackages/customerhostingpackage_detail.html +++ b/gnuviechadmin/templates/hostingpackages/customerhostingpackage_detail.html @@ -58,7 +58,7 @@

{% trans "No options booked" %}

{% endif %} {% if user.is_staff %} -

{% trans "Add option" %}

+

{% trans "Add option" %}

{% endif %} diff --git a/gnuviechadmin/templates/hostingpackages/customerhostingpackage_option_choices.html b/gnuviechadmin/templates/hostingpackages/customerhostingpackage_option_choices.html new file mode 100644 index 0000000..bd1e92f --- /dev/null +++ b/gnuviechadmin/templates/hostingpackages/customerhostingpackage_option_choices.html @@ -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 %} +
+ {% for label, items in hosting_options %} +
+
+
{{ label }}
+
    + {% for item in items %} +
  • {{ item }}
  • + {% endfor %} +
+
+
+ {% endfor %} +
+{% endblock %}