1111from django .core .exceptions import ObjectDoesNotExist , PermissionDenied , ValidationError
1212from django .core .paginator import EmptyPage , PageNotAnInteger , Paginator
1313from django .db .models import Count , Q
14- from django .http import HttpResponseForbidden , JsonResponse
14+ from django .http import HttpResponseForbidden , HttpResponseNotAllowed , JsonResponse
1515from django .shortcuts import redirect
1616from django .template .response import TemplateResponse
1717from django .urls import path , resolve
@@ -73,7 +73,7 @@ class Meta:
7373 "location" ,
7474 ]
7575 widgets = {
76- "label" : forms .TextInput (attrs = {"class" : "vTextField" }),
76+ "label" : forms .TextInput (attrs = {"class" : "vTextField ow-text-field " }),
7777 "notes" : forms .Textarea (attrs = {"rows" : 3 }),
7878 "input" : BatchCommandSchemaWidget ,
7979 "group" : OrganizationScopedSelect ,
@@ -508,6 +508,8 @@ def execute_command_view(self, request):
508508 A valid submission goes to the session and redirects to the confirm
509509 page, so that its device table can be paginated with plain GETs.
510510 """
511+ if request .method not in ("GET" , "POST" ):
512+ return HttpResponseNotAllowed (["GET" , "POST" ])
511513 self ._check_add_permission (request )
512514 if request .method == "POST" :
513515 form = BatchCommandExecutionForm (request .POST , request = request )
@@ -524,9 +526,6 @@ def execute_command_view(self, request):
524526 "title" : _ ("Execute mass command" ),
525527 "opts" : self .opts ,
526528 "form" : form ,
527- # not combined with self.media: ModelAdmin.media loads
528- # jquery.init.js before select2, the opposite of what select2
529- # needs (see BatchCommandExecutionForm.Media)
530529 "media" : form .media ,
531530 "has_view_permission" : self .has_view_permission (request ),
532531 }
@@ -536,6 +535,8 @@ def confirm_command_view(self, request):
536535 """Second step: review the targeted devices and dispatch the command.
537536 Dispatching is decided by the HTTP method alone.
538537 """
538+ if request .method not in ("GET" , "POST" ):
539+ return HttpResponseNotAllowed (["GET" , "POST" ])
539540 self ._check_add_permission (request )
540541 if request .method == "POST" :
541542 return self ._execute_batch_command (request )
0 commit comments