-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpost_list.html
142 lines (133 loc) · 7.67 KB
/
post_list.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
{% extends 'pdf_app/base.html' %}
{% block title %}PDF Documents{% endblock %}
{% block content %}
<div class="row">
<!-- Search and Filter Form -->
<div class="col-md-3">
<div class="card mb-4">
<div class="card-header">
<h5 class="card-title mb-0">Search & Filter</h5>
</div>
<div class="card-body">
<form method="get">
{{ search_form.query.label_tag }}
{{ search_form.query }}
<div class="mt-3">
{{ search_form.year.label_tag }}
{{ search_form.year }}
</div>
<div class="mt-3">
{{ search_form.category.label_tag }}
{{ search_form.category }}
</div>
<button type="submit" class="btn btn-primary mt-3 w-100">Search</button>
{% if request.GET %}
<a href="{% url 'pdf_app:post_list' %}" class="btn btn-secondary mt-2 w-100">Clear Filters</a>
{% endif %}
</form>
</div>
</div>
</div>
<!-- PDF List -->
<div class="col-md-9">
<div class="card">
<div class="card-header d-flex justify-content-between align-items-center">
<h5 class="card-title mb-0">PDF Documents</h5>
{% if user.is_authenticated %}
<a href="{% url 'pdf_app:post_create' %}" class="btn btn-success">
<i class="bi bi-plus-lg"></i> Add New PDF
</a>
{% endif %}
</div>
<div class="card-body">
{% if posts %}
<div class="table-responsive">
<table class="table table-hover">
<thead>
<tr>
<th>Title</th>
<th>Year</th>
<th>Category</th>
<th>Subcategory</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{% for post in posts %}
<tr>
<td>
<a href="{% url 'pdf_app:post_detail' post.pk %}" class="text-decoration-none">
{{ post.title }}
</a>
</td>
<td>
{% if post.subcategory.category.year_category %}
{{ post.subcategory.category.year_category.year }}
{% else %}
N/A
{% endif %}
</td>
<td>
{% if post.subcategory.category %}
{{ post.subcategory.category.name }}
{% else %}
N/A
{% endif %}
</td>
<td>{{ post.subcategory.name|default:"N/A" }}</td>
<td>
<div class="btn-group">
<a href="{% url 'pdf_app:post_detail' post.pk %}" class="btn btn-sm btn-outline-primary">
<i class="bi bi-eye"></i>
</a>
{% if user.is_authenticated %}
<a href="{% url 'pdf_app:post_update' post.pk %}" class="btn btn-sm btn-outline-warning">
<i class="bi bi-pencil"></i>
</a>
<a href="{% url 'pdf_app:post_delete' post.pk %}" class="btn btn-sm btn-outline-danger">
<i class="bi bi-trash"></i>
</a>
{% endif %}
</div>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<!-- Pagination -->
{% if is_paginated %}
<nav aria-label="Page navigation" class="mt-4">
<ul class="pagination justify-content-center">
{% if page_obj.has_previous %}
<li class="page-item">
<a class="page-link" href="?page=1{% if request.GET.query %}&query={{ request.GET.query }}{% endif %}{% if request.GET.year %}&year={{ request.GET.year }}{% endif %}{% if request.GET.category %}&category={{ request.GET.category }}{% endif %}">« First</a>
</li>
<li class="page-item">
<a class="page-link" href="?page={{ page_obj.previous_page_number }}{% if request.GET.query %}&query={{ request.GET.query }}{% endif %}{% if request.GET.year %}&year={{ request.GET.year }}{% endif %}{% if request.GET.category %}&category={{ request.GET.category }}{% endif %}">Previous</a>
</li>
{% endif %}
<li class="page-item disabled">
<span class="page-link">Page {{ page_obj.number }} of {{ page_obj.paginator.num_pages }}</span>
</li>
{% if page_obj.has_next %}
<li class="page-item">
<a class="page-link" href="?page={{ page_obj.next_page_number }}{% if request.GET.query %}&query={{ request.GET.query }}{% endif %}{% if request.GET.year %}&year={{ request.GET.year }}{% endif %}{% if request.GET.category %}&category={{ request.GET.category }}{% endif %}">Next</a>
</li>
<li class="page-item">
<a class="page-link" href="?page={{ page_obj.paginator.num_pages }}{% if request.GET.query %}&query={{ request.GET.query }}{% endif %}{% if request.GET.year %}&year={{ request.GET.year }}{% endif %}{% if request.GET.category %}&category={{ request.GET.category }}{% endif %}">Last »</a>
</li>
{% endif %}
</ul>
</nav>
{% endif %}
{% else %}
<div class="alert alert-info">
No PDF documents found.
</div>
{% endif %}
</div>
</div>
</div>
</div>
{% endblock %}