def get(self): """ Page de création d'un nouveau post """ current_connected_user = connected_user(get_jwt_identity()) return render_template('create_post.html', title="Créer un nouvel article", current_connected_user=connected_user( get_jwt_identity()))
def page_not_found(e): return render_template( 'error_page.html', title="500", label="500. Internal Server Error", current_connected_user = connected_user(get_jwt_identity()) ), 404
def invalid_token_callback(expired_token): return render_template( 'error_page.html', title="401", label="401. Unauthorized", current_connected_user = connected_user(get_jwt_identity()) ), 401
def page_not_found(e): return render_template( 'error_page.html', title="404", label="404. Not Found", current_connected_user = connected_user(get_jwt_identity()) ), 404
def expired_token_callback(expired_token): return render_template( 'login.html', title="Se connecter", current_connected_user = connected_user(get_jwt_identity()), label="Reconnectez-vous" ), 200
def get(self, post_id): """ Obtenir un post à partir de son id. """ try: post = PostService.get_post_by_id(post_id) post_schema = PostSchema() return render_template('post.html', title=post.title, post=post_schema.dump(post), current_connected_user=connected_user( get_jwt_identity())) except ResourceNotFound as e: return render_template('404.html', title="Article non trouvé", current_connected_user=connected_user( get_jwt_identity())), 404
def _handle_expired_signature(error): return render_template( 'login.html', title="Se connecter", current_connected_user = connected_user(get_jwt_identity()), label="Reconnectez-vous" ), 200 return redirect('/auth/login')
def get(self): """ Page a propos """ return render_template('about.html', title="A propos", current_connected_user=connected_user( get_jwt_identity()))
def get(self, post_id, id): """ Obtenir un commentaire à partir de son id """ try: comment = CommentService.get_comment_by_id(post_id, id) comment_schema = CommentSchema() return render_template( 'comment.html', title="Commentaire", comment = comment_schema.dump(comment), current_connected_user = connected_user(get_jwt_identity()), ), 200 except ResourceNotFound as e: return render_template( '404.html', title="Commentaire non trouvé", current_connected_user = connected_user(get_jwt_identity()) ), 404
def get(self): """ Page d'administration du site """ users = UserService.get_all_users() user_schema = UserProfileSchema() return render_template('administration.html', title="Administration", current_connected_user=connected_user( get_jwt_identity()), users=user_schema.dump(users, many=True)), 200
def get(self): """ Page connexion d'un utilisateur """ current_connected_user = connected_user(get_jwt_identity()) if current_connected_user is not None: user_id = current_connected_user['id'] return redirect(f'/users/{user_id}') return render_template('login.html', title="Se connecter", label="Connectez-vous")
def get(self): """ Obtenir tous les posts """ posts = PostService.get_all_post() post_schema = PostSchema(exclude=["comments"]) return render_template('posts.html', title="Articles", posts=post_schema.dump(posts, many=True), current_connected_user=connected_user( get_jwt_identity()))
def get(self): """ Page d'accueil """ posts = PostService.get_all_post() post_schema = PostSchema(exclude=["comments"]) return render_template('home.html', title="Accueil", posts=post_schema.dump(posts, many=True), current_connected_user=connected_user( get_jwt_identity()))
def get(self): """ Page d'inscription d'un utilisateur """ current_connected_user = connected_user(get_jwt_identity()) if current_connected_user is not None: user_id = current_connected_user['id'] return redirect(f'/users/{user_id}') return render_template( 'sign_up.html', title="S'inscrire", )
def get(self, post_id): """ Obtenir tous les commentaires d'un post """ comments = CommentService.get_all_post_comments(post_id) comment_schema = CommentSchema() return render_template( 'comments.html', title="Commentaires", comments = comment_schema.dump(comments, many=True), current_connected_user = connected_user(get_jwt_identity()), post_id = post_id ), 200