def post(self, post_id): post = Post.query.filter(Post.id == post_id).first_or_404() if not Permission(Has("makehidden"), IsAtleastModeratorInForum(forum=post.topic.forum)): flash(_("You do not have permission to hide this post"), "danger") return redirect(post.topic.url) if post.hidden: flash(_("Post is already hidden"), "warning") return redirect(post.topic.url) first_post = post.first_post post.hide(current_user) post.save() if first_post: flash(_("Topic hidden"), "success") else: flash(_("Post hidden"), "success") if post.first_post and not Permission(Has("viewhidden")): return redirect(post.topic.forum.url) return redirect(post.topic.url)
def post(self, topic_id, slug=None): topic = Topic.query.with_hidden().filter_by(id=topic_id).first_or_404() if not Permission(Has('makehidden'), IsAtleastModeratorInForum(forum=topic.forum)): flash(_("You do not have permission to hide this topic"), "danger") return redirect(topic.url) topic.hide(user=current_user) topic.save() if Permission(Has('viewhidden')): return redirect(topic.url) return redirect(topic.forum.url)
def post(self, topic_id, slug=None): topic = Topic.query.filter_by(id=topic_id).first_or_404() if not Permission(Has("makehidden"), IsAtleastModeratorInForum(forum=topic.forum)): flash(_("You do not have permission to unhide this topic"), "danger") return redirect(topic.url) topic.unhide() topic.save() return redirect(topic.url)
def post(self, post_id): post = Post.query.filter(Post.id == post_id).first_or_404() if not Permission(Has('makehidden'), IsAtleastModeratorInForum(forum=post.topic.forum)): flash(_("You do not have permission to unhide this post"), "danger") return redirect(post.topic.url) if not post.hidden: flash(_("Post is already unhidden"), "warning") redirect(post.topic.url) post.unhide() post.save() flash(_("Post unhidden"), "success") return redirect(post.topic.url)
def do_topic_action(topics, user, action, reverse): # noqa: C901 """Executes a specific action for topics. Returns a list with the modified topic objects. :param topics: A iterable with ``Topic`` objects. :param user: The user object which wants to perform the action. :param action: One of the following actions: locked, important and delete. :param reverse: If the action should be done in a reversed way. For example, to unlock a topic, ``reverse`` should be set to ``True``. """ if not topics: return False from flaskbb.utils.requirements import ( IsAtleastModeratorInForum, CanDeleteTopic, Has, ) if not Permission(IsAtleastModeratorInForum(forum=topics[0].forum)): flash( _("You do not have the permissions to execute this action."), "danger", ) return False modified_topics = 0 if action not in {"delete", "hide", "unhide"}: for topic in topics: if getattr(topic, action) and not reverse: continue setattr(topic, action, not reverse) modified_topics += 1 topic.save() elif action == "delete": if not Permission(CanDeleteTopic): flash( _("You do not have the permissions to delete these topics."), "danger", ) return False for topic in topics: modified_topics += 1 topic.delete() elif action == "hide": if not Permission(Has("makehidden")): flash( _("You do not have the permissions to hide these topics."), "danger", ) return False for topic in topics: if topic.hidden: continue modified_topics += 1 topic.hide(user) elif action == "unhide": if not Permission(Has("makehidden")): flash( _("You do not have the permissions to unhide these topics."), "danger", ) return False for topic in topics: if not topic.hidden: continue modified_topics += 1 topic.unhide() return modified_topics
def fulfill(self, user): if not hub_current_server: raise FlaskBBError("Could not get current server id") return bool(Permission(Has(hub_current_server.management_permission), identity=user))
def fulfill(self, user): if not hub_current_server: abort(404) return bool(Permission(Has(hub_current_server.base_permission), identity=user))