Skip to content

Commit c2d2f2f

Browse files
committed
refs #134 -- example callbacks on success/failure for the demo site
1 parent ac9844c commit c2d2f2f

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

demo/demo/__init__.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
import logging
2+
3+
4+
logger = logging.getLogger(__name__)
5+
16

27
class DemoCallbackException(Exception):
38
"A dummy callback exception"
@@ -19,3 +24,23 @@ def callback_exception(*args, **kwargs):
1924
It'll raise an exception
2025
"""
2126
raise DemoCallbackException()
27+
28+
29+
def callback_success_message(request):
30+
"""
31+
This function will be called a form post-save/create.
32+
33+
It adds a logging message
34+
"""
35+
logger.info('Sucessfully recorded form :)')
36+
return True
37+
38+
39+
def callback_fail_message(request):
40+
"""
41+
This function will be called a form post-save/create.
42+
43+
It adds a logging message (error)
44+
"""
45+
logger.error('Form storing has failed :(')
46+
return True

demo/demo/settings.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,3 +115,10 @@
115115
]
116116

117117
CORS_ORIGIN_ALLOW_ALL = True
118+
119+
120+
# Formidable call back post-create/update
121+
FORMIDABLE_POST_CREATE_CALLBACK_SUCCESS = 'demo.callback_success_message'
122+
FORMIDABLE_POST_UPDATE_CALLBACK_SUCCESS = 'demo.callback_success_message'
123+
FORMIDABLE_POST_CREATE_CALLBACK_FAIL = 'demo.callback_fail_message'
124+
FORMIDABLE_POST_UPDATE_CALLBACK_FAIL = 'demo.callback_fail_message'

0 commit comments

Comments
 (0)