From 79f87b975e47c27e24496c94a88656565f4f1e79 Mon Sep 17 00:00:00 2001 From: Elrond Date: Tue, 26 Mar 2013 19:19:32 +0100 Subject: piwigo: Start at pwg.images.addSimple. Without a session and a logged in user, this can't go much further. Misses check for the file upload field. Need refactored test tool for this. --- mediagoblin/plugins/piwigo/forms.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 mediagoblin/plugins/piwigo/forms.py (limited to 'mediagoblin/plugins/piwigo/forms.py') diff --git a/mediagoblin/plugins/piwigo/forms.py b/mediagoblin/plugins/piwigo/forms.py new file mode 100644 index 00000000..5bb12e62 --- /dev/null +++ b/mediagoblin/plugins/piwigo/forms.py @@ -0,0 +1,28 @@ +# GNU MediaGoblin -- federated, autonomous media hosting +# Copyright (C) 2013 MediaGoblin contributors. See AUTHORS. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + + +import wtforms + + +class AddSimpleForm(wtforms.Form): + image = wtforms.FileField() + name = wtforms.TextField( + validators=[wtforms.validators.Length(min=0, max=500)]) + comment = wtforms.TextField() + # tags = wtforms.FieldList(wtforms.TextField()) + category = wtforms.IntegerField() + level = wtforms.IntegerField() -- cgit v1.2.3 From c1df8d19630b1e60598db1bd93171926234b633b Mon Sep 17 00:00:00 2001 From: Elrond Date: Mon, 25 Mar 2013 15:34:21 +0100 Subject: piwigo: Add .images.add including form handling. To make things a bit easier, switch to WTForms for validating the received data. --- mediagoblin/plugins/piwigo/forms.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'mediagoblin/plugins/piwigo/forms.py') diff --git a/mediagoblin/plugins/piwigo/forms.py b/mediagoblin/plugins/piwigo/forms.py index 5bb12e62..18cbd5c5 100644 --- a/mediagoblin/plugins/piwigo/forms.py +++ b/mediagoblin/plugins/piwigo/forms.py @@ -26,3 +26,19 @@ class AddSimpleForm(wtforms.Form): # tags = wtforms.FieldList(wtforms.TextField()) category = wtforms.IntegerField() level = wtforms.IntegerField() + + +_md5_validator = wtforms.validators.Regexp(r"^[0-9a-fA-F]{32}$") + + +class AddForm(wtforms.Form): + original_sum = wtforms.TextField(None, + [_md5_validator, + wtforms.validators.Required()]) + thumbnail_sum = wtforms.TextField(None, + [wtforms.validators.Optional(False), + _md5_validator]) + file_sum = wtforms.TextField(None, [_md5_validator]) + name = wtforms.TextField() + date_creation = wtforms.TextField() + categories = wtforms.TextField() -- cgit v1.2.3 From 388daab77cd86e8b93f620716e626336056dcae1 Mon Sep 17 00:00:00 2001 From: Elrond Date: Thu, 9 May 2013 12:28:54 +0200 Subject: piwigo: Fix validator usage. wtforms.validators.Optional doesn't take an argument. I don't know, why I gave it one. --- mediagoblin/plugins/piwigo/forms.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mediagoblin/plugins/piwigo/forms.py') diff --git a/mediagoblin/plugins/piwigo/forms.py b/mediagoblin/plugins/piwigo/forms.py index 18cbd5c5..fb04aa6a 100644 --- a/mediagoblin/plugins/piwigo/forms.py +++ b/mediagoblin/plugins/piwigo/forms.py @@ -36,7 +36,7 @@ class AddForm(wtforms.Form): [_md5_validator, wtforms.validators.Required()]) thumbnail_sum = wtforms.TextField(None, - [wtforms.validators.Optional(False), + [wtforms.validators.Optional(), _md5_validator]) file_sum = wtforms.TextField(None, [_md5_validator]) name = wtforms.TextField() -- cgit v1.2.3