djangocms-forms icon indicating copy to clipboard operation
djangocms-forms copied to clipboard

for usage with djangocms-3.6.0

Open sarah-github opened this issue 5 years ago • 4 comments

Installed it for djangocms-3.6.0 in my infrastructure and fixed errors. The description concerning including urls might also get updated to use "path" instead of "url".

sarah-github avatar May 20 '19 00:05 sarah-github

This PR should be definitely pulled! Works perfectly and saved me sooooo much time!

GrazingScientist avatar Nov 27 '19 08:11 GrazingScientist

@mishbahr Any chance this is going to be pulled in?

amdemas avatar Jan 08 '20 20:01 amdemas

@mishbahr I would aperciate if you could merge this PR, to avoid loosing this usefull feature for django-cms.

pidou46 avatar Feb 18 '20 15:02 pidou46

Great work!

I think you could, however, make it better by adding on_delete on created_by (thus adding support to Django 2.x) and maintaining consistency with previous on_delete calls

diff --git a/djangocms_forms/models.py b/djangocms_forms/models.py
index 069f151..973b902 100644
--- a/djangocms_forms/models.py
+++ b/djangocms_forms/models.py
@@ -128,7 +128,7 @@ class FormDefinition(CMSPlugin):
 
 @python_2_unicode_compatible
 class FormField(models.Model):
-    form = models.ForeignKey(FormDefinition, related_name='fields', on_delete='CASCADE')
+    form = models.ForeignKey(FormDefinition, related_name='fields', on_delete=models.CASCADE)
     field_type = models.CharField(
         _('Field Type'), max_length=100,
         choices=settings.DJANGOCMS_FORMS_FIELD_TYPES,
@@ -223,10 +223,10 @@ class FormField(models.Model):
 @python_2_unicode_compatible
 class FormSubmission(models.Model):
     plugin = models.ForeignKey(
-        Form, verbose_name=_('Form'), editable=False, related_name='submissions', on_delete='CASCADE')
+        Form, verbose_name=_('Form'), editable=False, related_name='submissions', on_delete=models.CASCADE)
     creation_date = models.DateTimeField(_('Date'), auto_now=True)
     created_by = models.ForeignKey(
-        settings.AUTH_USER_MODEL, verbose_name=_('User'), editable=False, null=True)
+        settings.AUTH_USER_MODEL, verbose_name=_('User'), editable=False, null=True, on_delete=models.SET_NULL)
     ip = models.GenericIPAddressField(verbose_name='IP', blank=True, null=True)
     referrer = models.CharField(_('Referrer URL'), max_length=150, blank=True)

All the best!

marcosguedes avatar Mar 25 '20 16:03 marcosguedes