allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tvansteenbu...@apache.org
Subject [13/32] PEP8 cleanup
Date Fri, 10 Jan 2014 18:19:37 GMT
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c93733ac/ForgeDiscussion/forgediscussion/model/forum.py
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/model/forum.py b/ForgeDiscussion/forgediscussion/model/forum.py
index c13bb57..1d74375 100644
--- a/ForgeDiscussion/forgediscussion/model/forum.py
+++ b/ForgeDiscussion/forgediscussion/model/forum.py
@@ -34,9 +34,11 @@ config = utils.ConfigProxy(
 
 log = logging.getLogger(__name__)
 
+
 class Forum(M.Discussion):
+
     class __mongometa__:
-        name='forum'
+        name = 'forum'
     type_s = 'Discussion'
 
     parent_id = FieldProperty(schema.ObjectId, if_missing=None)
@@ -74,14 +76,15 @@ class Forum(M.Discussion):
 
     @property
     def email_address(self):
-        domain = '.'.join(reversed(self.app.url[1:-1].split('/'))).replace('_', '-')
+        domain = '.'.join(
+            reversed(self.app.url[1:-1].split('/'))).replace('_', '-')
         return '%s@%s%s' % (self.shortname.replace('/', '.'), domain, config.common_suffix)
 
     @LazyProperty
     def announcements(self):
         return self.thread_class().query.find(dict(
-                app_config_id=self.app_config_id,
-                flags='Announcement')).all()
+            app_config_id=self.app_config_id,
+            flags='Announcement')).all()
 
     def breadcrumbs(self):
         if self.parent:
@@ -113,12 +116,14 @@ class Forum(M.Discussion):
             subject = data['headers'].get('Subject', subject)
         if parent_id is not None:
             parent = self.post_class().query.get(_id=parent_id)
-            if parent: return parent.thread, parent_id
+            if parent:
+                return parent.thread, parent_id
         if message_id:
             post = self.post_class().query.get(_id=message_id)
-            if post: return post.thread, None
+            if post:
+                return post.thread, None
         # Otherwise it's a new thread
-        return self.thread_class()(discussion_id=self._id,subject=subject), None
+        return self.thread_class()(discussion_id=self._id, subject=subject), None
 
     @property
     def discussion_thread(self):
@@ -138,12 +143,15 @@ class Forum(M.Discussion):
                     self.app.config.options.mount_point)))
         return super(Forum, self).get_mail_footer(notification, toaddr)
 
+
 class ForumFile(M.File):
-    forum_id=FieldProperty(schema.ObjectId)
+    forum_id = FieldProperty(schema.ObjectId)
+
 
 class ForumThread(M.Thread):
+
     class __mongometa__:
-        name='forum_thread'
+        name = 'forum_thread'
         indexes = [
             'flags',
             'discussion_id',
@@ -178,7 +186,8 @@ class ForumThread(M.Thread):
         return self
 
     def post(self, subject, text, message_id=None, parent_id=None, **kw):
-        post = super(ForumThread, self).post(text, message_id=message_id, parent_id=parent_id, **kw)
+        post = super(ForumThread, self).post(
+            text, message_id=message_id, parent_id=parent_id, **kw)
         if not self.first_post_id:
             self.first_post_id = post._id
             self.num_replies = 1
@@ -188,22 +197,25 @@ class ForumThread(M.Thread):
     def set_forum(self, new_forum):
         self.post_class().query.update(
             dict(discussion_id=self.discussion_id, thread_id=self._id),
-            {'$set':dict(discussion_id=new_forum._id)}, multi=True)
+            {'$set': dict(discussion_id=new_forum._id)}, multi=True)
         self.attachment_class().query.update(
-            {'discussion_id':self.discussion_id, 'thread_id':self._id},
-            {'$set':dict(discussion_id=new_forum._id)})
+            {'discussion_id': self.discussion_id, 'thread_id': self._id},
+            {'$set': dict(discussion_id=new_forum._id)})
         self.discussion_id = new_forum._id
 
 
 class ForumPostHistory(M.PostHistory):
+
     class __mongometa__:
-        name='post_history'
+        name = 'post_history'
 
     artifact_id = ForeignIdProperty('ForumPost')
 
+
 class ForumPost(M.Post):
+
     class __mongometa__:
-        name='forum_post'
+        name = 'forum_post'
         history_class = ForumPostHistory
         indexes = [
             'timestamp',  # for the posts_24hr site_stats query
@@ -252,32 +264,35 @@ class ForumPost(M.Post):
         # Set the thread ID on my replies and attachments
         old_slug = self.slug + '/', self.full_slug + '/'
         reply_re = re.compile(self.slug + '/.*')
-        self.slug, self.full_slug = self.make_slugs(parent=parent, timestamp=self.timestamp)
+        self.slug, self.full_slug = self.make_slugs(
+            parent=parent, timestamp=self.timestamp)
         placeholder.text = 'Discussion moved to [here](%s#post-%s)' % (
             thread.url(), self.slug)
         new_slug = self.slug + '/', self.full_slug + '/'
-        self.discussion_id=thread.discussion_id
-        self.thread_id=thread._id
-        self.parent_id=new_parent_id
+        self.discussion_id = thread.discussion_id
+        self.thread_id = thread._id
+        self.parent_id = new_parent_id
         self.text = 'Discussion moved from [here](%s#post-%s)\n\n%s' % (
             placeholder.thread.url(), placeholder.slug, self.text)
         reply_tree = self.query.find(dict(slug=reply_re)).all()
         for post in reply_tree:
             post.slug = new_slug[0] + post.slug[len(old_slug[0]):]
             post.full_slug = new_slug[1] + post.slug[len(old_slug[1]):]
-            post.discussion_id=self.discussion_id
-            post.thread_id=self.thread_id
-        for post in [ self ] + reply_tree:
+            post.discussion_id = self.discussion_id
+            post.thread_id = self.thread_id
+        for post in [self] + reply_tree:
             for att in post.attachments:
-                att.discussion_id=self.discussion_id
-                att.thread_id=self.thread_id
+                att.discussion_id = self.discussion_id
+                att.thread_id = self.thread_id
+
 
 class ForumAttachment(M.DiscussionAttachment):
-    DiscussionClass=Forum
-    ThreadClass=ForumThread
-    PostClass=ForumPost
+    DiscussionClass = Forum
+    ThreadClass = ForumThread
+    PostClass = ForumPost
+
     class __mongometa__:
-        polymorphic_identity='ForumAttachment'
-    attachment_type=FieldProperty(str, if_missing='ForumAttachment')
+        polymorphic_identity = 'ForumAttachment'
+    attachment_type = FieldProperty(str, if_missing='ForumAttachment')
 
 Mapper.compile_all()

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c93733ac/ForgeDiscussion/forgediscussion/tasks.py
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/tasks.py b/ForgeDiscussion/forgediscussion/tasks.py
index 3384ca2..9566818 100644
--- a/ForgeDiscussion/forgediscussion/tasks.py
+++ b/ForgeDiscussion/forgediscussion/tasks.py
@@ -22,6 +22,7 @@ from allura.lib.decorators import task
 
 log = logging.getLogger(__name__)
 
+
 @task
 def calc_forum_stats(shortname):
     from forgediscussion import model as DM
@@ -32,6 +33,7 @@ def calc_forum_stats(shortname):
         return
     forum.update_stats()
 
+
 @task
 def calc_thread_stats(thread_id):
     from forgediscussion import model as DM

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c93733ac/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py b/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py
index 7980bee..e3b5682 100644
--- a/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py
+++ b/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py
@@ -38,6 +38,7 @@ from forgediscussion import model as FM
 
 log = logging.getLogger(__name__)
 
+
 class TestForumEmail(TestController):
 
     def setUp(self):
@@ -50,7 +51,7 @@ class TestForumEmail(TestController):
         r.forms[1].submit()
         r = self.app.get('/admin/discussion/forums')
         assert 'testforum' in r
-        self.email_address=c.user.email_addresses[0]
+        self.email_address = c.user.email_addresses[0]
         h.set_context('test', 'discussion', neighborhood='Projects')
         self.forum = FM.Forum.query.get(shortname='testforum')
 
@@ -58,7 +59,7 @@ class TestForumEmail(TestController):
         msg = MIMEText('This is a test message')
         self._post_email(
             self.email_address,
-            [ self.forum.email_address ],
+            [self.forum.email_address],
             'Test Simple Thread',
             msg)
         r = self.app.get('/p/test/discussion/testforum/')
@@ -69,10 +70,10 @@ class TestForumEmail(TestController):
             'alternative',
             _subparts=[
                 MIMEText('This is a test message'),
-                MIMEText('This is a <em>test</em> message', 'html') ])
+                MIMEText('This is a <em>test</em> message', 'html')])
         self._post_email(
             self.email_address,
-            [ self.forum.email_address ],
+            [self.forum.email_address],
             'Test Simple Thread',
             msg)
         r = self.app.get('/p/test/discussion/testforum/')
@@ -90,16 +91,17 @@ class TestForumEmail(TestController):
                     _subparts=[
                         MIMEText('This is a test message'),
                         MIMEText('This is a <em>test</em> message', 'html')
-                        ])
-                ])
+                    ])
+            ])
         with open(pkg_resources.resource_filename(
                 'forgediscussion', 'tests/data/python-logo.png'), 'rb') as fp:
             img = MIMEImage(fp.read())
-            img.add_header('Content-Disposition', 'attachment', filename='python-logo.png')
+            img.add_header('Content-Disposition', 'attachment',
+                           filename='python-logo.png')
             msg.attach(img)
         self._post_email(
             self.email_address,
-            [ self.forum.email_address ],
+            [self.forum.email_address],
             'Test Simple Thread',
             msg)
         r = self.app.get('/p/test/discussion/testforum/')
@@ -123,6 +125,7 @@ class TestForumEmail(TestController):
             data=msg.as_string())
         M.artifact_orm_session.flush()
 
+
 class TestForumAsync(TestController):
 
     def setUp(self):
@@ -144,7 +147,8 @@ class TestForumAsync(TestController):
 
     def test_has_access(self):
         assert False == c.app.has_access(M.User.anonymous(), 'testforum')
-        assert True == c.app.has_access(M.User.query.get(username='root'), 'testforum')
+        assert True == c.app.has_access(
+            M.User.query.get(username='root'), 'testforum')
 
     def test_post(self):
         self._post('testforum', 'Test Thread', 'Nothing here')
@@ -159,15 +163,17 @@ class TestForumAsync(TestController):
         posts = FM.ForumPost.query.find()
         assert_equal(posts.count(), 1)
         assert_equal(FM.ForumThread.query.get().num_replies, 1)
-        assert_equal(FM.ForumThread.query.get().first_post_id, 'test_reply@sf.net')
+        assert_equal(FM.ForumThread.query.get()
+                     .first_post_id, 'test_reply@sf.net')
 
         post = posts.first()
         self._post('testforum', 'Test Reply', 'Nothing here, either',
-                   message_id=post.thread.url()+post._id,
-                   in_reply_to=[ 'test_reply@sf.net' ])
+                   message_id=post.thread.url() + post._id,
+                   in_reply_to=['test_reply@sf.net'])
         assert_equal(FM.ForumThread.query.find().count(), 1)
         assert_equal(FM.ForumPost.query.find().count(), 2)
-        assert_equal(FM.ForumThread.query.get().first_post_id, 'test_reply@sf.net')
+        assert_equal(FM.ForumThread.query.get()
+                     .first_post_id, 'test_reply@sf.net')
 
     def test_attach(self):
         self._post('testforum', 'Attachment Thread', 'This is a text file',
@@ -189,7 +195,8 @@ class TestForumAsync(TestController):
         self.app.get('/discussion/testforum/thread/foobar/', status=404)
 
     def test_posts(self):
-        c.user = M.User.by_username('test-admin') # not sure why this fails when set to root (to match self.user_id)
+        # not sure why this fails when set to root (to match self.user_id)
+        c.user = M.User.by_username('test-admin')
         self._post('testforum', 'Test', 'test')
         thd = FM.ForumThread.query.find().first()
         thd_url = str('/discussion/testforum/thread/%s/' % thd._id)
@@ -197,28 +204,30 @@ class TestForumAsync(TestController):
         p = FM.ForumPost.query.find().first()
         url = str('/discussion/testforum/thread/%s/%s/' % (thd._id, p.slug))
         r = self.app.get(url)
-        f = r.html.find('form',{'action': '/p/test' + url})
+        f = r.html.find('form', {'action': '/p/test' + url})
         params = dict()
         inputs = f.findAll('input')
         for field in inputs:
             if field.has_key('name'):
-                params[field['name']] = field.has_key('value') and field['value'] or ''
+                params[field['name']] = field.has_key(
+                    'value') and field['value'] or ''
         params['subject'] = 'New Subject'
         params['text'] = 'Asdf'
         r = self.app.post(url, params=params)
         assert 'Asdf' in self.app.get(url)
         r = self.app.get(url, params=dict(version='1'))
-        post_form = r.html.find('form',{'action':'/p/test' + url + 'reply'})
+        post_form = r.html.find('form', {'action': '/p/test' + url + 'reply'})
         params = dict()
         inputs = post_form.findAll('input')
         for field in inputs:
             if field.has_key('name'):
-                params[field['name']] = field.has_key('value') and field['value'] or ''
+                params[field['name']] = field.has_key(
+                    'value') and field['value'] or ''
         params[post_form.find('textarea')['name']] = 'text'
         r = self.app.post(url + 'reply', params=params)
         self._post('testforum', 'Test Reply', 'Nothing here, either',
                    message_id='test_posts@sf.net',
-                   in_reply_to=[ p._id ])
+                   in_reply_to=[p._id])
         reply = FM.ForumPost.query.get(_id='test_posts@sf.net')
         r = self.app.get(thd_url + reply.slug + '/')
         # Check attachments
@@ -228,8 +237,9 @@ class TestForumAsync(TestController):
                           upload_files=[('file_info', 'test.asdfasdtxt',
                                          'This is a textfile')])
         r = self.app.post(url + 'attach',
-                          upload_files=[('file_info', 'test1.txt','This is a textfile'),
-                                        ('file_info', 'test2.txt','This is a textfile')])
+                          upload_files=[(
+                              'file_info', 'test1.txt', 'This is a textfile'),
+                              ('file_info', 'test2.txt', 'This is a textfile')])
         r = self.app.get(url)
         assert "test1.txt" in r
         assert "test2.txt" in r
@@ -242,8 +252,8 @@ class TestForumAsync(TestController):
                           params=dict(subject='New Thread', delete='', promote='on'))
         # Find new location
         r = self.app.get(url)
-        link = [ a for a in r.html.findAll('a')
-                 if a.renderContents() == 'here' ]
+        link = [a for a in r.html.findAll('a')
+                if a.renderContents() == 'here']
         url, slug = str(link[0]['href']).split('#')
         slug = slug.split('-')[-1]
         reply_slug = slug + str(reply.slug[4:])
@@ -265,6 +275,7 @@ class TestForumAsync(TestController):
                      message_id=message_id))
         M.artifact_orm_session.flush()
 
+
 class TestForum(TestController):
 
     def setUp(self):
@@ -299,7 +310,8 @@ class TestForum(TestController):
         r = self.app.get('/admin/discussion/forums')
         r.forms[1]['add_forum.shortname'] = 'tester'
         r.forms[1]['add_forum.name'] = 'Tester'
-        r.forms[1]['add_forum.description'] = '<a href="http://cnn.com">This is CNN</a>'
+        r.forms[1][
+            'add_forum.description'] = '<a href="http://cnn.com">This is CNN</a>'
         r.forms[1].submit()
         r = self.app.get('/discussion/')
         assert_equal(len(r.html.findAll('a', rel='nofollow')), 1)
@@ -315,13 +327,13 @@ class TestForum(TestController):
 
     def test_forum_subscribe(self):
         r = self.app.post('/discussion/subscribe', params={
-                'forum-0.shortname':'testforum',
-                'forum-0.subscribed':'on',
-                })
+            'forum-0.shortname': 'testforum',
+            'forum-0.subscribed': 'on',
+        })
         r = self.app.post('/discussion/subscribe', params={
-                'forum-0.shortname':'testforum',
-                'forum-0.subscribed':'',
-                })
+            'forum-0.shortname': 'testforum',
+            'forum-0.subscribed': '',
+        })
 
     def test_forum_index(self):
         r = self.app.get('/discussion/testforum/')
@@ -338,19 +350,24 @@ class TestForum(TestController):
 
         def _post_pending():
             r = self.app.get('/discussion/create_topic/')
-            f = r.html.find('form',{'action':'/p/test/discussion/save_new_topic'})
+            f = r.html.find(
+                'form', {'action': '/p/test/discussion/save_new_topic'})
             params = dict()
             inputs = f.findAll('input')
             for field in inputs:
                 if field.has_key('name'):
-                    params[field['name']] = field.has_key('value') and field['value'] or ''
-            params[f.find('textarea')['name']] = '1st post in Zero Posts thread'
+                    params[field['name']] = field.has_key(
+                        'value') and field['value'] or ''
+            params[f.find('textarea')['name']
+                   ] = '1st post in Zero Posts thread'
             params[f.find('select')['name']] = 'testforum'
-            params[f.find('input',{'style':'width: 90%'})['name']] = 'Test Zero Posts'
+            params[f.find('input', {'style': 'width: 90%'})
+                   ['name']] = 'Test Zero Posts'
             r = self.app.post('/discussion/save_new_topic', params=params,
                               extra_environ=dict(username='*anonymous'),
                               status=302)
-            assert r.location.startswith('http://localhost/p/test/discussion/testforum/thread/'), r.location
+            assert r.location.startswith(
+                'http://localhost/p/test/discussion/testforum/thread/'), r.location
 
         def _check():
             r = self.app.get('/discussion/')
@@ -363,9 +380,9 @@ class TestForum(TestController):
         r = self.app.get('/discussion/testforum/moderate?status=pending')
         post_id = r.html.find('input', {'name': 'post-0._id'})['value']
         r = self.app.post('/discussion/testforum/moderate/save_moderation', params={
-                'post-0._id': post_id,
-                'post-0.checked': 'on',
-                'spam': 'Spam Marked'})
+            'post-0._id': post_id,
+            'post-0.checked': 'on',
+            'spam': 'Spam Marked'})
         _check()
 
         # test posts deleted
@@ -374,22 +391,25 @@ class TestForum(TestController):
         post_id = r.html.find('input', {'name': 'post-0._id'})['value']
         r = self.app.post('/discussion/testforum/moderate/save_'
                           'moderation', params={
-                'post-0._id': post_id,
-                'post-0.checked': 'on',
-                'delete': 'Delete Marked'})
+                              'post-0._id': post_id,
+                              'post-0.checked': 'on',
+                              'delete': 'Delete Marked'})
         _check()
 
     def test_posting(self):
         r = self.app.get('/discussion/create_topic/')
-        f = r.html.find('form',{'action':'/p/test/discussion/save_new_topic'})
+        f = r.html.find(
+            'form', {'action': '/p/test/discussion/save_new_topic'})
         params = dict()
         inputs = f.findAll('input')
         for field in inputs:
             if field.has_key('name'):
-                params[field['name']] = field.has_key('value') and field['value'] or ''
+                params[field['name']] = field.has_key(
+                    'value') and field['value'] or ''
         params[f.find('textarea')['name']] = 'This is a *test thread*'
         params[f.find('select')['name']] = 'testforum'
-        params[f.find('input',{'style':'width: 90%'})['name']] = 'Test Thread'
+        params[f.find('input', {'style': 'width: 90%'})
+               ['name']] = 'Test Thread'
         r = self.app.post('/discussion/save_new_topic', params=params)
         r = self.app.get('/admin/discussion/forums')
         assert 'Message posted' in r
@@ -404,17 +424,21 @@ class TestForum(TestController):
 
     def test_notifications_escaping(self):
         r = self.app.get('/discussion/create_topic/')
-        f = r.html.find('form', {'action':'/p/test/discussion/save_new_topic'})
+        f = r.html.find(
+            'form', {'action': '/p/test/discussion/save_new_topic'})
         params = dict()
         inputs = f.findAll('input')
         for field in inputs:
             if field.has_key('name'):
-                params[field['name']] = field.has_key('value') and field['value'] or ''
+                params[field['name']] = field.has_key(
+                    'value') and field['value'] or ''
         params[f.find('textarea')['name']] = 'Post text'
         params[f.find('select')['name']] = 'testforum'
-        params[f.find('input', {'style':'width: 90%'})['name']] = "this is <h2> o'clock"
+        params[f.find('input', {'style': 'width: 90%'})
+               ['name']] = "this is <h2> o'clock"
         r = self.app.post('/discussion/save_new_topic', params=params)
-        n = M.Notification.query.find(dict(subject="[test:discussion] this is <h2> o'clock")).first()
+        n = M.Notification.query.find(
+            dict(subject="[test:discussion] this is <h2> o'clock")).first()
         assert_in('---\n\n[this is &lt;h2&gt; o&#39;clock]', n.text)
 
     def _set_anon_allowed(self):
@@ -424,32 +448,36 @@ class TestForum(TestController):
         opt_auth = select.find(text='*authenticated').parent
         opt_admin = select.find(text='Admin').parent
         r = self.app.post('/admin/discussion/update', params={
-                'card-0.value': opt_admin['value'],
-                'card-0.id': 'admin',
-                'card-4.id': 'read',
-                'card-4.value': opt_anon['value'],
-                'card-3.value': opt_auth['value'],
-                'card-3.new': opt_anon['value'],
-                'card-3.id': 'post'})
+            'card-0.value': opt_admin['value'],
+            'card-0.id': 'admin',
+            'card-4.id': 'read',
+            'card-4.value': opt_anon['value'],
+            'card-3.value': opt_auth['value'],
+            'card-3.new': opt_anon['value'],
+            'card-3.id': 'post'})
 
     @mock.patch('allura.model.discuss.g.spam_checker')
     def test_anonymous_post(self, spam_checker):
         spam_checker.check.return_value = True
         self._set_anon_allowed()
         r = self.app.get('/discussion/create_topic/')
-        f = r.html.find('form',{'action':'/p/test/discussion/save_new_topic'})
+        f = r.html.find(
+            'form', {'action': '/p/test/discussion/save_new_topic'})
         params = dict()
         inputs = f.findAll('input')
         for field in inputs:
             if field.has_key('name'):
-                params[field['name']] = field.has_key('value') and field['value'] or ''
+                params[field['name']] = field.has_key(
+                    'value') and field['value'] or ''
         params[f.find('textarea')['name']] = 'Post content'
         params[f.find('select')['name']] = 'testforum'
-        params[f.find('input',{'style':'width: 90%'})['name']] = 'Test Thread'
+        params[f.find('input', {'style': 'width: 90%'})
+               ['name']] = 'Test Thread'
         thread = self.app.post('/discussion/save_new_topic', params=params,
                                extra_environ=dict(username='*anonymous')).follow()
 
-        r = self.app.get(thread.request.url, extra_environ=dict(username='*anonymous'))
+        r = self.app.get(thread.request.url,
+                         extra_environ=dict(username='*anonymous'))
         assert 'Post awaiting moderation' in r
         assert 'name="delete"' not in r
         assert 'name="approve"' not in r
@@ -458,98 +486,121 @@ class TestForum(TestController):
         r = self.app.get(thread.request.url)
         assert '<div class="display_post moderate">' in r
         assert '<a href="" class="reply_post btn" style="display:none">' in r
-        assert r.html.find('a',{'class': 'little_link shortlink', 'style': 'display:none'}) is not None
+        assert r.html.find(
+            'a', {'class': 'little_link shortlink', 'style': 'display:none'}) is not None
         assert 'name="delete"' in r
         assert 'name="approve"' in r
         assert 'name="spam"' in r
         assert 'Post content' in r
         r = self.app.get('/discussion/testforum/moderate/')
         post = FM.ForumPost.query.get(text='Post content')
-        link = '<a href="%s">[%s]</a>' % (post.thread.url() + '?limit=25#' + post.slug, post.shorthand_id())
+        link = '<a href="%s">[%s]</a>' % (post.thread.url()
+                                          + '?limit=25#' + post.slug, post.shorthand_id())
         assert link in r, link
 
     def test_thread(self):
         r = self.app.get('/discussion/create_topic/')
-        f = r.html.find('form',{'action':'/p/test/discussion/save_new_topic'})
+        f = r.html.find(
+            'form', {'action': '/p/test/discussion/save_new_topic'})
         params = dict()
         inputs = f.findAll('input')
         for field in inputs:
             if field.has_key('name'):
-                params[field['name']] = field.has_key('value') and field['value'] or ''
+                params[field['name']] = field.has_key(
+                    'value') and field['value'] or ''
         params[f.find('textarea')['name']] = 'aaa'
         params[f.find('select')['name']] = 'testforum'
-        params[f.find('input',{'style':'width: 90%'})['name']] = 'AAA'
-        thread = self.app.post('/discussion/save_new_topic', params=params).follow()
+        params[f.find('input', {'style': 'width: 90%'})['name']] = 'AAA'
+        thread = self.app.post(
+            '/discussion/save_new_topic', params=params).follow()
         url = thread.request.url
 
         # test reply to post
-        f = thread.html.find('div',{'class':'row reply_post_form'}).find('form')
+        f = thread.html.find(
+            'div', {'class': 'row reply_post_form'}).find('form')
         rep_url = f.get('action')
         params = dict()
         inputs = f.findAll('input')
         for field in inputs:
             if field.has_key('name'):
-                params[field['name']] = field.has_key('value') and field['value'] or ''
+                params[field['name']] = field.has_key(
+                    'value') and field['value'] or ''
         params[f.find('textarea')['name']] = 'bbb'
         thread = self.app.post(str(rep_url), params=params)
         thread = self.app.get(url)
         # beautiful soup is getting some unicode error here - test without it
-        assert thread.html.findAll('div',{'class':'display_post'})[0].find('p').string == 'aaa'
-        assert thread.html.findAll('div',{'class':'display_post'})[1].find('p').string == 'bbb'
-        assert thread.response.body.count('<div class="promote_to_thread_form') == 1
-        assert thread.response.body.count('<div class="row reply_post_form') == 2
+        assert thread.html.findAll(
+            'div', {'class': 'display_post'})[0].find('p').string == 'aaa'
+        assert thread.html.findAll(
+            'div', {'class': 'display_post'})[1].find('p').string == 'bbb'
+        assert thread.response.body.count(
+            '<div class="promote_to_thread_form') == 1
+        assert thread.response.body.count(
+            '<div class="row reply_post_form') == 2
         assert thread.response.body.count('<div class="edit_post_form') == 2
 
         # test edit post
         thread_url = thread.request.url
         r = thread
-        reply_form = r.html.find('div',{'class':'edit_post_form reply'}).find('form')
+        reply_form = r.html.find(
+            'div', {'class': 'edit_post_form reply'}).find('form')
         post_link = str(reply_form['action'])
         params = dict()
         inputs = reply_form.findAll('input')
         for field in inputs:
             if field.has_key('name'):
-                params[field['name']] = field.has_key('value') and field['value'] or ''
+                params[field['name']] = field.has_key(
+                    'value') and field['value'] or ''
         params[reply_form.find('textarea')['name']] = 'zzz'
         self.app.post(post_link, params)
         r = self.app.get(thread_url)
-        assert 'zzz' in str(r.html.find('div',{'class':'display_post'}))
-        assert 'Last edit: Test Admin less than 1 minute ago' in str(r.html.find('div',{'class':'display_post'}))
+        assert 'zzz' in str(r.html.find('div', {'class': 'display_post'}))
+        assert 'Last edit: Test Admin less than 1 minute ago' in str(
+            r.html.find('div', {'class': 'display_post'}))
 
     def test_subscription_controls(self):
         r = self.app.get('/discussion/create_topic/')
-        f = r.html.find('form',{'action':'/p/test/discussion/save_new_topic'})
+        f = r.html.find(
+            'form', {'action': '/p/test/discussion/save_new_topic'})
         params = dict()
         inputs = f.findAll('input')
         for field in inputs:
             if field.has_key('name'):
-                params[field['name']] = field.has_key('value') and field['value'] or ''
+                params[field['name']] = field.has_key(
+                    'value') and field['value'] or ''
         params[f.find('textarea')['name']] = 'Post text'
         params[f.find('select')['name']] = 'testforum'
-        params[f.find('input',{'style':'width: 90%'})['name']] = 'Post subject'
-        thread = self.app.post('/discussion/save_new_topic', params=params).follow()
-        assert M.Notification.query.find(dict(subject='[test:discussion] Post subject')).count() == 1
+        params[f.find('input', {'style': 'width: 90%'})
+               ['name']] = 'Post subject'
+        thread = self.app.post(
+            '/discussion/save_new_topic', params=params).follow()
+        assert M.Notification.query.find(
+            dict(subject='[test:discussion] Post subject')).count() == 1
         r = self.app.get('/discussion/testforum/')
-        f = r.html.find('form',{'class':'follow_form'})
+        f = r.html.find('form', {'class': 'follow_form'})
         subscribe_url = f.get('action')
         params = dict()
         inputs = f.findAll('input')
         for field in inputs:
             if field.has_key('name') and 'subscription' not in field['name']:
-                params[field['name']] = field.has_key('value') and field['value'] or ''
+                params[field['name']] = field.has_key(
+                    'value') and field['value'] or ''
         self.app.post(str(subscribe_url), params=params)
         self.app.get('/discussion/general/subscribe_to_forum?subscribe=True')
         url = thread.request.url
-        f = thread.html.find('div',{'class':'row reply_post_form'}).find('form')
+        f = thread.html.find(
+            'div', {'class': 'row reply_post_form'}).find('form')
         rep_url = f.get('action')
         params = dict()
         inputs = f.findAll('input')
         for field in inputs:
             if field.has_key('name'):
-                params[field['name']] = field.has_key('value') and field['value'] or ''
+                params[field['name']] = field.has_key(
+                    'value') and field['value'] or ''
         params[f.find('textarea')['name']] = 'Reply 2'
         thread_reply = self.app.post(str(rep_url), params=params)
-        assert M.Notification.query.find(dict(subject='[test:discussion] Re: Post subject')).count() == 1
+        assert M.Notification.query.find(
+            dict(subject='[test:discussion] Re: Post subject')).count() == 1
 
     def get_table_rows(self, response, closest_id):
         tbody = response.html.find('div', {'id': closest_id}).find('tbody')
@@ -565,22 +616,24 @@ class TestForum(TestController):
 
     def test_thread_announcement(self):
         r = self.app.get('/discussion/create_topic/')
-        f = r.html.find('form',{'action':'/p/test/discussion/save_new_topic'})
+        f = r.html.find(
+            'form', {'action': '/p/test/discussion/save_new_topic'})
         params = dict()
         inputs = f.findAll('input')
         for field in inputs:
             if field.has_key('name'):
-                params[field['name']] = field.has_key('value') and field['value'] or ''
+                params[field['name']] = field.has_key(
+                    'value') and field['value'] or ''
         params[f.find('textarea')['name']] = 'aaa aaa'
         params[f.find('select')['name']] = 'testforum'
-        params[f.find('input',{'style':'width: 90%'})['name']] = 'AAAA'
+        params[f.find('input', {'style': 'width: 90%'})['name']] = 'AAAA'
         r = self.app.post('/discussion/save_new_topic', params=params).follow()
         url = r.request.url
         thread_id = url.rstrip('/').rsplit('/', 1)[-1]
         thread = FM.ForumThread.query.get(_id=thread_id)
         r = self.app.post(url + 'moderate', params=dict(
-                flags='Announcement',
-                discussion='testforum'))
+            flags='Announcement',
+            discussion='testforum'))
         thread2 = FM.ForumThread.query.get(_id=thread_id)
         assert_equal(thread2.flags, ['Announcement'])
 
@@ -595,29 +648,33 @@ class TestForum(TestController):
 
     def test_thread_sticky(self):
         r = self.app.get('/discussion/create_topic/')
-        f = r.html.find('form',{'action':'/p/test/discussion/save_new_topic'})
+        f = r.html.find(
+            'form', {'action': '/p/test/discussion/save_new_topic'})
         params = dict()
         inputs = f.findAll('input')
         for field in inputs:
             if field.has_key('name'):
-                params[field['name']] = field.has_key('value') and field['value'] or ''
+                params[field['name']] = field.has_key(
+                    'value') and field['value'] or ''
         params[f.find('textarea')['name']] = 'aaa aaa'
         params[f.find('select')['name']] = 'testforum'
-        params[f.find('input',{'style':'width: 90%'})['name']] = 'topic1'
+        params[f.find('input', {'style': 'width: 90%'})['name']] = 'topic1'
         r = self.app.post('/discussion/save_new_topic', params=params).follow()
         url1 = r.request.url
         tid1 = url1.rstrip('/').rsplit('/', 1)[-1]
 
         r = self.app.get('/discussion/create_topic/')
-        f = r.html.find('form',{'action':'/p/test/discussion/save_new_topic'})
+        f = r.html.find(
+            'form', {'action': '/p/test/discussion/save_new_topic'})
         params = dict()
         inputs = f.findAll('input')
         for field in inputs:
             if field.has_key('name'):
-                params[field['name']] = field.has_key('value') and field['value'] or ''
+                params[field['name']] = field.has_key(
+                    'value') and field['value'] or ''
         params[f.find('textarea')['name']] = 'aaa aaa'
         params[f.find('select')['name']] = 'testforum'
-        params[f.find('input',{'style':'width: 90%'})['name']] = 'topic2'
+        params[f.find('input', {'style': 'width: 90%'})['name']] = 'topic2'
         r = self.app.post('/discussion/save_new_topic', params=params).follow()
         url2 = r.request.url
         tid2 = url2.rstrip('/').rsplit('/', 1)[-1]
@@ -631,8 +688,8 @@ class TestForum(TestController):
 
         # Make oldest thread Sticky
         r = self.app.post(url1 + 'moderate', params=dict(
-                flags='Sticky',
-                discussion='testforum'))
+            flags='Sticky',
+            discussion='testforum'))
         thread1 = FM.ForumThread.query.get(_id=tid1)
         assert_equal(thread1.flags, ['Sticky'])
 
@@ -645,8 +702,8 @@ class TestForum(TestController):
 
         # Reset Sticky flag
         r = self.app.post(url1 + 'moderate', params=dict(
-                flags='',
-                discussion='testforum'))
+            flags='',
+            discussion='testforum'))
         thread1 = FM.ForumThread.query.get(_id=tid1)
         assert_equal(thread1.flags, [])
 
@@ -662,81 +719,94 @@ class TestForum(TestController):
     def test_move_thread(self):
         # make the topic
         r = self.app.get('/discussion/create_topic/')
-        f = r.html.find('form',{'action':'/p/test/discussion/save_new_topic'})
+        f = r.html.find(
+            'form', {'action': '/p/test/discussion/save_new_topic'})
         params = dict()
         inputs = f.findAll('input')
         for field in inputs:
             if field.has_key('name'):
-                params[field['name']] = field.has_key('value') and field['value'] or ''
+                params[field['name']] = field.has_key(
+                    'value') and field['value'] or ''
         params[f.find('textarea')['name']] = 'aaa aaa'
         params[f.find('select')['name']] = 'testforum'
-        params[f.find('input',{'style':'width: 90%'})['name']] = 'topic1'
-        thread = self.app.post('/discussion/save_new_topic', params=params).follow()
+        params[f.find('input', {'style': 'width: 90%'})['name']] = 'topic1'
+        thread = self.app.post(
+            '/discussion/save_new_topic', params=params).follow()
         url = thread.request.url
         # make a reply
-        f = thread.html.find('div',{'class':'row reply_post_form'}).find('form')
+        f = thread.html.find(
+            'div', {'class': 'row reply_post_form'}).find('form')
         rep_url = f.get('action')
         params = dict()
         inputs = f.findAll('input')
         for field in inputs:
             if field.has_key('name'):
-                params[field['name']] = field.has_key('value') and field['value'] or ''
+                params[field['name']] = field.has_key(
+                    'value') and field['value'] or ''
         params[f.find('textarea')['name']] = 'bbb'
         thread = self.app.post(str(rep_url), params=params)
         thread = self.app.get(url)
         # make sure the posts are in the original thread
-        posts = thread.html.find('div',{'id':'comment'}).findAll('div',{'class':'discussion-post'})
+        posts = thread.html.find('div', {'id': 'comment'}).findAll(
+            'div', {'class': 'discussion-post'})
         assert_equal(len(posts), 2)
         # move the thread
         r = self.app.post(url + 'moderate', params=dict(
-                flags='',
-                discussion='general')).follow()
+            flags='',
+            discussion='general')).follow()
         # make sure all the posts got moved
-        posts = r.html.find('div',{'id':'comment'}).findAll('div',{'class':'discussion-post'})
+        posts = r.html.find('div', {'id': 'comment'}).findAll(
+            'div', {'class': 'discussion-post'})
         assert_equal(len(posts), 2)
 
     def test_sidebar_menu(self):
         r = self.app.get('/discussion/')
-        sidebarmenu = str(r.html.find('div',{'id':'sidebar'}))
+        sidebarmenu = str(r.html.find('div', {'id': 'sidebar'}))
         assert '<a href="/p/test/discussion/create_topic/"><b data-icon="+" class="ico ico-plus"></b> <span>Create Topic</span></a>' in sidebarmenu
         assert '<a href="/p/test/discussion/new_forum"><b data-icon="q" class="ico ico-conversation"></b> <span>Add Forum</span></a>' in sidebarmenu
         assert '<h3 class="">Help</h3>' in sidebarmenu
         assert '<a href="/p/test/discussion/markdown_syntax"><span>Formatting Help</span></a>' in sidebarmenu
         assert '<a href="flag_as_spam" class="sidebar_thread_spam"><b data-icon="^" class="ico ico-flag"></b> <span>Mark as Spam</span></a>' not in sidebarmenu
         r = self.app.get('/discussion/create_topic/')
-        f = r.html.find('form',{'action':'/p/test/discussion/save_new_topic'})
+        f = r.html.find(
+            'form', {'action': '/p/test/discussion/save_new_topic'})
         params = dict()
         inputs = f.findAll('input')
         for field in inputs:
             if field.has_key('name'):
-                params[field['name']] = field.has_key('value') and field['value'] or ''
+                params[field['name']] = field.has_key(
+                    'value') and field['value'] or ''
         params[f.find('textarea')['name']] = 'aaa'
         params[f.find('select')['name']] = 'testforum'
-        params[f.find('input',{'style':'width: 90%'})['name']] = 'AAA'
-        thread = self.app.post('/discussion/save_new_topic', params=params).follow()
-        thread_sidebarmenu = str(thread.html.find('div',{'id':'sidebar'}))
+        params[f.find('input', {'style': 'width: 90%'})['name']] = 'AAA'
+        thread = self.app.post(
+            '/discussion/save_new_topic', params=params).follow()
+        thread_sidebarmenu = str(thread.html.find('div', {'id': 'sidebar'}))
         assert '<a href="flag_as_spam" class="sidebar_thread_spam"><b data-icon="^" class="ico ico-flag"></b> <span>Mark as Spam</span></a>' in thread_sidebarmenu
 
     def test_sidebar_menu_anon(self):
         r = self.app.get('/discussion/')
-        sidebarmenu = str(r.html.find('div',{'id':'sidebar'}))
+        sidebarmenu = str(r.html.find('div', {'id': 'sidebar'}))
         assert '<a href="/p/test/discussion/create_topic/"><b data-icon="+" class="ico ico-plus"></b> <span>Create Topic</span></a>' in sidebarmenu
         assert '<a href="/p/test/discussion/new_forum"><b data-icon="q" class="ico ico-conversation"></b> <span>Add Forum</span></a>' in sidebarmenu
         assert '<h3 class="">Help</h3>' in sidebarmenu
         assert '<a href="/p/test/discussion/markdown_syntax"><span>Formatting Help</span></a>' in sidebarmenu
         assert '<a href="flag_as_spam" class="sidebar_thread_spam"><b data-icon="^" class="ico ico-flag"></b> <span>Mark as Spam</span></a>' not in sidebarmenu
         r = self.app.get('/discussion/create_topic/')
-        f = r.html.find('form',{'action':'/p/test/discussion/save_new_topic'})
+        f = r.html.find(
+            'form', {'action': '/p/test/discussion/save_new_topic'})
         params = dict()
         inputs = f.findAll('input')
         for field in inputs:
             if field.has_key('name'):
-                params[field['name']] = field.has_key('value') and field['value'] or ''
+                params[field['name']] = field.has_key(
+                    'value') and field['value'] or ''
         params[f.find('textarea')['name']] = 'aaa'
         params[f.find('select')['name']] = 'testforum'
-        params[f.find('input',{'style':'width: 90%'})['name']] = 'AAA'
-        thread = self.app.post('/discussion/save_new_topic', params=params).follow(extra_environ=dict(username='*anonymous'))
-        thread_sidebarmenu = str(thread.html.find('div',{'id':'sidebar'}))
+        params[f.find('input', {'style': 'width: 90%'})['name']] = 'AAA'
+        thread = self.app.post('/discussion/save_new_topic',
+                               params=params).follow(extra_environ=dict(username='*anonymous'))
+        thread_sidebarmenu = str(thread.html.find('div', {'id': 'sidebar'}))
         assert '<a href="flag_as_spam" class="sidebar_thread_spam"><b data-icon="^" class="ico ico-flag"></b> <span>Mark as Spam</span></a>' not in thread_sidebarmenu
 
     def test_feed(self):
@@ -760,7 +830,8 @@ class TestForum(TestController):
         r.forms[1].submit()
         r = self.app.get('/admin/discussion/forums')
         assert u'téstforum'.encode('utf-8') in r
-        r = self.app.get(u'/p/test/discussion/create_topic/téstforum/'.encode('utf-8'))
+        r = self.app.get(
+            u'/p/test/discussion/create_topic/téstforum/'.encode('utf-8'))
         assert u'<option value="téstforum" selected>Tést Forum</option>' in r
 
 
@@ -769,7 +840,8 @@ class TestForumStats(TestController):
     def test_stats(self):
         self.app.get('/discussion/stats', status=200)
 
-    @mock.patch('ming.session.Session.aggregate')  # mim doesn't support aggregate
+    # mim doesn't support aggregate
+    @mock.patch('ming.session.Session.aggregate')
     def test_stats_data(self, aggregate):
         # partial data, some days are implicit 0
         aggregate.return_value = {'result': [
@@ -778,21 +850,22 @@ class TestForumStats(TestController):
                 "month": 1,
                 "day": 2},
              "posts": 3
-            },
+             },
             {"_id": {
                 "year": 2013,
                 "month": 1,
                 "day": 3},
              "posts": 5
-            },
+             },
             {"_id": {
                 "year": 2013,
                 "month": 1,
                 "day": 5},
              "posts": 2
-            },
+             },
         ]}
-        r = self.app.get('/discussion/stats_data?begin=2013-01-01&end=2013-01-06')
+        r = self.app.get(
+            '/discussion/stats_data?begin=2013-01-01&end=2013-01-06')
         assert_equal(r.json, {
             'begin': '2013-01-01 00:00:00',
             'end': '2013-01-06 00:00:00',

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c93733ac/ForgeDiscussion/forgediscussion/tests/functional/test_forum_admin.py
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/tests/functional/test_forum_admin.py b/ForgeDiscussion/forgediscussion/tests/functional/test_forum_admin.py
index 8a92969..2f28cbc 100644
--- a/ForgeDiscussion/forgediscussion/tests/functional/test_forum_admin.py
+++ b/ForgeDiscussion/forgediscussion/tests/functional/test_forum_admin.py
@@ -45,12 +45,12 @@ class TestForumAdmin(TestController):
         h.set_context('test', 'Forum', neighborhood='Projects')
         frm = FM.Forum.query.get(shortname='testforum')
         r = self.app.post('/admin/discussion/update_forums',
-                          params={'forum-0.delete':'',
-                                  'forum-0.id':str(frm._id),
-                                  'forum-0.name':'New Test Forum',
-                                  'forum-0.shortname':'NewTestForum',
-                                  'forum-0.description':'My desc',
-                                  'forum-0.monitoring_email':''})
+                          params={'forum-0.delete': '',
+                                  'forum-0.id': str(frm._id),
+                                  'forum-0.name': 'New Test Forum',
+                                  'forum-0.shortname': 'NewTestForum',
+                                  'forum-0.description': 'My desc',
+                                  'forum-0.monitoring_email': ''})
         r = self.app.get('/admin/discussion/forums')
         assert 'New Test Forum' in r
         assert 'My desc' in r
@@ -101,11 +101,11 @@ class TestForumAdmin(TestController):
         h.set_context('test', 'Forum', neighborhood='Projects')
         forum_a = FM.Forum.query.get(shortname='a')
         self.app.post('/admin/discussion/update_forums',
-                        params={'forum-0.delete':'on',
-                                'forum-0.id':str(forum_a._id),
-                                'forum-0.name':'Forum A',
-                                'forum-0.description':''
-                               })
+                      params={'forum-0.delete': 'on',
+                              'forum-0.id': str(forum_a._id),
+                              'forum-0.name': 'Forum A',
+                              'forum-0.description': ''
+                              })
         # Now we have two forums: 'a', and 'b'.  'a' is deleted.
         # Let's try to create new forums with these names.
         r = self.app.get('/admin/discussion/forums')
@@ -121,7 +121,8 @@ class TestForumAdmin(TestController):
 
     def test_forum_icon(self):
         file_name = 'neo-icon-set-454545-256x350.png'
-        file_path = os.path.join(allura.__path__[0],'nf','allura','images',file_name)
+        file_path = os.path.join(
+            allura.__path__[0], 'nf', 'allura', 'images', file_name)
         file_data = file(file_path).read()
         upload = ('add_forum.icon', file_name, file_data)
 
@@ -129,16 +130,16 @@ class TestForumAdmin(TestController):
         r = self.app.get('/admin/discussion/forums')
         app_id = r.forms[1]['add_forum.app_id'].value
         r = self.app.post('/admin/discussion/add_forum',
-                          params={'add_forum.shortname':'testforum',
-                                  'add_forum.app_id':app_id,
-                                  'add_forum.name':'Test Forum',
-                                  'add_forum.description':'',
-                                  'add_forum.parent':'',
+                          params={'add_forum.shortname': 'testforum',
+                                  'add_forum.app_id': app_id,
+                                  'add_forum.name': 'Test Forum',
+                                  'add_forum.description': '',
+                                  'add_forum.parent': '',
                                   },
                           upload_files=[upload]),
         r = self.app.get('/discussion/testforum/icon')
         image = PIL.Image.open(StringIO(r.body))
-        assert image.size == (48,48)
+        assert image.size == (48, 48)
 
     def test_delete_undelete(self):
         r = self.app.get('/admin/discussion/forums')
@@ -147,24 +148,24 @@ class TestForumAdmin(TestController):
         r.forms[1]['add_forum.name'] = 'Test Forum'
         r = r.forms[1].submit()
         r = self.app.get('/admin/discussion/forums')
-        assert len(r.html.findAll('input',{'value':'Delete'})) == 2
+        assert len(r.html.findAll('input', {'value': 'Delete'})) == 2
         h.set_context('test', 'Forum', neighborhood='Projects')
         frm = FM.Forum.query.get(shortname='testforum')
 
         r = self.app.post('/admin/discussion/update_forums',
-                          params={'forum-0.delete':'on',
-                                  'forum-0.id':str(frm._id),
-                                  'forum-0.name':'New Test Forum',
-                                  'forum-0.description':'My desc'})
+                          params={'forum-0.delete': 'on',
+                                  'forum-0.id': str(frm._id),
+                                  'forum-0.name': 'New Test Forum',
+                                  'forum-0.description': 'My desc'})
         r = self.app.get('/admin/discussion/forums')
-        assert len(r.html.findAll('input',{'value':'Delete'})) == 1
+        assert len(r.html.findAll('input', {'value': 'Delete'})) == 1
         r = self.app.post('/admin/discussion/update_forums',
-                          params={'forum-0.undelete':'on',
-                                  'forum-0.id':str(frm._id),
-                                  'forum-0.name':'New Test Forum',
-                                  'forum-0.description':'My desc'})
+                          params={'forum-0.undelete': 'on',
+                                  'forum-0.id': str(frm._id),
+                                  'forum-0.name': 'New Test Forum',
+                                  'forum-0.description': 'My desc'})
         r = self.app.get('/admin/discussion/forums')
-        assert len(r.html.findAll('input',{'value':'Delete'})) == 2
+        assert len(r.html.findAll('input', {'value': 'Delete'})) == 2
 
     def test_members_only(self):
         # make a forum anyone can see
@@ -174,47 +175,56 @@ class TestForumAdmin(TestController):
         r.forms[1].submit()
         # forum can be viewed by member and non-member
         self.app.get('/discussion/secret')
-        self.app.get('/discussion/secret',extra_environ=dict(username='test-user'))
-        # make a post in the forum and confirm it is also viewable by member and non-member
+        self.app.get('/discussion/secret',
+                     extra_environ=dict(username='test-user'))
+        # make a post in the forum and confirm it is also viewable by member
+        # and non-member
         r = self.app.get('/discussion/create_topic/')
-        f = r.html.find('form',{'action':'/p/test/discussion/save_new_topic'})
+        f = r.html.find(
+            'form', {'action': '/p/test/discussion/save_new_topic'})
         params = dict()
         inputs = f.findAll('input')
         for field in inputs:
             if field.has_key('name'):
-                params[field['name']] = field.has_key('value') and field['value'] or ''
+                params[field['name']] = field.has_key(
+                    'value') and field['value'] or ''
         params[f.find('textarea')['name']] = 'secret text'
         params[f.find('select')['name']] = 'secret'
-        params[f.find('input',{'style':'width: 90%'})['name']] = 'secret topic'
+        params[f.find('input', {'style': 'width: 90%'})
+               ['name']] = 'secret topic'
         r = self.app.post('/discussion/save_new_topic', params=params).follow()
-        thread_url= r.request.url
+        thread_url = r.request.url
         self.app.get(thread_url)
-        self.app.get(thread_url,extra_environ=dict(username='test-user'))
+        self.app.get(thread_url, extra_environ=dict(username='test-user'))
         # link shows up in app for member and non-member
         r = self.app.get('/discussion/')
         assert '/secret/' in r
-        r = self.app.get('/discussion/',extra_environ=dict(username='test-user'))
+        r = self.app.get('/discussion/',
+                         extra_environ=dict(username='test-user'))
         assert '/secret/' in r
         # make the forum member only viewable
         secret = FM.Forum.query.get(shortname='secret')
         self.app.post('/admin/discussion/update_forums',
-                        params={'forum-0.members_only':'on',
-                                'forum-0.id':str(secret._id),
-                                'forum-0.name':'Secret',
-                                'forum-0.shortname':'secret',
-                                'forum-0.description':'',
-                                'forum-0.monitoring_email':''
-                               })
+                      params={'forum-0.members_only': 'on',
+                              'forum-0.id': str(secret._id),
+                              'forum-0.name': 'Secret',
+                              'forum-0.shortname': 'secret',
+                              'forum-0.description': '',
+                              'forum-0.monitoring_email': ''
+                              })
         # member can see the forum, but non-member gets 403
         self.app.get('/discussion/secret')
-        self.app.get('/discussion/secret',extra_environ=dict(username='test-user'), status=403)
+        self.app.get('/discussion/secret',
+                     extra_environ=dict(username='test-user'), status=403)
         # member can see a thread in the forum, but non-member gets 403
         self.app.get(thread_url)
-        self.app.get(thread_url,extra_environ=dict(username='test-user'), status=403)
+        self.app.get(thread_url,
+                     extra_environ=dict(username='test-user'), status=403)
         # link shows up in app for member but not non-member
         r = self.app.get('/discussion/')
         assert '/secret/' in r
-        r = self.app.get('/discussion/',extra_environ=dict(username='test-user'))
+        r = self.app.get('/discussion/',
+                         extra_environ=dict(username='test-user'))
         assert '/secret/' not in r
 
     def test_anon_posts(self):
@@ -225,38 +235,43 @@ class TestForumAdmin(TestController):
         r.forms[1].submit()
         # try to post in the forum and get a 403
         r = self.app.get('/discussion/create_topic/')
-        f = r.html.find('form',{'action':'/p/test/discussion/save_new_topic'})
+        f = r.html.find(
+            'form', {'action': '/p/test/discussion/save_new_topic'})
         params = dict()
         inputs = f.findAll('input')
         for field in inputs:
             if field.has_key('name'):
-                params[field['name']] = field.has_key('value') and field['value'] or ''
+                params[field['name']] = field.has_key(
+                    'value') and field['value'] or ''
         params[f.find('textarea')['name']] = 'post text'
         params[f.find('select')['name']] = 'testforum'
-        params[f.find('input',{'style':'width: 90%'})['name']] = 'post topic'
-        r = self.app.post('/discussion/save_new_topic', params=params, extra_environ=dict(username='*anonymous'))
+        params[f.find('input', {'style': 'width: 90%'})['name']] = 'post topic'
+        r = self.app.post('/discussion/save_new_topic',
+                          params=params, extra_environ=dict(username='*anonymous'))
         assert r.location == 'http://localhost/auth/'
         # allow anon posts in the forum
         testforum = FM.Forum.query.get(shortname='testforum')
         self.app.post('/admin/discussion/update_forums',
-                        params={'forum-0.anon_posts':'on',
-                                'forum-0.id':str(testforum._id),
-                                'forum-0.name':'Test Forum',
-                                'forum-0.shortname':'testforum',
-                                'forum-0.description':'',
-                                'forum-0.monitoring_email':''
-                               })
+                      params={'forum-0.anon_posts': 'on',
+                              'forum-0.id': str(testforum._id),
+                              'forum-0.name': 'Test Forum',
+                              'forum-0.shortname': 'testforum',
+                              'forum-0.description': '',
+                              'forum-0.monitoring_email': ''
+                              })
         # successfully post to the forum
         r = self.app.get('/discussion/create_topic/')
-        f = r.html.find('form',{'action':'/p/test/discussion/save_new_topic'})
+        f = r.html.find(
+            'form', {'action': '/p/test/discussion/save_new_topic'})
         params = dict()
         inputs = f.findAll('input')
         for field in inputs:
             if field.has_key('name'):
-                params[field['name']] = field.has_key('value') and field['value'] or ''
+                params[field['name']] = field.has_key(
+                    'value') and field['value'] or ''
         params[f.find('textarea')['name']] = 'post text'
         params[f.find('select')['name']] = 'testforum'
-        params[f.find('input',{'style':'width: 90%'})['name']] = 'post topic'
+        params[f.find('input', {'style': 'width: 90%'})['name']] = 'post topic'
         r = self.app.post('/discussion/save_new_topic', params=params)
         assert 'http://localhost/p/test/discussion/testforum/thread/' in r.location
 
@@ -267,26 +282,31 @@ class TestForumAdmin(TestController):
         r.forms[1].submit()
         testforum = FM.Forum.query.get(shortname='testforum')
         self.app.post('/admin/discussion/update_forums',
-                        params={'forum-0.anon_posts':'on',
-                                'forum-0.id':str(testforum._id),
-                                'forum-0.name':'Test Forum',
-                                'forum-0.shortname':'testforum',
-                                'forum-0.description':'',
-                                'forum-0.monitoring_email':'email@monitoring.com'
-                               })
+                      params={'forum-0.anon_posts': 'on',
+                              'forum-0.id': str(testforum._id),
+                              'forum-0.name': 'Test Forum',
+                              'forum-0.shortname': 'testforum',
+                              'forum-0.description': '',
+                              'forum-0.monitoring_email': 'email@monitoring.com'
+                              })
 
         r = self.app.get('/discussion/create_topic/')
-        f = r.html.find('form',{'action':'/p/test/discussion/save_new_topic'})
+        f = r.html.find(
+            'form', {'action': '/p/test/discussion/save_new_topic'})
         params = dict()
         inputs = f.findAll('input')
         for field in inputs:
             if field.has_key('name'):
-                params[field['name']] = field.has_key('value') and field['value'] or ''
+                params[field['name']] = field.has_key(
+                    'value') and field['value'] or ''
         params[f.find('textarea')['name']] = 'post text'
         params[f.find('select')['name']] = 'testforum'
-        params[f.find('input',{'style':'width: 90%'})['name']] = 'post topic'
+        params[f.find('input', {'style': 'width: 90%'})['name']] = 'post topic'
         r = self.app.post('/discussion/save_new_topic', params=params)
         M.MonQTask.run_ready()
-        email_tasks = M.MonQTask.query.find(dict(task_name='allura.tasks.mail_tasks.sendsimplemail')).all()
-        assert 'Sent from sourceforge.net because email@monitoring.com is subscribed to http://localhost/p/test/discussion/testforum/' in email_tasks[0].kwargs['text'],email_tasks[0].kwargs['text']
-        assert 'a project admin can change settings at http://localhost/p/test/admin/discussion/forums' in email_tasks[0].kwargs['text']
+        email_tasks = M.MonQTask.query.find(
+            dict(task_name='allura.tasks.mail_tasks.sendsimplemail')).all()
+        assert 'Sent from sourceforge.net because email@monitoring.com is subscribed to http://localhost/p/test/discussion/testforum/' in email_tasks[
+            0].kwargs['text'], email_tasks[0].kwargs['text']
+        assert 'a project admin can change settings at http://localhost/p/test/admin/discussion/forums' in email_tasks[
+            0].kwargs['text']

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c93733ac/ForgeDiscussion/forgediscussion/tests/functional/test_import.py
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/tests/functional/test_import.py b/ForgeDiscussion/forgediscussion/tests/functional/test_import.py
index 76d7896..b641b2d 100644
--- a/ForgeDiscussion/forgediscussion/tests/functional/test_import.py
+++ b/ForgeDiscussion/forgediscussion/tests/functional/test_import.py
@@ -27,7 +27,7 @@ from allura import model as M
 from alluratest.controller import TestController, TestRestApiBase
 
 
-class TestImportController(TestRestApiBase):#TestController):
+class TestImportController(TestRestApiBase):  # TestController):
 
     def setUp(self):
         super(TestImportController, self).setUp()
@@ -38,27 +38,28 @@ class TestImportController(TestRestApiBase):#TestController):
     def test_no_capability(self):
         self.set_api_ticket({'import2': ['Projects', 'test']})
         resp = self.api_post('/rest/p/test/discussion/perform_import',
-            doc=self.json_text)
+                             doc=self.json_text)
         assert resp.status_int == 403
 
         self.set_api_ticket({'import': ['Projects', 'test2']})
         resp = self.api_post('/rest/p/test/discussion/perform_import',
-            doc=self.json_text)
+                             doc=self.json_text)
         assert resp.status_int == 403
 
         self.set_api_ticket({'import': ['Projects', 'test']})
         resp = self.api_post('/rest/p/test/discussion/perform_import',
-            doc=self.json_text)
+                             doc=self.json_text)
         assert resp.status_int == 200
 
     def test_validate_import(self):
         r = self.api_post('/rest/p/test/discussion/validate_import',
-            doc=self.json_text)
+                          doc=self.json_text)
         assert not r.json['errors']
 
     def test_import_anon(self):
-        api_ticket = M.ApiTicket(user_id=c.user._id, capabilities={'import': ['Projects', 'test']},
-                                 expires=datetime.utcnow() + timedelta(days=1))
+        api_ticket = M.ApiTicket(
+            user_id=c.user._id, capabilities={'import': ['Projects', 'test']},
+            expires=datetime.utcnow() + timedelta(days=1))
         ming.orm.session(api_ticket).flush()
         self.set_api_token(api_ticket)
 
@@ -69,15 +70,17 @@ class TestImportController(TestRestApiBase):#TestController):
         assert 'Open Discussion' in str(r)
         assert 'Welcome to Open Discussion' in str(r)
         for link in r.html.findAll('a'):
-            if 'Welcome to Open Discussion' in str(link): break
+            if 'Welcome to Open Discussion' in str(link):
+                break
         r = self.app.get(link.get('href'))
         assert '2009-11-19' in str(r)
         assert 'Welcome to Open Discussion' in str(r)
         assert 'Anonymous' in str(r)
 
     def test_import_map(self):
-        api_ticket = M.ApiTicket(user_id=c.user._id, capabilities={'import': ['Projects', 'test']},
-                                 expires=datetime.utcnow() + timedelta(days=1))
+        api_ticket = M.ApiTicket(
+            user_id=c.user._id, capabilities={'import': ['Projects', 'test']},
+            expires=datetime.utcnow() + timedelta(days=1))
         ming.orm.session(api_ticket).flush()
         self.set_api_token(api_ticket)
 
@@ -89,7 +92,8 @@ class TestImportController(TestRestApiBase):#TestController):
         assert 'Open Discussion' in str(r)
         assert 'Welcome to Open Discussion' in str(r)
         for link in r.html.findAll('a'):
-            if 'Welcome to Open Discussion' in str(link): break
+            if 'Welcome to Open Discussion' in str(link):
+                break
         r = self.app.get(link.get('href'))
         assert '2009-11-19' in str(r)
         assert 'Welcome to Open Discussion' in str(r)
@@ -97,8 +101,9 @@ class TestImportController(TestRestApiBase):#TestController):
         assert 'Anonymous' not in str(r)
 
     def test_import_create(self):
-        api_ticket = M.ApiTicket(user_id=c.user._id, capabilities={'import': ['Projects', 'test']},
-                                 expires=datetime.utcnow() + timedelta(days=1))
+        api_ticket = M.ApiTicket(
+            user_id=c.user._id, capabilities={'import': ['Projects', 'test']},
+            expires=datetime.utcnow() + timedelta(days=1))
         ming.orm.session(api_ticket).flush()
         self.set_api_token(api_ticket)
 
@@ -109,7 +114,8 @@ class TestImportController(TestRestApiBase):#TestController):
         assert 'Open Discussion' in str(r)
         assert 'Welcome to Open Discussion' in str(r)
         for link in r.html.findAll('a'):
-            if 'Welcome to Open Discussion' in str(link): break
+            if 'Welcome to Open Discussion' in str(link):
+                break
         r = self.app.get(link.get('href'))
         assert '2009-11-19' in str(r)
         assert 'Welcome to Open Discussion' in str(r)
@@ -131,8 +137,11 @@ class TestImportController(TestRestApiBase):#TestController):
         assert_equal(from_api['description'], org['description'])
         assert_equal(from_api['summary'], org['summary'])
         assert_equal(from_api['ticket_num'], org['id'])
-        assert_equal(from_api['created_date'], self.time_normalize(org['date']))
-        assert_equal(from_api['mod_date'], self.time_normalize(org['date_updated']))
-        assert_equal(from_api['custom_fields']['_resolution'], org['resolution'])
+        assert_equal(from_api['created_date'],
+                     self.time_normalize(org['date']))
+        assert_equal(from_api['mod_date'],
+                     self.time_normalize(org['date_updated']))
+        assert_equal(from_api['custom_fields']
+                     ['_resolution'], org['resolution'])
         assert_equal(from_api['custom_fields']['_cc'], org['cc'])
         assert_equal(from_api['custom_fields']['_private'], org['private'])

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c93733ac/ForgeDiscussion/forgediscussion/tests/functional/test_rest.py
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/tests/functional/test_rest.py b/ForgeDiscussion/forgediscussion/tests/functional/test_rest.py
index d78a7fb..dd02429 100644
--- a/ForgeDiscussion/forgediscussion/tests/functional/test_rest.py
+++ b/ForgeDiscussion/forgediscussion/tests/functional/test_rest.py
@@ -49,12 +49,14 @@ class TestDiscussionApiBase(TestRestApiBase):
 
     def create_topic(self, forum, subject, text):
         r = self.app.get('/discussion/create_topic/')
-        f = r.html.find('form', {'action': '/p/test/discussion/save_new_topic'})
+        f = r.html.find(
+            'form', {'action': '/p/test/discussion/save_new_topic'})
         params = dict()
         inputs = f.findAll('input')
         for field in inputs:
             if field.has_key('name'):
-                params[field['name']] = field.has_key('value') and field['value'] or ''
+                params[field['name']] = field.has_key(
+                    'value') and field['value'] or ''
         params[f.find('textarea')['name']] = text
         params[f.find('select')['name']] = forum
         params[f.find('input', {'style': 'width: 90%'})['name']] = subject
@@ -69,23 +71,27 @@ class TestRootRestController(TestDiscussionApiBase):
         assert_equal(len(forums), 2)
         forums = sorted(forums, key=lambda x: x['name'])
         assert_equal(forums[0]['name'], 'General Discussion')
-        assert_equal(forums[0]['description'], 'Forum about anything you want to talk about.')
+        assert_equal(
+            forums[0]['description'], 'Forum about anything you want to talk about.')
         assert_equal(forums[0]['num_topics'], 2)
-        assert_equal(forums[0]['url'], 'http://localhost/rest/p/test/discussion/general/')
+        assert_equal(
+            forums[0]['url'], 'http://localhost/rest/p/test/discussion/general/')
         assert_equal(forums[0]['last_post']['subject'], 'Hi guys')
         assert_equal(forums[0]['last_post']['author'], 'test-admin')
         assert_equal(forums[0]['last_post']['text'], 'Hi boys and girls')
         assert_equal(forums[1]['name'], u'Say Héllo')
         assert_equal(forums[1]['description'], u'Say héllo here')
         assert_equal(forums[1]['num_topics'], 0)
-        assert_equal(forums[1]['url'], 'http://localhost/rest/p/test/discussion/h%C3%A9llo/')
+        assert_equal(
+            forums[1]['url'], 'http://localhost/rest/p/test/discussion/h%C3%A9llo/')
         assert_equal(forums[1]['last_post'], None)
 
     def test_forum(self):
         forum = self.api_get('/rest/p/test/discussion/general/')
         forum = forum.json['forum']
         assert_equal(forum['name'], 'General Discussion')
-        assert_equal(forum['description'], 'Forum about anything you want to talk about.')
+        assert_equal(
+            forum['description'], 'Forum about anything you want to talk about.')
         topics = forum['topics']
         assert_equal(len(topics), 2)
         assert_equal(topics[0]['subject'], 'Hi guys')
@@ -126,7 +132,8 @@ class TestRootRestController(TestDiscussionApiBase):
         forum = self.api_get('/rest/p/test/discussion/general/')
         forum = forum.json['forum']
         assert_equal(forum['name'], 'General Discussion')
-        assert_equal(forum['description'], 'Forum about anything you want to talk about.')
+        assert_equal(
+            forum['description'], 'Forum about anything you want to talk about.')
         topics = forum['topics']
         topic = self.api_get(topics[0]['url'][len('http://localhost'):])
         topic = topic.json['topic']

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c93733ac/ForgeDiscussion/forgediscussion/tests/test_app.py
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/tests/test_app.py b/ForgeDiscussion/forgediscussion/tests/test_app.py
index 3666821..76f2071 100644
--- a/ForgeDiscussion/forgediscussion/tests/test_app.py
+++ b/ForgeDiscussion/forgediscussion/tests/test_app.py
@@ -45,14 +45,18 @@ class TestBulkExport(TestDiscussionApiBase):
         forums = sorted(discussion['forums'], key=lambda x: x['name'])
 
         assert_equal(forums[0]['shortname'], u'general')
-        assert_equal(forums[0]['description'], u'Forum about anything you want to talk about.')
+        assert_equal(
+            forums[0]['description'], u'Forum about anything you want to talk about.')
         assert_equal(forums[0]['name'], u'General Discussion')
         forums[0]['threads'] = sorted(forums[0]['threads'],
-            key=lambda x: x['posts'][0]['subject'])
-        assert_equal(forums[0]['threads'][0]['posts'][0]['text'], u'Hi boys and girls')
-        assert_equal(forums[0]['threads'][0]['posts'][0]['subject'], u'Hi guys')
+                                      key=lambda x: x['posts'][0]['subject'])
+        assert_equal(
+            forums[0]['threads'][0]['posts'][0]['text'], u'Hi boys and girls')
+        assert_equal(
+            forums[0]['threads'][0]['posts'][0]['subject'], u'Hi guys')
         assert_equal(forums[0]['threads'][1]['posts'][0]['text'], u'1st post')
-        assert_equal(forums[0]['threads'][1]['posts'][0]['subject'], u"Let's talk")
+        assert_equal(
+            forums[0]['threads'][1]['posts'][0]['subject'], u"Let's talk")
         assert_equal(forums[1]['shortname'], u'héllo')
         assert_equal(forums[1]['description'], u'Say héllo here')
         assert_equal(forums[1]['name'], u'Say Héllo')

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c93733ac/ForgeDiscussion/forgediscussion/tests/test_forum_roles.py
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/tests/test_forum_roles.py b/ForgeDiscussion/forgediscussion/tests/test_forum_roles.py
index 18b1f26..44d6989 100644
--- a/ForgeDiscussion/forgediscussion/tests/test_forum_roles.py
+++ b/ForgeDiscussion/forgediscussion/tests/test_forum_roles.py
@@ -22,15 +22,18 @@ from allura import model as M
 from allura.lib import security
 from allura.tests import decorators as td
 
+
 def setUp():
     setup_basic_test()
     setup_global_objects()
 
+
 @td.with_discussion
 def test_role_assignments():
     admin = M.User.by_username('test-admin')
     user = M.User.by_username('test-user')
     anon = M.User.anonymous()
+
     def check_access(perm):
         pred = security.has_access(c.app, perm)
         return pred(user=admin), pred(user=user), pred(user=anon)

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c93733ac/ForgeDiscussion/forgediscussion/utils.py
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/utils.py b/ForgeDiscussion/forgediscussion/utils.py
index 3d88d9a..d9128d9 100644
--- a/ForgeDiscussion/forgediscussion/utils.py
+++ b/ForgeDiscussion/forgediscussion/utils.py
@@ -23,34 +23,38 @@ from allura.lib import helpers as h
 from allura.model import ProjectRole, ACE, ALL_PERMISSIONS, DENY_ALL
 from forgediscussion import model as DM
 
+
 def save_forum_icon(forum, icon):
-    if forum.icon: forum.icon.delete()
+    if forum.icon:
+        forum.icon.delete()
     DM.ForumFile.save_image(
         icon.filename, icon.file, content_type=icon.type,
         square=True, thumbnail_size=(48, 48),
         thumbnail_meta=dict(forum_id=forum._id))
 
+
 def create_forum(app, new_forum):
     if 'parent' in new_forum and new_forum['parent']:
         parent_id = ObjectId(str(new_forum['parent']))
         shortname = (DM.Forum.query.get(_id=parent_id).shortname + '/'
-                        + new_forum['shortname'])
+                     + new_forum['shortname'])
     else:
-        parent_id=None
+        parent_id = None
         shortname = new_forum['shortname']
-    description = new_forum.get('description','')
+    description = new_forum.get('description', '')
 
     f = DM.Forum(app_config_id=app.config._id,
-                    parent_id=parent_id,
-                    name=h.really_unicode(new_forum['name']),
-                    shortname=h.really_unicode(shortname),
-                    description=h.really_unicode(description),
-                    members_only=new_forum.get('members_only', False),
-                    anon_posts=new_forum.get('anon_posts', False),
-                    monitoring_email=new_forum.get('monitoring_email', None),
-                    )
+                 parent_id=parent_id,
+                 name=h.really_unicode(new_forum['name']),
+                 shortname=h.really_unicode(shortname),
+                 description=h.really_unicode(description),
+                 members_only=new_forum.get('members_only', False),
+                 anon_posts=new_forum.get('anon_posts', False),
+                 monitoring_email=new_forum.get('monitoring_email', None),
+                 )
     if f.members_only and f.anon_posts:
-        flash('You cannot have anonymous posts in a members only forum.', 'warning')
+        flash('You cannot have anonymous posts in a members only forum.',
+              'warning')
         f.anon_posts = False
     if f.members_only:
         role_developer = ProjectRole.by_name('Developer')._id

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c93733ac/ForgeDiscussion/forgediscussion/widgets/admin.py
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/widgets/admin.py b/ForgeDiscussion/forgediscussion/widgets/admin.py
index 9f1c449..bb954b1 100644
--- a/ForgeDiscussion/forgediscussion/widgets/admin.py
+++ b/ForgeDiscussion/forgediscussion/widgets/admin.py
@@ -29,10 +29,11 @@ from allura.lib.widgets import form_fields as ffw
 from allura.lib import helpers as h
 from forgediscussion import model as DM
 
+
 class OptionsAdmin(ff.AdminForm):
-    defaults=dict(
+    defaults = dict(
         ff.ForgeForm.defaults,
-        submit_text = 'Save')
+        submit_text='Save')
 
     @property
     def fields(self):
@@ -41,48 +42,57 @@ class OptionsAdmin(ff.AdminForm):
                 name='PostingPolicy',
                 label='Posting Policy',
                 options=[
-                    ew.Option(py_value='ApproveOnceModerated', label='Approve Once Moderated'),
+                    ew.Option(py_value='ApproveOnceModerated',
+                              label='Approve Once Moderated'),
                     ew.Option(py_value='ApproveAll', label='Approve All')])
         ]
         return fields
 
+
 class AddForum(ff.AdminForm):
     template = 'jinja:forgediscussion:templates/discussion_widgets/add_forum.html'
-    defaults=dict(
+    defaults = dict(
         ff.ForgeForm.defaults,
         name="add_forum",
         value=None,
         app=None,
-        submit_text = 'Save')
+        submit_text='Save')
 
     @property
     def fields(self):
         fields = [
             ew.HiddenField(name='app_id', label='App'),
-            ew.TextField(name='name', label='Name', validator=fev.UnicodeString()),
+            ew.TextField(name='name', label='Name',
+                         validator=fev.UnicodeString()),
             ew.TextField(name='shortname', label='Short Name',
                          validator=All(
-                                 fev.Regex(ur"^[^\s\/\.]*$", not_empty=True, messages={
-                                    'invalid':'Shortname cannot contain space . or /',
-                                    'empty':'You must create a short name for the forum.'}),
-                                 UniqueForumShortnameValidator())),
+                             fev.Regex(ur"^[^\s\/\.]*$", not_empty=True, messages={
+                                 'invalid': 'Shortname cannot contain space . or /',
+                                 'empty': 'You must create a short name for the forum.'}),
+                             UniqueForumShortnameValidator())),
             ew.TextField(name='parent', label='Parent Forum'),
-            ew.TextField(name='description', label='Description',validator=fev.UnicodeString()),
-            ew.TextField(name='monitoring_email', label='Monitoring Email',validator=fev.Email()),
+            ew.TextField(name='description', label='Description',
+                         validator=fev.UnicodeString()),
+            ew.TextField(name='monitoring_email',
+                         label='Monitoring Email', validator=fev.Email()),
             ffw.FileChooser(name='icon', label='Icon'),
             ew.Checkbox(name="members_only", label="Developer Only"),
             ew.Checkbox(name="anon_posts", label="Allow Anonymous Posts")
         ]
         return fields
 
+
 class AddForumShort(AddForum):
     template = 'jinja:forgediscussion:templates/discussion_widgets/add_forum_short.html'
 
+
 class UniqueForumShortnameValidator(fev.FancyValidator):
 
     def _to_python(self, value, state):
-        forums = DM.Forum.query.find(dict(app_config_id=ObjectId(state.full_dict['app_id']))).all()
+        forums = DM.Forum.query.find(
+            dict(app_config_id=ObjectId(state.full_dict['app_id']))).all()
         value = h.really_unicode(value.lower() or '')
-        if value in [ f.shortname for f in forums ]:
-            raise formencode.Invalid('A forum already exists with that short name, please choose another.', value, state)
+        if value in [f.shortname for f in forums]:
+            raise formencode.Invalid(
+                'A forum already exists with that short name, please choose another.', value, state)
         return value


Mime
View raw message