1 from django.contrib.auth.mixins import LoginRequiredMixin
2 from django.views.generic import ListView, CreateView, DeleteView
3 from .models import SSHKey
6 class SSHKeysView(LoginRequiredMixin, ListView):
7 def get_queryset(self):
8 return SSHKey.objects.filter(user=self.request.user)
11 class AddSSHKeyView(LoginRequiredMixin, CreateView):
15 template_name = 'ssh_keys/sshkey_add.html'
17 def form_valid(self, form):
18 form.instance.user = self.request.user
19 return super().form_valid(form)
22 class DeleteSSHKeyView(LoginRequiredMixin, DeleteView):
25 def get_queryset(self):
26 return SSHKey.objects.filter(user=self.request.user)