add various comments
This commit is contained in:
parent
039fe5f54c
commit
7b511ccda2
|
@ -67,6 +67,11 @@ def computers_table_view(request, pk):
|
|||
|
||||
|
||||
class ComputersFilterView(LoginRequiredMixin, SingleTableMixin, FilterView):
|
||||
"""
|
||||
A view to show all computer objects in a table.
|
||||
This view is not intended for customers to see but should be limited to
|
||||
admins only
|
||||
"""
|
||||
table_class = ComputersTable
|
||||
model = Computer
|
||||
template_name = "computers/all_computers.html"
|
||||
|
@ -82,6 +87,10 @@ class ComputersFilterView(LoginRequiredMixin, SingleTableMixin, FilterView):
|
|||
|
||||
|
||||
class ComputerCreateFromCustomerView(LoginRequiredMixin, CreateView):
|
||||
"""
|
||||
A view to show a ComputerCreateForm after comming from a customers computer
|
||||
table. The customer will be preselected in the form.
|
||||
"""
|
||||
form_class = ComputerCreateForm
|
||||
template_name = 'computers/computer_create.html'
|
||||
|
||||
|
|
|
@ -29,12 +29,23 @@ def td_format(td_object):
|
|||
|
||||
|
||||
def get_customers(user):
|
||||
"""
|
||||
Returns a queryset of customers the user is allowed to view.
|
||||
|
||||
user : django.contrib.auth.models.User
|
||||
"""
|
||||
return get_objects_for_user(user,
|
||||
'customers.view_customer',
|
||||
klass=Customer)
|
||||
|
||||
|
||||
def get_objects(model_name, user):
|
||||
"""
|
||||
Returns a queryset of a given model name the user is allowed to view.
|
||||
|
||||
model_name: string
|
||||
user : django.contrib.auth.models.User
|
||||
"""
|
||||
model_name = model_name.lower()
|
||||
customers = get_customers(user)
|
||||
app_names = [
|
||||
|
|
Loading…
Reference in New Issue