admin: add generic tests

This commit is contained in:
Jens Langhammer
2020-05-19 20:59:43 +02:00
parent 5ba55356a9
commit db69c3e38d
7 changed files with 72 additions and 25 deletions

View File

@ -52,9 +52,10 @@ class SourceCreateView(
def get_form_class(self):
source_type = self.request.GET.get("type")
model = next(x for x in all_subclasses(Source) if x.__name__ == source_type)
if not model:
raise Http404
try:
model = next(x for x in all_subclasses(Source) if x.__name__ == source_type)
except StopIteration as exc:
raise Http404 from exc
return path_to_class(model.form)