Просмотр исходного кода

Cleanup subforum changes

Fix example data creating topics in categories.
Don't render "posts" table on categories, and hide the new topic button.
Added a check to new_topic that redirects requests away if the new_topic's forum_id is a category.
RJackson 11 лет назад
Родитель
Сommit
8cc501643b
3 измененных файлов с 8 добавлено и 2 удалено
  1. 4 0
      flaskbb/forum/views.py
  2. 3 1
      flaskbb/templates/forum/forum.html
  3. 1 1
      manage.py

+ 4 - 0
flaskbb/forum/views.py

@@ -103,6 +103,10 @@ def view_post(post_id):
 def new_topic(forum_id):
     forum = Forum.query.filter_by(id=forum_id).first()
 
+    if forum.is_category:
+        flash("You cannot post a topic in a category.", "error")
+        return redirect(url_for('forum.view_forum', forum_id=forum.id))
+
     if not perm_post_topic(user=current_user, forum=forum):
         flash("You do not have the permissions to create a new topic.", "error")
         return redirect(url_for('forum.view_forum', forum_id=forum.id))

+ 3 - 1
flaskbb/templates/forum/forum.html

@@ -17,7 +17,7 @@
     {{ render_pagination(topics, url_for('forum.view_forum', forum_id=forum.id)) }}
 </div> <!-- end span pagination -->
 
-{% if current_user|post_topic(forum) %}
+{% if current_user|post_topic(forum) and not forum.is_category %}
 <div class="pull-right" style="padding-bottom: 10px">
     <a href="{{ url_for('forum.new_topic', forum_id=forum.id) }}" class="btn btn-primary">New Topic</a>
 </div>
@@ -88,6 +88,7 @@
 </table>
 {% endif %}
 
+{% if not forum.is_category %}
 <table class="table table-bordered">
     <thead>
         <tr>
@@ -138,5 +139,6 @@
 
     </tbody>
 </table>
+{% endif %}
 
 {% endblock %}

+ 1 - 1
manage.py

@@ -194,7 +194,7 @@ def createall():
             db.session.add(forum)
 
     # create 1 topic in each forum
-    for k in range(1, 5):
+    for k in [2, 3, 5, 6]:  # Forum ids are not sequential because categories.
         topic = Topic()
         topic.first_post = Post()