List OS user in admin hosting package list
This commit is contained in:
parent
806ee80a85
commit
a136bcc52b
3 changed files with 32 additions and 17 deletions
|
@ -38,19 +38,19 @@ class CreateHostingPackage(PermissionRequiredMixin, CreateView):
|
|||
|
||||
model = CustomerHostingPackage
|
||||
raise_exception = True
|
||||
permission_required = 'domains.add_customerhostingpackage'
|
||||
permission_required = "domains.add_customerhostingpackage"
|
||||
template_name_suffix = "_create"
|
||||
form_class = CreateHostingPackageForm
|
||||
|
||||
def form_valid(self, form):
|
||||
hostingpackage = form.save()
|
||||
hosting_package = form.save()
|
||||
messages.success(
|
||||
self.request,
|
||||
_("Started setup of new hosting package {name}.").format(
|
||||
name=hostingpackage.name
|
||||
name=hosting_package.name
|
||||
),
|
||||
)
|
||||
return redirect(hostingpackage)
|
||||
return redirect(hosting_package)
|
||||
|
||||
|
||||
class CreateCustomerHostingPackage(CreateHostingPackage):
|
||||
|
@ -75,16 +75,16 @@ class CreateCustomerHostingPackage(CreateHostingPackage):
|
|||
return context
|
||||
|
||||
def form_valid(self, form):
|
||||
hostingpackage = form.save(commit=False)
|
||||
hostingpackage.customer = self.get_customer_object()
|
||||
hostingpackage.save()
|
||||
hosting_package = form.save(commit=False)
|
||||
hosting_package.customer = self.get_customer_object()
|
||||
hosting_package.save()
|
||||
messages.success(
|
||||
self.request,
|
||||
_("Started setup of new hosting package {name}.").format(
|
||||
name=hostingpackage.name
|
||||
name=hosting_package.name
|
||||
),
|
||||
)
|
||||
return redirect(hostingpackage)
|
||||
return redirect(hosting_package)
|
||||
|
||||
|
||||
class CustomerHostingPackageDetails(StaffOrSelfLoginRequiredMixin, DetailView):
|
||||
|
@ -126,6 +126,7 @@ class StaffUserRequiredMixin(UserPassesTestMixin):
|
|||
Mixin to make views available to staff members only.
|
||||
|
||||
"""
|
||||
|
||||
def test_func(self):
|
||||
return self.request.user.is_staff
|
||||
|
||||
|
@ -139,6 +140,14 @@ class AllCustomerHostingPackageList(StaffUserRequiredMixin, ListView):
|
|||
model = CustomerHostingPackage
|
||||
template_name_suffix = "_admin_list"
|
||||
|
||||
def get_queryset(self):
|
||||
return (
|
||||
super()
|
||||
.get_queryset()
|
||||
.select_related("osuser", "customer")
|
||||
.only("name", "pk", "created", "customer__username", "osuser__username")
|
||||
)
|
||||
|
||||
|
||||
class CustomerHostingPackageList(StaffOrSelfLoginRequiredMixin, ListView):
|
||||
"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue