#10094 changes from code review

This commit is contained in:
Arthur 2022-08-23 09:29:55 -07:00
parent f48aaf1c46
commit 8b1a462a60
2 changed files with 8 additions and 11 deletions

View File

@ -329,9 +329,9 @@ class ObjectEditView(GetReturnURLMixin, BaseObjectView):
def get_extra_addanother_params(self, request, params): def get_extra_addanother_params(self, request, params):
""" """
Return a QueryDict of extra params to use on the Add Another button. Return a dictionary of extra parameters to use on the Add Another button.
""" """
return params return {}
# #
# Request handlers # Request handlers
@ -405,7 +405,7 @@ class ObjectEditView(GetReturnURLMixin, BaseObjectView):
# If cloning is supported, pre-populate a new instance of the form # If cloning is supported, pre-populate a new instance of the form
params = prepare_cloned_fields(obj) params = prepare_cloned_fields(obj)
params = self.get_extra_addanother_params(request, params) params.update(self.get_extra_addanother_params(request))
if params: if params:
if 'return_url' in request.GET: if 'return_url' in request.GET:
params['return_url'] = request.GET.get('return_url') params['return_url'] = request.GET.get('return_url')

View File

@ -366,14 +366,11 @@ class ContactAssignmentEditView(generic.ObjectEditView):
instance.object = get_object_or_404(content_type.model_class(), pk=request.GET.get('object_id')) instance.object = get_object_or_404(content_type.model_class(), pk=request.GET.get('object_id'))
return instance return instance
def get_extra_addanother_params(self, request, params: dict): def get_extra_addanother_params(self, request):
if not params: return {
params = QueryDict(mutable=True) 'content_type': request.GET.get('content_type'),
'object_id': request.GET.get('object_id'),
params['content_type'] = request.GET.get('content_type') }
params['object_id'] = request.GET.get('object_id')
return params
class ContactAssignmentDeleteView(generic.ObjectDeleteView): class ContactAssignmentDeleteView(generic.ObjectDeleteView):