alanjameschapman / whiteboard

django blog for teachers and students
0 stars 1 forks source link

USER STORY: view all posts summarized #23

Closed alanjameschapman closed 8 months ago

alanjameschapman commented 8 months ago

As a user I can view all posts summarized so that I can browse topics.

Acceptance Criteria

Tasks

alanjameschapman commented 8 months ago

Add PostList class to edblog/views:

class PostList(generic.ListView):
    queryset = Post.objects.all()
    template_name = "post_list.html"

Add basic template to edblog/templates/edblog/post_list.html (this will be developed further):

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Views Part 1</title>
</head>

<body>
    <h1>Posts list</h1>
    {% for post in object_list %}
    <h2>{{post.title}}</h2>
    <p>{{post.excerpt}}</p>
    <p>Author: {{post.author}}</p>
    {% endfor %}
</body>

</html>

Add posts.json to edblog/fixtures to quickly check how a large dataset will be displayed.

Admin Deployed
Image Image
alanjameschapman commented 8 months ago

Add base and index.html templates with snippets, paginate, add boilerplate css.

Local Deployed
Image Image
alanjameschapman commented 8 months ago

Install Cloudinary and connect API.

Update Post model and index.html with DTL.

Result

Image

alanjameschapman commented 8 months ago

Students can now see relevant posts, depending on their enrolment. Teachers can see only posts which they authored.

Enrolment Image
Posts Image
Teacher 1 Image
Teacher 2 Image
Student 1 Image
Student 2 Image