Esempio n. 1
0
    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()))
Esempio n. 2
0
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
Esempio n. 3
0
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
Esempio n. 4
0
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
Esempio n. 5
0
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
Esempio n. 6
0
 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
Esempio n. 7
0
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')
Esempio n. 8
0
    def get(self):
        """
        Page a propos
        """

        return render_template('about.html',
                               title="A propos",
                               current_connected_user=connected_user(
                                   get_jwt_identity()))
Esempio n. 9
0
 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
Esempio n. 10
0
 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
Esempio n. 11
0
 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")
Esempio n. 12
0
 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()))
Esempio n. 13
0
 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()))
Esempio n. 14
0
    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",
        )
Esempio n. 15
0
 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