|
a/ForgeDiscussion/forgediscussion/widgets/admin.py |
|
b/ForgeDiscussion/forgediscussion/widgets/admin.py |
|
... |
|
... |
28 |
ew.Option(py_value='ApproveAll', label='Approve All')])
|
28 |
ew.Option(py_value='ApproveAll', label='Approve All')])
|
29 |
]
|
29 |
]
|
30 |
return fields
|
30 |
return fields
|
31 |
|
31 |
|
32 |
class AddForum(ff.AdminForm):
|
32 |
class AddForum(ff.AdminForm):
|
33 |
template = 'jinja:discussion_widgets/add_forum.html'
|
33 |
template = 'jinja:forgediscussion:templates/discussion_widgets/add_forum.html'
|
34 |
defaults=dict(
|
34 |
defaults=dict(
|
35 |
ff.ForgeForm.defaults,
|
35 |
ff.ForgeForm.defaults,
|
36 |
name="add_forum",
|
36 |
name="add_forum",
|
37 |
value=None,
|
37 |
value=None,
|
38 |
app=None,
|
38 |
app=None,
|
|
... |
|
... |
54 |
ffw.FileChooser(name='icon', label='Icon')
|
54 |
ffw.FileChooser(name='icon', label='Icon')
|
55 |
]
|
55 |
]
|
56 |
return fields
|
56 |
return fields
|
57 |
|
57 |
|
58 |
class AddForumShort(AddForum):
|
58 |
class AddForumShort(AddForum):
|
59 |
template = 'jinja:discussion_widgets/add_forum_short.html'
|
59 |
template = 'jinja:forgediscussion:templates/discussion_widgets/add_forum_short.html'
|
60 |
|
60 |
|
61 |
class UniqueForumShortnameValidator(fev.FancyValidator):
|
61 |
class UniqueForumShortnameValidator(fev.FancyValidator):
|
62 |
|
62 |
|
63 |
def _to_python(self, value, state):
|
63 |
def _to_python(self, value, state):
|
64 |
forums = DM.Forum.query.find(dict(app_config_id=ObjectId(state.full_dict['app_id']))).all()
|
64 |
forums = DM.Forum.query.find(dict(app_config_id=ObjectId(state.full_dict['app_id']))).all()
|
65 |
value = h.really_unicode(value.lower() or '').encode('utf-8')
|
65 |
value = h.really_unicode(value.lower() or '').encode('utf-8')
|
66 |
if value in [ f.shortname for f in forums ]:
|
66 |
if value in [ f.shortname for f in forums ]:
|
67 |
raise formencode.Invalid('A forum already exists with that short name, please choose another.', value, state)
|
67 |
raise formencode.Invalid('A forum already exists with that short name, please choose another.', value, state)
|
68 |
return value |
68 |
return value
|