Fix the ssh key list decorator, SettingsView.get_form and the DRF login namespace for current Django

This commit is contained in:
sajeyks 2026-11-05 14:43:57 +03:00
commit 5bf3d13ae4
3 changed files with 6 additions and 5 deletions

View file

@ -18,6 +18,7 @@ from django.views.generic import RedirectView
from django.urls import reverse_lazy
urlpatterns = [
re_path(r'^open_api/auth/', include('rest_framework.urls')),
re_path(r'^index.html$', LandingView.as_view()),
re_path(r'^open_api/',
include('opennebula_api.urls', namespace='opennebula_api')),

View file

@ -493,6 +493,7 @@ class SSHKeyDeleteView(LoginRequiredMixin, DeleteView):
return super(SSHKeyDeleteView, self).delete(request, *args, **kwargs)
@method_decorator(decorators, name='dispatch')
class SSHKeyListView(LoginRequiredMixin, ListView):
template_name = "hosting/user_keys.html"
login_url = reverse_lazy('hosting:login')
@ -506,7 +507,6 @@ class SSHKeyListView(LoginRequiredMixin, ListView):
self.queryset = UserHostingKey.objects.filter(user=user)
return super(SSHKeyListView, self).get_queryset()
@method_decorator(decorators)
def render_to_response(self, context, **response_kwargs):
if not self.queryset:
return HttpResponseRedirect(reverse('hosting:choice_ssh_keys'))
@ -549,7 +549,7 @@ class SettingsView(LoginRequiredMixin, FormView):
form_class = BillingAddressForm
permission_required = ['view_usercarddetail']
def get_form(self, form_class):
def get_form(self, form_class=None):
"""
Check if the user already saved contact details. If so, then show
the form populated with those details, to let user change them.
@ -559,6 +559,8 @@ class SettingsView(LoginRequiredMixin, FormView):
user = CustomUser.objects.get(username=username)
else:
user = self.request.user
if form_class is None:
form_class = self.get_form_class()
return form_class(
instance=user.billing_addresses.first(),
**self.get_form_kwargs())

View file

@ -1,12 +1,10 @@
from django.urls import re_path, include
from django.urls import re_path
from rest_framework.urlpatterns import format_suffix_patterns
from .views import VmCreateView, VmDetailsView
app_name = 'opennebula_api'
urlpatterns = {
re_path(r'^auth/', include('rest_framework.urls', namespace='rest_framework')),
re_path(r'^vms/$', VmCreateView.as_view(), name="vm_create"),
re_path(r'^vms/(?P<pk>[0-9]+)/$', VmDetailsView.as_view(),
name="vm_details"),