diff --git a/pytition/petition/models.py b/pytition/petition/models.py index 73e64ea0..c001d870 100644 --- a/pytition/petition/models.py +++ b/pytition/petition/models.py @@ -235,10 +235,12 @@ def transfer_to(self, user=None, org=None): self.user = None self.save() - def prepopulate_from_template(self, template, fields=None): + def prepopulate_from_template(self, template, fields=None, exclude_fields=None): if fields is None: fields = [f.name for f in self._meta.fields if f.name not in ["id", "title", "salt", "user", "org"]] for field in fields: + if field in exclude_fields: + continue if hasattr(self, field) and hasattr(template, field): template_value = getattr(template, field) if template_value is not None and template_value != "": diff --git a/pytition/petition/views.py b/pytition/petition/views.py index 620935a0..a6a5542d 100644 --- a/pytition/petition/views.py +++ b/pytition/petition/views.py @@ -1067,7 +1067,7 @@ def done(self, form_list, **kwargs): if use_template: template = PetitionTemplate.objects.get(pk=template_id) if template in org.petitiontemplate_set.all(): - petition.prepopulate_from_template(template) + petition.prepopulate_from_template(template, exclude_fields=['text']) petition.save() else: messages.error(self.request, _("This template does not belong to your organization")) @@ -1086,7 +1086,7 @@ def done(self, form_list, **kwargs): if use_template: template = PetitionTemplate.objects.get(pk=template_id) if template in pytitionuser.petitiontemplate_set.all(): - petition.prepopulate_from_template(template) + petition.prepopulate_from_template(template, exclude_fields=['text']) petition.save() else: messages.error(self.request, _("This template does not belong to you"))