make sure form doesn't make it possible to post to locked topic
This commit is contained in:
		@@ -71,6 +71,18 @@ class Users(Model):
 | 
				
			|||||||
                subscriptions.user_id = ?"""
 | 
					                subscriptions.user_id = ?"""
 | 
				
			||||||
        return db.query(q, self.id)
 | 
					        return db.query(q, self.id)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def can_post_to_topic(self, topic):
 | 
				
			||||||
 | 
					        if self.is_guest():
 | 
				
			||||||
 | 
					            return False
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if self.is_mod():
 | 
				
			||||||
 | 
					            return True
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if topic['is_locked']:
 | 
				
			||||||
 | 
					            return False
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return True
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class Topics(Model):
 | 
					class Topics(Model):
 | 
				
			||||||
    table = "topics"
 | 
					    table = "topics"
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -8,7 +8,8 @@
 | 
				
			|||||||
    <label for="topic_id">Topic</label>
 | 
					    <label for="topic_id">Topic</label>
 | 
				
			||||||
    <select name="topic_id" id="topic_id" autocomplete="off">
 | 
					    <select name="topic_id" id="topic_id" autocomplete="off">
 | 
				
			||||||
      {% for topic in all_topics %}
 | 
					      {% for topic in all_topics %}
 | 
				
			||||||
        <option value="{{ topic['id'] }}" {{"selected" if (request.args.get('topic_id')) == (topic['id'] | string) else ""}}>{{ topic['name'] }}</option>
 | 
					        {% set disable_topic = active_user and not active_user.can_post_to_topic(topic) %}
 | 
				
			||||||
 | 
					        <option value="{{ topic['id'] }}" {{"selected" if (request.args.get('topic_id')) == (topic['id'] | string) else ""}} {{'disabled' if disable_topic else ''}} >{{ topic['name'] }}{{ ' (locked)' if topic.is_locked }}</option>
 | 
				
			||||||
      {% endfor %}
 | 
					      {% endfor %}
 | 
				
			||||||
    </select><br>
 | 
					    </select><br>
 | 
				
			||||||
    <label for="title">Thread title</label>
 | 
					    <label for="title">Thread title</label>
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user