mirror of
https://github.com/wagtail/wagtail.git
synced 2024-11-30 01:46:24 +01:00
Extract PreviewOnEdit.get_form_class() method
This commit is contained in:
parent
e2c7b640d9
commit
0087b811e8
@ -16,6 +16,7 @@ from wagtail.utils.decorators import xframe_options_sameorigin_override
|
|||||||
|
|
||||||
class PreviewOnEdit(View):
|
class PreviewOnEdit(View):
|
||||||
model = None
|
model = None
|
||||||
|
form_class = None
|
||||||
http_method_names = ("post", "get", "delete")
|
http_method_names = ("post", "get", "delete")
|
||||||
preview_expiration_timeout = 60 * 60 * 24 # seconds
|
preview_expiration_timeout = 60 * 60 * 24 # seconds
|
||||||
session_key_prefix = "wagtail-preview-"
|
session_key_prefix = "wagtail-preview-"
|
||||||
@ -53,8 +54,13 @@ class PreviewOnEdit(View):
|
|||||||
obj = obj.get_latest_revision_as_object()
|
obj = obj.get_latest_revision_as_object()
|
||||||
return obj
|
return obj
|
||||||
|
|
||||||
|
def get_form_class(self):
|
||||||
|
if self.form_class:
|
||||||
|
return self.form_class
|
||||||
|
return get_edit_handler(self.model).get_form_class()
|
||||||
|
|
||||||
def get_form(self, query_dict):
|
def get_form(self, query_dict):
|
||||||
form_class = get_edit_handler(self.model).get_form_class()
|
form_class = self.get_form_class()
|
||||||
|
|
||||||
if not query_dict:
|
if not query_dict:
|
||||||
# Query dict is empty, return null form
|
# Query dict is empty, return null form
|
||||||
|
Loading…
Reference in New Issue
Block a user