admin: fix source creation view
This commit is contained in:
parent
6c0e7b9741
commit
08a5c98823
0
passbook/admin/forms/__init__.py
Normal file
0
passbook/admin/forms/__init__.py
Normal file
6
passbook/admin/forms/source.py
Normal file
6
passbook/admin/forms/source.py
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
"""passbook core source form fields"""
|
||||||
|
# from django import forms
|
||||||
|
|
||||||
|
SOURCE_FORM_FIELDS = ['name', 'slug', 'enabled']
|
||||||
|
|
||||||
|
# class SourceForm(forms.Form)
|
|
@ -31,7 +31,7 @@ class SourceCreateView(SuccessMessageMixin, AdminRequiredMixin, CreateView):
|
||||||
|
|
||||||
def get_form_class(self):
|
def get_form_class(self):
|
||||||
source_type = self.request.GET.get('type')
|
source_type = self.request.GET.get('type')
|
||||||
model = next(x if x.__name__ == source_type else None for x in Source.__subclasses__())
|
model = next(x for x in Source.__subclasses__() if x.__name__ == source_type)
|
||||||
if not model:
|
if not model:
|
||||||
raise Http404
|
raise Http404
|
||||||
return path_to_class(model.form)
|
return path_to_class(model.form)
|
||||||
|
|
Reference in a new issue