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( class ListSshPublicKeys(
HostingPackageAndCustomerMixin, StaffOrSelfLoginRequiredMixin, ListView 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 model = SshPublicKey
context_object_name = 'keys' context_object_name = 'keys'
@ -114,9 +120,19 @@ class ListSshPublicKeys(
class DeleteSshPublicKey( class DeleteSshPublicKey(
HostingPackageAndCustomerMixin, StaffOrSelfLoginRequiredMixin, DeleteView HostingPackageAndCustomerMixin, StaffOrSelfLoginRequiredMixin, DeleteView
): ):
"""
This view is used for delete confirmation of a :py:class:`SSH public key
<osusers.models.SshPublicKey>`.
"""
model = SshPublicKey model = SshPublicKey
context_object_name = 'key' 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): def get_context_data(self, **kwargs):
context = super(DeleteSshPublicKey, self).get_context_data(**kwargs) context = super(DeleteSshPublicKey, self).get_context_data(**kwargs)
context.update({ context.update({
@ -135,12 +151,21 @@ class DeleteSshPublicKey(
class EditSshPublicKeyComment( class EditSshPublicKeyComment(
HostingPackageAndCustomerMixin, StaffOrSelfLoginRequiredMixin, UpdateView HostingPackageAndCustomerMixin, StaffOrSelfLoginRequiredMixin, UpdateView
): ):
"""
This view is used for editing the comment field of a :py:class:`SSH public
key <osusers.models.SshPublicKey>`.
"""
model = SshPublicKey model = SshPublicKey
context_object_name = 'key' context_object_name = 'key'
fields = ['comment'] fields = ['comment']
template_name_suffix = '_edit_comment' template_name_suffix = '_edit_comment'
form_class = EditSshPublicKeyCommentForm 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): def get_form_kwargs(self):
kwargs = super(EditSshPublicKeyComment, self).get_form_kwargs() kwargs = super(EditSshPublicKeyComment, self).get_form_kwargs()
kwargs['hostingpackage'] = self.get_hosting_package() kwargs['hostingpackage'] = self.get_hosting_package()