add docstrings, restrict queryset of osusers.views

This commit is contained in:
Jan Dittberner 2015-02-01 02:11:41 +01:00
parent 5e1f34c9d8
commit 5ad3ba1631

View file

@ -98,6 +98,12 @@ class AddSshPublicKey(
class ListSshPublicKeys(
HostingPackageAndCustomerMixin, StaffOrSelfLoginRequiredMixin, ListView
):
"""
This view is used for showing the list of :py:class:`SSH public keys
<osusers.models.SshPublicKey>` assigned to the hosting package specified
via URL parameter 'pattern'.
"""
model = SshPublicKey
context_object_name = 'keys'
@ -114,9 +120,19 @@ class ListSshPublicKeys(
class DeleteSshPublicKey(
HostingPackageAndCustomerMixin, StaffOrSelfLoginRequiredMixin, DeleteView
):
"""
This view is used for delete confirmation of a :py:class:`SSH public key
<osusers.models.SshPublicKey>`.
"""
model = SshPublicKey
context_object_name = 'key'
def get_queryset(self):
return super(DeleteSshPublicKey, self).get_queryset().filter(
user=self.get_hosting_package().osuser)
def get_context_data(self, **kwargs):
context = super(DeleteSshPublicKey, self).get_context_data(**kwargs)
context.update({
@ -135,12 +151,21 @@ class DeleteSshPublicKey(
class EditSshPublicKeyComment(
HostingPackageAndCustomerMixin, StaffOrSelfLoginRequiredMixin, UpdateView
):
"""
This view is used for editing the comment field of a :py:class:`SSH public
key <osusers.models.SshPublicKey>`.
"""
model = SshPublicKey
context_object_name = 'key'
fields = ['comment']
template_name_suffix = '_edit_comment'
form_class = EditSshPublicKeyCommentForm
def get_queryset(self):
return super(EditSshPublicKeyComment, self).get_queryset().filter(
user=self.get_hosting_package().osuser)
def get_form_kwargs(self):
kwargs = super(EditSshPublicKeyComment, self).get_form_kwargs()
kwargs['hostingpackage'] = self.get_hosting_package()