Jan Dittberner
680f091cba
- 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
44 lines
1.2 KiB
Python
44 lines
1.2 KiB
Python
"""
|
|
This module contains the form classes related to hosting packages.
|
|
|
|
"""
|
|
from __future__ import absolute_import, unicode_literals
|
|
|
|
from django import forms
|
|
from django.core.urlresolvers import reverse
|
|
from django.utils.translation import ugettext as _
|
|
|
|
from crispy_forms.helper import FormHelper
|
|
from crispy_forms.layout import (
|
|
Layout,
|
|
Submit,
|
|
)
|
|
|
|
from .models import CustomerHostingPackage
|
|
|
|
|
|
class CreateHostingPackageForm(forms.ModelForm):
|
|
"""
|
|
This form class is used for creating new customer hosting packages.
|
|
|
|
"""
|
|
class Meta:
|
|
model = CustomerHostingPackage
|
|
fields = ['template', 'name', 'description']
|
|
|
|
def __init__(self, instance, *args, **kwargs):
|
|
username = kwargs.pop('user')
|
|
super(CreateHostingPackageForm, self).__init__(
|
|
*args, **kwargs
|
|
)
|
|
self.fields['description'].widget.attrs['rows'] = 2
|
|
self.helper = FormHelper()
|
|
self.helper.form_action = reverse(
|
|
'create_hosting_package', kwargs={'user': username}
|
|
)
|
|
self.helper.layout = Layout(
|
|
'template',
|
|
'name',
|
|
'description',
|
|
Submit('submit', _('Add Hosting Package')),
|
|
)
|