def flaskbb_load_blueprints(app: Flask): donations = Blueprint("donations", __name__) register_view(donations, routes=['/qiwi_hook'], view_func=QiwiHook.as_view('qiwi_hook')) app.register_blueprint(donations) app.before_first_request(lambda: register_webhooks_service(app))
def flaskbb_load_blueprints(app): auth = Blueprint("auth", __name__) def login_rate_limit(): """Dynamically load the rate limiting config from the database.""" # [count] [per|/] [n (optional)] [second|minute|hour|day|month|year] return "{count}/{timeout}minutes".format( count=flaskbb_config["AUTH_REQUESTS"], timeout=flaskbb_config["AUTH_TIMEOUT"]) def login_rate_limit_message(): """Display the amount of time left until the user can access the requested resource again.""" current_limit = getattr(g, 'view_rate_limit', None) if current_limit is not None: window_stats = limiter.limiter.get_window_stats(*current_limit) reset_time = datetime.utcfromtimestamp(window_stats[0]) timeout = reset_time - datetime.utcnow() return "{timeout}".format(timeout=format_timedelta(timeout)) @auth.before_request def check_rate_limiting(): """Check the the rate limits for each request for this blueprint.""" if not flaskbb_config["AUTH_RATELIMIT_ENABLED"]: return None return limiter.check() @auth.errorhandler(429) def login_rate_limit_error(error): """Register a custom error handler for a 'Too Many Requests' (HTTP CODE 429) error.""" return render_template("errors/too_many_logins.html", timeout=error.description) # Activate rate limiting on the whole blueprint limiter.limit(login_rate_limit, error_message=login_rate_limit_message)(auth) register_view(auth, routes=['/discord'], view_func=DiscordAuthorize.as_view('discord')) register_view( auth, routes=['/discord-callback'], view_func=DiscordAuthorizeCallback.as_view( 'discord-callback', authentication_manager_factory=authentication_manager_factory, registration_service_factory=registration_service_factory)) register_view(auth, routes=['/logout'], view_func=Logout.as_view('logout')) app.register_blueprint(auth, url_prefix=app.config['AUTH_URL_PREFIX'])
def flaskbb_load_blueprints(app): management = Blueprint("management", __name__) @management.before_request def check_fresh_login(): """Checks if the login is fresh for the current user, otherwise the user has to reauthenticate.""" if not login_fresh(): return current_app.login_manager.needs_refresh() # Categories register_view( management, routes=['/category/add'], view_func=AddCategory.as_view('add_category') ) register_view( management, routes=["/category/<int:category_id>/delete"], view_func=DeleteCategory.as_view('delete_category') ) register_view( management, routes=['/category/<int:category_id>/edit'], view_func=EditCategory.as_view('edit_category') ) # Forums register_view( management, routes=['/forums/add', '/forums/<int:category_id>/add'], view_func=AddForum.as_view('add_forum') ) register_view( management, routes=['/forums/<int:forum_id>/delete'], view_func=DeleteForum.as_view('delete_forum') ) register_view( management, routes=['/forums/<int:forum_id>/edit'], view_func=EditForum.as_view('edit_forum') ) register_view( management, routes=['/forums'], view_func=Forums.as_view('forums') ) # Groups register_view( management, routes=['/groups/add'], view_func=AddGroup.as_view('add_group') ) register_view( management, routes=['/groups/<int:group_id>/delete', '/groups/delete'], view_func=DeleteGroup.as_view('delete_group') ) register_view( management, routes=['/groups/<int:group_id>/edit'], view_func=EditGroup.as_view('edit_group') ) register_view( management, routes=['/groups'], view_func=Groups.as_view('groups') ) # Plugins register_view( management, routes=['/plugins/<path:name>/disable'], view_func=DisablePlugin.as_view('disable_plugin') ) register_view( management, routes=['/plugins/<path:name>/enable'], view_func=EnablePlugin.as_view('enable_plugin') ) register_view( management, routes=['/plugins/<path:name>/install'], view_func=InstallPlugin.as_view('install_plugin') ) register_view( management, routes=['/plugins/<path:name>/uninstall'], view_func=UninstallPlugin.as_view('uninstall_plugin') ) register_view( management, routes=['/plugins'], view_func=PluginsView.as_view('plugins') ) # Reports register_view( management, routes=['/reports/<int:report_id>/delete', '/reports/delete'], view_func=DeleteReport.as_view('delete_report') ) register_view( management, routes=['/reports/<int:report_id>/markread', '/reports/markread'], view_func=MarkReportRead.as_view('report_markread') ) register_view( management, routes=['/reports/unread'], view_func=UnreadReports.as_view('unread_reports') ) register_view( management, routes=['/reports'], view_func=Reports.as_view('reports') ) # Settings register_view( management, routes=[ '/settings', '/settings/<path:slug>', '/settings/plugin/<path:plugin>' ], view_func=ManagementSettings.as_view('settings') ) # Users register_view( management, routes=['/users/add'], view_func=AddUser.as_view('add_user') ) register_view( management, routes=['/users/banned'], view_func=BannedUsers.as_view('banned_users') ) register_view( management, routes=['/users/ban', '/users/<int:user_id>/ban'], view_func=BanUser.as_view('ban_user') ) register_view( management, routes=['/users/delete', '/users/<int:user_id>/delete'], view_func=DeleteUser.as_view('delete_user') ) register_view( management, routes=['/users/<int:user_id>/edit'], view_func=EditUser.as_view('edit_user') ) register_view( management, routes=['/users/unban', '/users/<int:user_id>/unban'], view_func=UnbanUser.as_view('unban_user') ) register_view( management, routes=['/users'], view_func=ManageUsers.as_view('users') ) register_view( management, routes=['/celerystatus'], view_func=CeleryStatus.as_view('celery_status') ) register_view( management, routes=['/'], view_func=ManagementOverview.as_view('overview') ) app.register_blueprint( management, url_prefix=app.config["ADMIN_URL_PREFIX"] )
def flaskbb_load_blueprints(app): auth = Blueprint("auth", __name__) def login_rate_limit(): """Dynamically load the rate limiting config from the database.""" # [count] [per|/] [n (optional)] [second|minute|hour|day|month|year] return "{count}/{timeout}minutes".format( count=flaskbb_config["AUTH_REQUESTS"], timeout=flaskbb_config["AUTH_TIMEOUT"]) def login_rate_limit_message(): """Display the amount of time left until the user can access the requested resource again.""" current_limit = getattr(g, 'view_rate_limit', None) if current_limit is not None: window_stats = limiter.limiter.get_window_stats(*current_limit) reset_time = datetime.utcfromtimestamp(window_stats[0]) timeout = reset_time - datetime.utcnow() return "{timeout}".format(timeout=format_timedelta(timeout)) @auth.before_request def check_rate_limiting(): """Check the the rate limits for each request for this blueprint.""" if not flaskbb_config["AUTH_RATELIMIT_ENABLED"]: return None return limiter.check() @auth.errorhandler(429) def login_rate_limit_error(error): """Register a custom error handler for a 'Too Many Requests' (HTTP CODE 429) error.""" return render_template("errors/too_many_logins.html", timeout=error.description) def registration_service_factory(): with app.app_context(): blacklist = [ w.strip() for w in flaskbb_config["AUTH_USERNAME_BLACKLIST"].split(",") ] requirements = registration.UsernameRequirements( min=flaskbb_config["AUTH_USERNAME_MIN_LENGTH"], max=flaskbb_config["AUTH_USERNAME_MAX_LENGTH"], blacklist=blacklist) validators = [ registration.EmailUniquenessValidator(User), registration.UsernameUniquenessValidator(User), registration.UsernameValidator(requirements) ] return RegistrationService(validators, UserRepository(db)) # Activate rate limiting on the whole blueprint limiter.limit(login_rate_limit, error_message=login_rate_limit_message)(auth) register_view(auth, routes=['/logout'], view_func=Logout.as_view('logout')) register_view(auth, routes=['/login'], view_func=Login.as_view('login')) register_view(auth, routes=['/reauth'], view_func=Reauth.as_view('reauth')) register_view( auth, routes=['/register'], view_func=Register.as_view( 'register', registration_service_factory=registration_service_factory)) register_view(auth, routes=['/reset-password'], view_func=ForgotPassword.as_view('forgot_password')) def reset_service_factory(): token_serializer = FlaskBBTokenSerializer(app.config['SECRET_KEY'], expiry=timedelta(hours=1)) verifiers = [EmailMatchesUserToken(User)] return ResetPasswordService(token_serializer, User, token_verifiers=verifiers) register_view(auth, routes=['/reset-password/<token>'], view_func=ResetPassword.as_view( 'reset_password', password_reset_service_factory=reset_service_factory)) register_view( auth, routes=['/activate'], view_func=RequestActivationToken.as_view('request_activation_token')) register_view(auth, routes=['/activate/confirm', '/activate/confirm/<token>'], view_func=ActivateAccount.as_view('activate_account')) app.register_blueprint(auth, url_prefix=app.config['AUTH_URL_PREFIX'])
if form.validate_on_submit(): user = User.query.filter( User.username == form.username.data).first_or_404() user.rank = rank db.session.commit() flash("Rank {} given to {}".format(rank.rank_name, user.username), "success") return redirect(url_for("ranks_management.index")) return render_template("ranks_management_apply.html", form=form, rank=rank) register_view( ranks_management, routes=["/delete/<id>"], view_func=DeleteRankView.as_view("delete_rank"), ) register_view(ranks_management, routes=["/edit/<id>"], view_func=EditRankView.as_view("edit_rank")) register_view(ranks_management, routes=["/add"], view_func=AddRankView.as_view("add_rank")) register_view( ranks_management, routes=["/apply/<id>"], view_func=ApplyCustomRank.as_view("apply_rank"), )
Conversation.trash == True, ).\ order_by(Conversation.date_modified.desc()). \ paginate(page, flaskbb_config['TOPICS_PER_PAGE'], False) message_count = Conversation.query. \ filter(Conversation.user_id == current_user.id).\ count() return render_template("message/trash.html", conversations=conversations, message_count=message_count) register_view(message, routes=['/drafts'], view_func=DraftMessages.as_view('drafts')) register_view(message, routes=['/', '/inbox'], view_func=Inbox.as_view('inbox')) register_view(message, routes=['/<int:conversation_id>/delete'], view_func=DeleteConversation.as_view('delete_conversation')) register_view(message, routes=["/<int:conversation_id>/edit"], view_func=EditConversation.as_view('edit_conversation')) register_view(message, routes=['/<int:conversation_id>/move'], view_func=MoveConversation.as_view('move_conversation')) register_view(message, routes=['/<int:conversation_id>/restore'],
def flaskbb_load_blueprints(app): auth = Blueprint("auth", __name__) def login_rate_limit(): """Dynamically load the rate limiting config from the database.""" # [count] [per|/] [n (optional)] [second|minute|hour|day|month|year] return "{count}/{timeout}minutes".format( count=flaskbb_config["AUTH_REQUESTS"], timeout=flaskbb_config["AUTH_TIMEOUT"] ) def login_rate_limit_message(): """Display the amount of time left until the user can access the requested resource again.""" current_limit = getattr(g, 'view_rate_limit', None) if current_limit is not None: window_stats = limiter.limiter.get_window_stats(*current_limit) reset_time = datetime.utcfromtimestamp(window_stats[0]) timeout = reset_time - datetime.utcnow() return "{timeout}".format(timeout=format_timedelta(timeout)) @auth.before_request def check_rate_limiting(): """Check the the rate limits for each request for this blueprint.""" if not flaskbb_config["AUTH_RATELIMIT_ENABLED"]: return None return limiter.check() @auth.errorhandler(429) def login_rate_limit_error(error): """Register a custom error handler for a 'Too Many Requests' (HTTP CODE 429) error.""" return render_template( "errors/too_many_logins.html", timeout=error.description ) # Activate rate limiting on the whole blueprint limiter.limit( login_rate_limit, error_message=login_rate_limit_message )(auth) register_view(auth, routes=['/logout'], view_func=Logout.as_view('logout')) register_view( auth, routes=['/login'], view_func=Login.as_view( 'login', authentication_manager_factory=authentication_manager_factory ) ) register_view( auth, routes=['/reauth'], view_func=Reauth.as_view( 'reauth', reauthentication_factory=reauthentication_manager_factory ) ) register_view( auth, routes=['/register'], view_func=Register.as_view( 'register', registration_service_factory=registration_service_factory ) ) register_view( auth, routes=['/reset-password'], view_func=ForgotPassword.as_view( 'forgot_password', password_reset_service_factory=reset_service_factory ) ) register_view( auth, routes=['/reset-password/<token>'], view_func=ResetPassword.as_view( 'reset_password', password_reset_service_factory=reset_service_factory ) ) register_view( auth, routes=['/activate'], view_func=RequestActivationToken.as_view( 'request_activation_token', account_activator_factory=account_activator_factory ) ) register_view( auth, routes=['/activate/confirm'], view_func=ActivateAccount.as_view( 'activate_account', account_activator_factory=account_activator_factory ) ) register_view( auth, routes=['/activate/confirm/<token>'], view_func=AutoActivateAccount.as_view( 'autoactivate_account', account_activator_factory=account_activator_factory ) ) app.register_blueprint(auth, url_prefix=app.config['AUTH_URL_PREFIX'])
def flaskbb_load_blueprints(app): forum = Blueprint("forum", __name__) register_view(forum, routes=[ "/category/<int:category_id>", "/category/<int:category_id>-<slug>" ], view_func=ViewCategory.as_view("view_category")) register_view(forum, routes=[ "/forum/<int:forum_id>/edit", "/forum/<int:forum_id>-<slug>/edit" ], view_func=ManageForum.as_view("manage_forum")) register_view( forum, routes=["/forum/<int:forum_id>", "/forum/<int:forum_id>-<slug>"], view_func=ViewForum.as_view("view_forum")) register_view( forum, routes=["/<int:forum_id>/markread", "/<int:forum_id>-<slug>/markread"], view_func=MarkRead.as_view("markread")) register_view(forum, routes=[ "/<int:forum_id>/topic/new", "/<int:forum_id>-<slug>/topic/new" ], view_func=NewTopic.as_view("new_topic")) register_view( forum, routes=[ "/topic/<int:topic_id>/edit", "/topic/<int:topic_id>-<slug>/edit", ], view_func=EditTopic.as_view("edit_topic"), ) register_view(forum, routes=["/memberlist"], view_func=MemberList.as_view("memberlist")) register_view(forum, routes=["/post/<int:post_id>/delete"], view_func=DeletePost.as_view("delete_post")) register_view(forum, routes=["/post/<int:post_id>/edit"], view_func=EditPost.as_view("edit_post")) register_view(forum, routes=["/post/<int:post_id>/raw"], view_func=RawPost.as_view("raw_post")) register_view(forum, routes=["/post/<int:post_id>/report"], view_func=ReportView.as_view("report_post")) register_view(forum, routes=["/post/<int:post_id>"], view_func=ViewPost.as_view("view_post")) register_view(forum, routes=["/search"], view_func=Search.as_view("search")) register_view(forum, routes=[ "/topic/<int:topic_id>/delete", "/topic/<int:topic_id>-<slug>/delete" ], view_func=DeleteTopic.as_view("delete_topic")) register_view(forum, routes=[ "/topic/<int:topic_id>/highlight", "/topic/<int:topic_id>-<slug>/highlight" ], view_func=HighlightTopic.as_view("highlight_topic")) register_view(forum, routes=[ "/topic/<int:topic_id>/lock", "/topic/<int:topic_id>-<slug>/lock" ], view_func=LockTopic.as_view("lock_topic")) register_view(forum, routes=[ "/topic/<int:topic_id>/post/<int:post_id>/reply", "/topic/<int:topic_id>-<slug>/post/<int:post_id>/reply" ], view_func=NewPost.as_view("reply_post")) register_view(forum, routes=[ "/topic/<int:topic_id>/post/new", "/topic/<int:topic_id>-<slug>/post/new" ], view_func=NewPost.as_view("new_post")) register_view( forum, routes=["/topic/<int:topic_id>", "/topic/<int:topic_id>-<slug>"], view_func=ViewTopic.as_view("view_topic")) register_view(forum, routes=[ "/topic/<int:topic_id>/trivialize", "/topic/<int:topic_id>-<slug>/trivialize" ], view_func=TrivializeTopic.as_view("trivialize_topic")) register_view(forum, routes=[ "/topic/<int:topic_id>/unlock", "/topic/<int:topic_id>-<slug>/unlock" ], view_func=UnlockTopic.as_view("unlock_topic")) register_view(forum, routes=[ "/topictracker/<int:topic_id>/add", "/topictracker/<int:topic_id>-<slug>/add" ], view_func=TrackTopic.as_view("track_topic")) register_view(forum, routes=[ "/topictracker/<int:topic_id>/delete", "/topictracker/<int:topic_id>-<slug>/delete" ], view_func=UntrackTopic.as_view("untrack_topic")) register_view(forum, routes=["/topictracker"], view_func=TopicTracker.as_view("topictracker")) register_view(forum, routes=["/"], view_func=ForumIndex.as_view("index")) register_view(forum, routes=["/who-is-online"], view_func=WhoIsOnline.as_view("who_is_online")) register_view(forum, routes=[ "/topic/<int:topic_id>/hide", "/topic/<int:topic_id>-<slug>/hide" ], view_func=HideTopic.as_view("hide_topic")) register_view(forum, routes=[ "/topic/<int:topic_id>/unhide", "/topic/<int:topic_id>-<slug>/unhide" ], view_func=UnhideTopic.as_view("unhide_topic")) register_view(forum, routes=["/post/<int:post_id>/hide"], view_func=HidePost.as_view("hide_post")) register_view(forum, routes=["/post/<int:post_id>/unhide"], view_func=UnhidePost.as_view("unhide_post")) register_view(forum, routes=["/markdown", "/markdown/<path:mode>"], view_func=MarkdownPreview.as_view("markdown_preview")) forum.before_request(force_login_if_needed) app.register_blueprint(forum, url_prefix=app.config["FORUM_URL_PREFIX"])
class AllUserPosts(MethodView): def get(self, username): page = request.args.get("page", 1, type=int) user = User.query.filter_by(username=username).first_or_404() posts = user.all_posts(page, current_user) return render_template("user/all_posts.html", user=user, posts=posts) class UserProfile(MethodView): def get(self, username): user = User.query.filter_by(username=username).first_or_404() return render_template("user/profile.html", user=user) register_view(user, routes=['/settings/email'], view_func=ChangeEmail.as_view('change_email')) register_view(user, routes=['/settings/general'], view_func=UserSettings.as_view('settings')) register_view(user, routes=['/settings/password'], view_func=ChangePassword.as_view('change_password')) register_view(user, routes=["/settings/user-details"], view_func=ChangeUserDetails.as_view('change_user_details')) register_view(user, routes=['/<username>/posts'], view_func=AllUserPosts.as_view('view_all_posts')) register_view(user, routes=['/<username>/topics'],
decorators = [allows.requires(IsAdmin)] def post(self, plugin): plugin = get_plugin_from_all(plugin) if not plugin.installed: plugin.install() Setting.invalidate_cache() flash(_("Plugin has been installed."), "success") else: flash(_("Cannot install plugin."), "danger") return redirect(url_for("management.plugins")) register_view(management, routes=['/category/add'], view_func=AddCategory.as_view('add_category')) register_view( management, routes=["/category/<int:category_id>/delete"], view_func=DeleteCategory.as_view('delete_category') ) register_view( management, routes=['/category/<int:category_id>/edit'], view_func=EditCategory.as_view('edit_category') ) register_view( management, routes=['/forums/add', '/forums/<int:category_id>/add'], view_func=AddForum.as_view('add_forum') )
form.populate_obj(settings) settings.save() flash(_('Your subscription settings have been updated'), 'success') return redirect(url_for('.manage')) def _get_choices(self): 'Get list of forums to choose from' return [ (category.title, [(forum.id, forum.title) for forum, x in forums]) for category, forums in Category.get_all(user=real(current_user)) ] register_view(blueprint, routes=['/manage'], view_func=SubsManage.as_view('manage')) @blueprint.route('/rss/<key>') def rss(key): 'Personalized RSS feed' settings = SubscriptionSettings.query.filter( SubscriptionSettings.rss_key == key).first_or_404() user_id = settings.user_id user = User.query.get(user_id) categories = Category.get_all(user=real(user)) allowed_forums = [] for category, forums in categories: for forum, forumsread in forums:
def flaskbb_load_blueprints(app): forum = Blueprint("forum", __name__) register_view( forum, routes=[ "/category/<int:category_id>", "/category/<int:category_id>-<slug>" ], view_func=ViewCategory.as_view("view_category") ) register_view( forum, routes=[ "/forum/<int:forum_id>/edit", "/forum/<int:forum_id>-<slug>/edit" ], view_func=ManageForum.as_view("manage_forum") ) register_view( forum, routes=["/forum/<int:forum_id>", "/forum/<int:forum_id>-<slug>"], view_func=ViewForum.as_view("view_forum") ) register_view( forum, routes=["/<int:forum_id>/markread", "/<int:forum_id>-<slug>/markread"], view_func=MarkRead.as_view("markread") ) register_view( forum, routes=[ "/<int:forum_id>/topic/new", "/<int:forum_id>-<slug>/topic/new" ], view_func=NewTopic.as_view("new_topic") ) register_view( forum, routes=["/memberlist"], view_func=MemberList.as_view("memberlist") ) register_view( forum, routes=["/post/<int:post_id>/delete"], view_func=DeletePost.as_view("delete_post") ) register_view( forum, routes=["/post/<int:post_id>/edit"], view_func=EditPost.as_view("edit_post") ) register_view( forum, routes=["/post/<int:post_id>/raw"], view_func=RawPost.as_view("raw_post") ) register_view( forum, routes=["/post/<int:post_id>/report"], view_func=ReportView.as_view("report_post") ) register_view( forum, routes=["/post/<int:post_id>"], view_func=ViewPost.as_view("view_post") ) register_view( forum, routes=["/search"], view_func=Search.as_view("search") ) register_view( forum, routes=[ "/topic/<int:topic_id>/delete", "/topic/<int:topic_id>-<slug>/delete" ], view_func=DeleteTopic.as_view("delete_topic") ) register_view( forum, routes=[ "/topic/<int:topic_id>/highlight", "/topic/<int:topic_id>-<slug>/highlight" ], view_func=HighlightTopic.as_view("highlight_topic") ) register_view( forum, routes=[ "/topic/<int:topic_id>/lock", "/topic/<int:topic_id>-<slug>/lock" ], view_func=LockTopic.as_view("lock_topic") ) register_view( forum, routes=[ "/topic/<int:topic_id>/post/<int:post_id>/reply", "/topic/<int:topic_id>-<slug>/post/<int:post_id>/reply" ], view_func=NewPost.as_view("reply_post") ) register_view( forum, routes=[ "/topic/<int:topic_id>/post/new", "/topic/<int:topic_id>-<slug>/post/new" ], view_func=NewPost.as_view("new_post") ) register_view( forum, routes=["/topic/<int:topic_id>", "/topic/<int:topic_id>-<slug>"], view_func=ViewTopic.as_view("view_topic") ) register_view( forum, routes=[ "/topic/<int:topic_id>/trivialize", "/topic/<int:topic_id>-<slug>/trivialize" ], view_func=TrivializeTopic.as_view("trivialize_topic") ) register_view( forum, routes=[ "/topic/<int:topic_id>/unlock", "/topic/<int:topic_id>-<slug>/unlock" ], view_func=UnlockTopic.as_view("unlock_topic") ) register_view( forum, routes=[ "/topictracker/<int:topic_id>/add", "/topictracker/<int:topic_id>-<slug>/add" ], view_func=TrackTopic.as_view("track_topic") ) register_view( forum, routes=[ "/topictracker/<int:topic_id>/delete", "/topictracker/<int:topic_id>-<slug>/delete" ], view_func=UntrackTopic.as_view("untrack_topic") ) register_view( forum, routes=["/topictracker"], view_func=TopicTracker.as_view("topictracker") ) register_view(forum, routes=["/"], view_func=ForumIndex.as_view("index")) register_view( forum, routes=["/who-is-online"], view_func=WhoIsOnline.as_view("who_is_online") ) register_view( forum, routes=[ "/topic/<int:topic_id>/hide", "/topic/<int:topic_id>-<slug>/hide" ], view_func=HideTopic.as_view("hide_topic") ) register_view( forum, routes=[ "/topic/<int:topic_id>/unhide", "/topic/<int:topic_id>-<slug>/unhide" ], view_func=UnhideTopic.as_view("unhide_topic") ) register_view( forum, routes=["/post/<int:post_id>/hide"], view_func=HidePost.as_view("hide_post") ) register_view( forum, routes=["/post/<int:post_id>/unhide"], view_func=UnhidePost.as_view("unhide_post") ) register_view( forum, routes=[ "/markdown", "/markdown/<path:mode>" ], view_func=MarkdownPreview.as_view("markdown_preview") ) forum.before_request(force_login_if_needed) app.register_blueprint(forum, url_prefix=app.config["FORUM_URL_PREFIX"])
if "Like" in request.form: change_user_karma(user.discord, current_user.discord, 1) elif "Dislike" in request.form: change_user_karma(user.discord, current_user.discord, -1) elif "Reset" in request.form: change_user_karma(user.discord, current_user.discord, 0) if post: return redirect(post.url) return redirect(user.url) register_view( hub, routes=["/"], view_func=Hub.as_view("index"), ) register_view( hub, routes=["/control"], view_func=ControlView.as_view("control") ) register_view( hub, routes=["/start"], view_func=StartServer.as_view("start"), )
def get(self): page = request.args.get("page", 1, type=int) conversations = (Conversation.query.filter( Conversation.user_id == current_user.id, Conversation.trash == True, ).order_by(Conversation.date_modified.desc()).paginate( page, flaskbb_config["TOPICS_PER_PAGE"], False)) return render_template("trash.html", conversations=conversations) register_view( conversations_bp, routes=["/drafts"], view_func=DraftMessages.as_view("drafts"), ) register_view(conversations_bp, routes=["/", "/inbox"], view_func=Inbox.as_view("inbox")) register_view( conversations_bp, routes=["/<int:conversation_id>/delete"], view_func=DeleteConversation.as_view("delete_conversation"), ) register_view( conversations_bp, routes=["/<int:conversation_id>/edit"], view_func=EditConversation.as_view("edit_conversation"), )
def flaskbb_load_blueprints(app): user = Blueprint("user", __name__) register_view(user, routes=['/settings/email'], view_func=ChangeEmail.as_view('change_email')) register_view(user, routes=['/settings/general'], view_func=UserSettings.as_view('settings')) register_view(user, routes=['/settings/password'], view_func=ChangePassword.as_view('change_password')) register_view(user, routes=["/settings/user-details"], view_func=ChangeUserDetails.as_view('change_user_details')) register_view(user, routes=['/<username>/posts'], view_func=AllUserPosts.as_view('view_all_posts')) register_view(user, routes=['/<username>/topics'], view_func=AllUserTopics.as_view('view_all_topics')) register_view(user, routes=['/<username>'], view_func=UserProfile.as_view('profile')) app.register_blueprint(user, url_prefix=app.config["USER_URL_PREFIX"])
def flaskbb_load_blueprints(app): user = Blueprint("user", __name__) register_view(user, routes=["/settings/email"], view_func=ChangeEmail.as_view("change_email")) register_view(user, routes=["/settings/general"], view_func=UserSettings.as_view("settings")) register_view( user, routes=["/settings/password"], view_func=ChangePassword.as_view("change_password"), ) register_view( user, routes=["/settings/user-details"], view_func=ChangeUserDetails.as_view("change_user_details"), ) register_view( user, routes=["/user<userid>/posts"], view_func=AllUserPosts.as_view("view_all_posts"), ) register_view( user, routes=["/user<userid>/topics"], view_func=AllUserTopics.as_view("view_all_topics"), ) register_view(user, routes=["/user<userid>"], view_func=UserProfile.as_view("profile")) app.register_blueprint(user, url_prefix=app.config["USER_URL_PREFIX"])
"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) register_view(forum, routes=[ '/category/<int:category_id>', '/category/<int:category_id>-<slug>' ], view_func=ViewCategory.as_view('view_category')) register_view( forum, routes=['/forum/<int:forum_id>/edit', '/forum/<int:forum_id>-<slug>/edit'], view_func=ManageForum.as_view('manage_forum')) register_view(forum, routes=['/forum/<int:forum_id>', '/forum/<int:forum_id>-<slug>'], view_func=ViewForum.as_view('view_forum')) register_view( forum, routes=['/<int:forum_id>/markread', '/<int:forum_id>-<slug>/markread'], view_func=MarkRead.as_view('markread')) register_view( forum,
def flaskbb_load_blueprints(app): forum = Blueprint("forum", __name__) register_view( forum, routes=[ '/category/<int:category_id>', '/category/<int:category_id>-<slug>' ], view_func=ViewCategory.as_view('view_category') ) register_view( forum, routes=[ '/forum/<int:forum_id>/edit', '/forum/<int:forum_id>-<slug>/edit' ], view_func=ManageForum.as_view('manage_forum') ) register_view( forum, routes=['/forum/<int:forum_id>', '/forum/<int:forum_id>-<slug>'], view_func=ViewForum.as_view('view_forum') ) register_view( forum, routes=['/<int:forum_id>/markread', '/<int:forum_id>-<slug>/markread'], view_func=MarkRead.as_view('markread') ) register_view( forum, routes=[ '/<int:forum_id>/topic/new', '/<int:forum_id>-<slug>/topic/new' ], view_func=NewTopic.as_view('new_topic') ) register_view( forum, routes=['/memberlist'], view_func=MemberList.as_view('memberlist') ) register_view( forum, routes=['/post/<int:post_id>/delete'], view_func=DeletePost.as_view('delete_post') ) register_view( forum, routes=['/post/<int:post_id>/edit'], view_func=EditPost.as_view('edit_post') ) register_view( forum, routes=['/post/<int:post_id>/raw'], view_func=RawPost.as_view('raw_post') ) register_view( forum, routes=['/post/<int:post_id>/report'], view_func=ReportView.as_view('report_post') ) register_view( forum, routes=['/post/<int:post_id>'], view_func=ViewPost.as_view('view_post') ) register_view(forum, routes=['/search'], view_func=Search.as_view('search')) register_view( forum, routes=[ '/topic/<int:topic_id>/delete', '/topic/<int:topic_id>-<slug>/delete' ], view_func=DeleteTopic.as_view('delete_topic') ) register_view( forum, routes=[ '/topic/<int:topic_id>/highlight', '/topic/<int:topic_id>-<slug>/highlight' ], view_func=HighlightTopic.as_view('highlight_topic') ) register_view( forum, routes=[ '/topic/<int:topic_id>/lock', '/topic/<int:topic_id>-<slug>/lock' ], view_func=LockTopic.as_view('lock_topic') ) register_view( forum, routes=[ '/topic/<int:topic_id>/post/<int:post_id>/reply', '/topic/<int:topic_id>-<slug>/post/<int:post_id>/reply' ], view_func=NewPost.as_view('reply_post') ) register_view( forum, routes=[ '/topic/<int:topic_id>/post/new', '/topic/<int:topic_id>-<slug>/post/new' ], view_func=NewPost.as_view('new_post') ) register_view( forum, routes=['/topic/<int:topic_id>', '/topic/<int:topic_id>-<slug>'], view_func=ViewTopic.as_view('view_topic') ) register_view( forum, routes=[ '/topic/<int:topic_id>/trivialize', '/topic/<int:topic_id>-<slug>/trivialize' ], view_func=TrivializeTopic.as_view('trivialize_topic') ) register_view( forum, routes=[ '/topic/<int:topic_id>/unlock', '/topic/<int:topic_id>-<slug>/unlock' ], view_func=UnlockTopic.as_view('unlock_topic') ) register_view( forum, routes=[ '/topictracker/<int:topic_id>/add', '/topictracker/<int:topic_id>-<slug>/add' ], view_func=TrackTopic.as_view('track_topic') ) register_view( forum, routes=[ '/topictracker/<int:topic_id>/delete', '/topictracker/<int:topic_id>-<slug>/delete' ], view_func=UntrackTopic.as_view('untrack_topic') ) register_view( forum, routes=['/topictracker'], view_func=TopicTracker.as_view('topictracker') ) register_view(forum, routes=['/'], view_func=ForumIndex.as_view('index')) register_view( forum, routes=['/who-is-online'], view_func=WhoIsOnline.as_view('who_is_online') ) register_view( forum, routes=[ "/topic/<int:topic_id>/hide", "/topic/<int:topic_id>-<slug>/hide" ], view_func=HideTopic.as_view('hide_topic') ) register_view( forum, routes=[ "/topic/<int:topic_id>/unhide", "/topic/<int:topic_id>-<slug>/unhide" ], view_func=UnhideTopic.as_view('unhide_topic') ) register_view( forum, routes=["/post/<int:post_id>/hide"], view_func=HidePost.as_view('hide_post') ) register_view( forum, routes=["/post/<int:post_id>/unhide"], view_func=UnhidePost.as_view('unhide_post') ) register_view( forum, routes=["/link"], view_func=Linked.as_view('link') ) app.register_blueprint(forum, url_prefix=app.config["FORUM_URL_PREFIX"])
if user: user.activated = True user.save() if current_user != user: logout_user() login_user(user) flash(_("Your account has been activated."), "success") return redirect(url_for("forum.index")) return render_template("auth/account_activation.html", form=form) register_view(auth, routes=['/logout'], view_func=Logout.as_view('logout')) register_view(auth, routes=['/login'], view_func=Login.as_view('login')) register_view(auth, routes=['/reauth'], view_func=Reauth.as_view('reauth')) register_view(auth, routes=['/register'], view_func=Register.as_view('register')) register_view( auth, routes=['/reset-password'], view_func=ForgotPassword.as_view('forgot_password') ) register_view( auth, routes=['/reset-password/<token>'], view_func=ResetPassword.as_view('reset_password') ) register_view( auth, routes=['/activate'], view_func=RequestActivationToken.as_view('request_activation_token') )
def flaskbb_load_blueprints(app): user = Blueprint("user", __name__) register_view( user, routes=["/settings/email"], view_func=ChangeEmail.as_view("change_email") ) register_view( user, routes=["/settings/general"], view_func=UserSettings.as_view("settings") ) register_view( user, routes=["/settings/password"], view_func=ChangePassword.as_view("change_password"), ) register_view( user, routes=["/settings/user-details"], view_func=ChangeUserDetails.as_view("change_user_details"), ) register_view( user, routes=["/<username>/posts"], view_func=AllUserPosts.as_view("view_all_posts"), ) register_view( user, routes=["/<username>/topics"], view_func=AllUserTopics.as_view("view_all_topics"), ) register_view( user, routes=["/<username>"], view_func=UserProfile.as_view("profile") ) app.register_blueprint(user, url_prefix=app.config["USER_URL_PREFIX"])
ckey = re.sub(r'[^\w\d]', '', form.searchText.data) query = query.filter(server_ban.ckey == ckey) elif form.searchType.data == "Admin": ckey = re.sub(r'[^\w\d]', '', form.searchText.data) query = query.filter(server_ban.a_ckey == ckey) elif form.searchType.data == "Reason": query = query.filter(server_ban.reason.contains(form.searchText.data)) bans_records_page: Pagination = query.paginate(page, 50) bans = bans_records_from_db_records(bans_records_page.items) return render_template("hub/bans.html", **self.get_args(), bans=bans, page=bans_records_page, form=form) register_view( hub, routes=["/"], view_func=Hub.as_view("index"), ) register_view( hub, routes=["/hublogs"], view_func=HubLogView.as_view("hublogs") ) register_view( hub, routes=["/start"], view_func=StartServer.as_view("start"), )