Skip to content

Commit cb1a682

Browse files
Fixed anonymous as None to Foregin key 'form_user'
1 parent c45a284 commit cb1a682

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

CHANGELOG.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@ Changelog
33
=========
44

55

6-
0.1.0 (unreleased)
6+
0.2.0 (unreleased)
7+
=================
8+
* Removed col and rows setting from CharField form plugin
9+
* Set more margin options in spacing between fields
10+
* Fixed anonymous as None to Foregin key 'form_user'
11+
12+
0.1.0
713
==================
814

915
* Set ``default_auto_field`` to ``BigAutoField`` to ensure projects don't try to create a migration if they still use ``AutoField``

djangocms_form_builder/actions.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,19 +107,24 @@ class SaveToDBAction(FormAction):
107107
verbose_name = _("Save form submission")
108108

109109
def execute(self, form, request):
110-
if get_option(form, "unique", False) and get_option(
110+
111+
form_user = None
112+
if request.user.is_authenticated:
113+
form_user = request.user
114+
115+
if get_option(form, "unique", False) and get_option(
111116
form, "login_required", False
112117
):
113118
keys = {
114119
"form_name": get_option(form, "form_name"),
115-
"form_user": request.user,
120+
"form_user": form_user,
116121
}
117122
defaults = {}
118123
else:
119124
keys = {}
120125
defaults = {
121126
"form_name": get_option(form, "form_name"),
122-
"form_user": request.user,
127+
"form_user": form_user,
123128
}
124129
defaults.update(
125130
{

0 commit comments

Comments
 (0)