Browse Source

Added option to track the topic upon creation

sh4nks 10 years ago
parent
commit
5ae8af0523
1 changed files with 8 additions and 1 deletions
  1. 8 1
      flaskbb/forum/forms.py

+ 8 - 1
flaskbb/forum/forms.py

@@ -9,7 +9,7 @@
     :license: BSD, see LICENSE for more details.
 """
 from flask.ext.wtf import Form
-from wtforms import TextAreaField, TextField, SelectMultipleField
+from wtforms import TextAreaField, TextField, SelectMultipleField, BooleanField
 from wtforms.validators import Required, Optional, Length
 
 from flaskbb.forum.models import Topic, Post, Report, Forum
@@ -37,12 +37,19 @@ class ReplyForm(Form):
 class NewTopicForm(ReplyForm):
     title = TextField("Topic Title", validators=[
         Required(message="A topic title is required")])
+
     content = TextAreaField("Content", validators=[
         Required(message="You cannot post a reply without content.")])
 
+    track_topic = BooleanField("Track this topic", default=False, validators=[
+        Optional()])
+
     def save(self, user, forum):
         topic = Topic(title=self.title.data)
         post = Post(content=self.content.data)
+
+        if self.track_topic.data:
+            user.track_topic(topic)
         return topic.save(user=user, forum=forum, post=post)