Switch to unified view

a/ForgeDiscussion/forgediscussion/widgets/admin.py b/ForgeDiscussion/forgediscussion/widgets/admin.py
...
...
40
40
41
    @property
41
    @property
42
    def fields(self):
42
    def fields(self):
43
        fields = [
43
        fields = [
44
            ew.HiddenField(name='app_id', label='App'),
44
            ew.HiddenField(name='app_id', label='App'),
45
            ew.TextField(name='name', label='Name'),
45
            ew.TextField(name='name', label='Name', validator=fev.UnicodeString()),
46
            ew.TextField(name='shortname', label='Short Name',
46
            ew.TextField(name='shortname', label='Short Name',
47
                         validator=All(
47
                         validator=All(
48
                                 fev.Regex(r"^[^\s\/\.]*$", not_empty=True, messages={
48
                                 fev.Regex(ur"^[^\s\/\.]*$", not_empty=True, messages={
49
                                    'invalid':'Shortname cannot contain space . or /',
49
                                    'invalid':'Shortname cannot contain space . or /',
50
                                    'empty':'You must create a short name for the forum.'}),
50
                                    'empty':'You must create a short name for the forum.'}),
51
                                 UniqueForumShortnameValidator())),
51
                                 UniqueForumShortnameValidator())),
52
            ew.TextField(name='parent', label='Parent Forum'),
52
            ew.TextField(name='parent', label='Parent Forum'),
53
            ew.TextField(name='description', label='Description',validator=fev.UnicodeString()),
53
            ew.TextField(name='description', label='Description',validator=fev.UnicodeString()),
...
...
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 '')
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