incomplete create_hosting_package view
- add staff user view create_hosting_package - add hostingpackages.forms.CreateHostingPackageForm - add hostingpackages.views.CreateHostingPackage - add link for staff users on user_dashboard page - add url pattern - TODO: implement saving the hosting package, update docs
This commit is contained in:
parent
9890248e80
commit
680f091cba
7 changed files with 117 additions and 4 deletions
47
gnuviechadmin/hostingpackages/views.py
Normal file
47
gnuviechadmin/hostingpackages/views.py
Normal file
|
@ -0,0 +1,47 @@
|
|||
"""
|
||||
This module defines views related to hosting packages.
|
||||
|
||||
"""
|
||||
from __future__ import absolute_import, unicode_literals
|
||||
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.views.generic.edit import CreateView
|
||||
from django.contrib.auth import get_user_model
|
||||
|
||||
from braces.views import (
|
||||
LoginRequiredMixin,
|
||||
StaffuserRequiredMixin,
|
||||
)
|
||||
|
||||
from .forms import CreateHostingPackageForm
|
||||
from .models import CustomerHostingPackage
|
||||
|
||||
|
||||
class CreateHostingPackage(
|
||||
LoginRequiredMixin, StaffuserRequiredMixin, CreateView
|
||||
):
|
||||
"""
|
||||
Create a hosting package.
|
||||
|
||||
"""
|
||||
model = CustomerHostingPackage
|
||||
raise_exception = True
|
||||
template_name_suffix = '_create'
|
||||
form_class = CreateHostingPackageForm
|
||||
|
||||
def get_form_kwargs(self):
|
||||
kwargs = super(CreateHostingPackage, self).get_form_kwargs()
|
||||
kwargs.update(self.kwargs)
|
||||
return kwargs
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(CreateHostingPackage, self).get_context_data(**kwargs)
|
||||
customer = get_user_model().objects.get(username=self.kwargs['user'])
|
||||
context['customer'] = customer
|
||||
return context
|
||||
|
||||
def get_success_url(self):
|
||||
return reverse('customer_dashboard', slug=self.kwargs['user'])
|
||||
|
||||
def form_valid(self, form):
|
||||
return super(CreateHostingPackage, self).form_valid(form)
|
Loading…
Add table
Add a link
Reference in a new issue