Skip to content

Commit

Permalink
Merge pull request #258 from makinacorpus/sec_sanitize_attachments
Browse files Browse the repository at this point in the history
🐛 Display Paperclip error messages on form page
  • Loading branch information
Chatewgne authored Feb 16, 2023
2 parents a9ce414 + 1abb92f commit 466728f
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,14 @@ CHANGELOG
8.5.0+dev (202X-XX-XX)
-----------------------

**Dependencies**

* Drop python 3.6 support

**Bug fixes**

- Redirect on Paperclip form error (to include Paperclip error message on object detail page directly)


8.5.0 (2023-02-07)
-----------------------
Expand Down
2 changes: 2 additions & 0 deletions mapentity/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,11 @@ def __tabbed_layout_for_field(self, field):


class AttachmentForm(BaseAttachmentForm):

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

self.redirect_on_error = True
self.helper = FormHelper(form=self)
self.helper.form_tag = True
self.helper.form_class = 'attachment form-horizontal'
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
'Django',
'django-appypod',
'django-compressor',
'django-crispy-forms',
'django-crispy-forms<2.0',
'django-embed-video',
'django-filter',
'django-leaflet>=0.19,<0.20', # leaflet 0.7.x
Expand Down
25 changes: 25 additions & 0 deletions test_app/migrations/0015_auto_20230215_1446.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Generated by Django 3.2.15 on 2023-02-15 14:46

from django.db import migrations, models
import paperclip.models
import paperclip.validators


class Migration(migrations.Migration):

dependencies = [
('test_app', '0014_sector'),
]

operations = [
migrations.AddField(
model_name='attachment',
name='random_suffix',
field=models.CharField(blank=True, default='', max_length=128),
),
migrations.AlterField(
model_name='attachment',
name='attachment_file',
field=models.FileField(blank=True, max_length=512, upload_to=paperclip.models.attachment_upload, validators=[paperclip.validators.FileMimetypeValidator()], verbose_name='File'),
),
]

0 comments on commit 466728f

Please sign in to comment.