Révision a2aba77e
Ajouté par Serghei Mihai il y a environ 7 ans
corbo/templates/corbo/announce_form.html | ||
---|---|---|
1 |
{% extends "corbo/category_detail.html" %}
|
|
1 |
{% extends "corbo/announce_list.html" %}
|
|
2 | 2 |
{% load i18n %} |
3 | 3 |
|
4 | 4 |
{% block breadcrumb %} |
corbo/templates/corbo/announce_list.html | ||
---|---|---|
1 |
{% extends 'corbo/manage.html' %} |
|
2 |
{% load i18n %} |
|
3 |
|
|
4 |
{% block breadcrumb %} |
|
5 |
{{ block.super }} |
|
6 |
{% if category %} |
|
7 |
<a href='{% url "view_category" slug=category.slug %}'>{{ category }}</a> |
|
8 |
{% endif %} |
|
9 |
{% endblock %} |
|
10 |
|
|
11 |
{% block appbar %} |
|
12 |
<h2>{{ category.name }}</h2> |
|
13 |
<a class="extra-actions-menu-opener">☰</a> |
|
14 |
<ul class="extra-actions-menu"> |
|
15 |
<li><a href="{% url 'subscriptions-import' slug=category.slug %}" rel="popup">{% trans 'Import subscriptions' %}</a></li> |
|
16 |
</ul> |
|
17 |
|
|
18 |
<a href="{% url 'delete_category' slug=category.slug %}" rel="popup">{% trans 'Delete' %}</a> |
|
19 |
<a href="{% url 'edit_category' slug=category.slug %}" rel="popup">{% trans 'Edit' %}</a> |
|
20 |
<a href="{% url 'add_announce' slug=category.slug %}">{% trans 'New announce' %}</a> |
|
21 |
{% endblock %} |
|
22 |
|
|
23 |
{% block content %} |
|
24 |
<div id="management"> |
|
25 |
{% if object_list %} |
|
26 |
<ul class='objects-list single-links'> |
|
27 |
{% for announce in object_list %} |
|
28 |
<li class="{% if not announce.is_published %}unpublished{% endif %}"> |
|
29 |
<a href="{% url 'edit_announce' announce.id %}">{{ announce.title }}</a> |
|
30 |
<div class="datetime"> |
|
31 |
{% if announce.publication_time %} |
|
32 |
{% blocktrans with mtime=announce.publication_time|date:'DATETIME_FORMAT' %} |
|
33 |
Published on {{ mtime }} |
|
34 |
{% endblocktrans %} |
|
35 |
{% endif %} |
|
36 |
</div> |
|
37 |
</li> |
|
38 |
{% endfor %} |
|
39 |
</ul> |
|
40 |
|
|
41 |
{% if is_paginated %} |
|
42 |
<p class="paginator"> |
|
43 |
{% if page_obj.number > 1 %} |
|
44 |
{% if page_obj.previous_page_number != 1 %} |
|
45 |
<a href="?page=1">1</a> |
|
46 |
... |
|
47 |
{% endif %} |
|
48 |
{% endif %} |
|
49 |
|
|
50 |
{% if page_obj.has_previous %} |
|
51 |
<a href="?page={{ page_obj.previous_page_number }}">{{ page_obj.previous_page_number }}</a> |
|
52 |
{% endif %} |
|
53 |
<span class="this-page"> |
|
54 |
{{ page_obj.number }} |
|
55 |
</span> |
|
56 |
{% if page_obj.has_next %} |
|
57 |
<a href="?page={{ page_obj.next_page_number }}">{{ page_obj.next_page_number }}</a> |
|
58 |
{% endif %} |
|
59 |
|
|
60 |
{% if page_obj.number != page_obj.paginator.num_pages %} |
|
61 |
{% if page_obj.paginator.num_pages > 1 %} |
|
62 |
{% if page_obj.next_page_number != page_obj.paginator.num_pages %} |
|
63 |
... |
|
64 |
<a href="?page={{ page_obj.paginator.num_pages }}">{{ page_obj.paginator.num_pages }}</a> |
|
65 |
{% endif %} |
|
66 |
{% endif %} |
|
67 |
{% endif %} |
|
68 |
</p> |
|
69 |
{% endif %} |
|
70 |
|
|
71 |
{% else %} |
|
72 |
<div class="big-msg-info"> |
|
73 |
{% blocktrans %} |
|
74 |
This category doesn't have any announces yet. Click on "New announce" button in the top |
|
75 |
right of the page to add a first one. |
|
76 |
{% endblocktrans %} |
|
77 |
</div> |
|
78 |
{% endif %} |
|
79 |
</div> |
|
80 |
{% endblock %} |
corbo/templates/corbo/category_detail.html | ||
---|---|---|
1 |
{% extends 'corbo/manage.html' %} |
|
2 |
{% load i18n %} |
|
3 |
|
|
4 |
{% block breadcrumb %} |
|
5 |
{{ block.super }} |
|
6 |
{% if category %} |
|
7 |
<a href='{% url "view_category" slug=category.slug %}'>{{ category }}</a> |
|
8 |
{% endif %} |
|
9 |
{% endblock %} |
|
10 |
|
|
11 |
{% block appbar %} |
|
12 |
<h2>{{ object.name }}</h2> |
|
13 |
<a class="extra-actions-menu-opener">☰</a> |
|
14 |
<ul class="extra-actions-menu"> |
|
15 |
<li><a href="{% url 'subscriptions-import' slug=category.slug %}" rel="popup">{% trans 'Import subscriptions' %}</a></li> |
|
16 |
</ul> |
|
17 |
|
|
18 |
<a href="{% url 'delete_category' slug=object.slug %}" rel="popup">{% trans 'Delete' %}</a> |
|
19 |
<a href="{% url 'edit_category' slug=object.slug %}" rel="popup">{% trans 'Edit' %}</a> |
|
20 |
<a href="{% url 'add_announce' slug=object.slug %}">{% trans 'New announce' %}</a> |
|
21 |
{% endblock %} |
|
22 |
|
|
23 |
{% block content %} |
|
24 |
<div id="management"> |
|
25 |
<ul class='objects-list single-links'> |
|
26 |
{% for announce in announces %} |
|
27 |
<li class="{% if not announce.is_published %}unpublished{% endif %}"> |
|
28 |
<a href="{% url 'edit_announce' announce.id %}">{{ announce.title }}</a> |
|
29 |
<div class="datetime"> |
|
30 |
{% if announce.publication_time %} |
|
31 |
{% blocktrans with mtime=announce.publication_time|date:'DATETIME_FORMAT' %} |
|
32 |
Published on {{ mtime }} |
|
33 |
{% endblocktrans %} |
|
34 |
{% endif %} |
|
35 |
</div> |
|
36 |
</li> |
|
37 |
{% endfor %} |
|
38 |
</ul> |
|
39 |
|
|
40 |
{% if not announces %} |
|
41 |
<div class="big-msg-info"> |
|
42 |
{% blocktrans %} |
|
43 |
This category doesn't have any announces yet. Click on "New announce" button in the top |
|
44 |
right of the page to add a first one. |
|
45 |
{% endblocktrans %} |
|
46 |
</div> |
|
47 |
{% endif %} |
|
48 |
|
|
49 |
{% endblock %} |
corbo/views.py | ||
---|---|---|
129 | 129 |
edit_category = CategoryEditView.as_view() |
130 | 130 |
|
131 | 131 |
|
132 |
class CategoryView(DetailView): |
|
133 |
model = models.Category |
|
132 |
class CategoryView(ListView): |
|
133 |
model = models.Announce |
|
134 |
paginate_by = settings.ANNOUNCES_PER_PAGE |
|
135 |
|
|
136 |
def get_queryset(self): |
|
137 |
qs = super(CategoryView, self).get_queryset() |
|
138 |
return qs.filter(category__slug=self.kwargs['slug']) |
|
134 | 139 |
|
135 | 140 |
def get_context_data(self, **kwargs): |
136 | 141 |
context = super(CategoryView, self).get_context_data(**kwargs) |
137 |
context['announces'] = self.object.announce_set.all().order_by( |
|
138 |
'-publication_time', '-ctime') |
|
142 |
context['category'] = models.Category.objects.get(slug=self.kwargs['slug']) |
|
139 | 143 |
return context |
140 | 144 |
|
141 | 145 |
|
Formats disponibles : Unified diff
add pagination for announces (#13878)