Show More
@@ -1,33 +1,49 b'' | |||||
1 | # -*- coding: utf-8 -*- |
|
1 | # -*- coding: utf-8 -*- | |
2 |
|
2 | |||
3 | # Copyright (C) 2010-2017 RhodeCode GmbH |
|
3 | # Copyright (C) 2010-2017 RhodeCode GmbH | |
4 | # |
|
4 | # | |
5 | # This program is free software: you can redistribute it and/or modify |
|
5 | # This program is free software: you can redistribute it and/or modify | |
6 | # it under the terms of the GNU Affero General Public License, version 3 |
|
6 | # it under the terms of the GNU Affero General Public License, version 3 | |
7 | # (only), as published by the Free Software Foundation. |
|
7 | # (only), as published by the Free Software Foundation. | |
8 | # |
|
8 | # | |
9 | # This program is distributed in the hope that it will be useful, |
|
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. |
|
12 | # GNU General Public License for more details. | |
13 | # |
|
13 | # | |
14 | # You should have received a copy of the GNU Affero General Public License |
|
14 | # You should have received a copy of the GNU Affero General Public License | |
15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
16 | # |
|
16 | # | |
17 | # This program is dual-licensed. If you wish to learn more about the |
|
17 | # This program is dual-licensed. If you wish to learn more about the | |
18 | # RhodeCode Enterprise Edition, including its added features, Support services, |
|
18 | # RhodeCode Enterprise Edition, including its added features, Support services, | |
19 | # and proprietary license terms, please see https://rhodecode.com/licenses/ |
|
19 | # and proprietary license terms, please see https://rhodecode.com/licenses/ | |
20 |
|
20 | |||
21 | """ |
|
21 | """ | |
22 | Base module for form rendering / validation - currently just a wrapper for |
|
22 | Base module for form rendering / validation - currently just a wrapper for | |
23 | deform - later can be replaced with something custom. |
|
23 | deform - later can be replaced with something custom. | |
24 | """ |
|
24 | """ | |
25 |
|
25 | |||
26 | from rhodecode.translation import _ |
|
26 | from rhodecode.translation import _ | |
|
27 | from rhodecode.translation import TranslationString | |||
|
28 | ||||
|
29 | from mako.template import Template | |||
27 | from deform import Button, Form, widget, ValidationFailure |
|
30 | from deform import Button, Form, widget, ValidationFailure | |
28 |
|
31 | |||
29 |
|
32 | |||
30 | class buttons: |
|
33 | class buttons: | |
31 | save = Button(name='Save', type='submit') |
|
34 | save = Button(name='Save', type='submit') | |
32 | reset = Button(name=_('Reset'), type='reset') |
|
35 | reset = Button(name=_('Reset'), type='reset') | |
33 | delete = Button(name=_('Delete'), type='submit') |
|
36 | delete = Button(name=_('Delete'), type='submit') | |
|
37 | ||||
|
38 | ||||
|
39 | class RcForm(Form): | |||
|
40 | def render_error(self, request, field): | |||
|
41 | html = '' | |||
|
42 | if field.error: | |||
|
43 | for err in field.error.messages(): | |||
|
44 | if isinstance(err, TranslationString): | |||
|
45 | err = request.translate(err) | |||
|
46 | html = Template( | |||
|
47 | '<span class="error-message">${err}</span>').render(err=err) | |||
|
48 | ||||
|
49 | return html |
General Comments 0
You need to be logged in to leave comments.
Login now