Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
E
esi-table-data
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
esi-data-scrapping
esi-table-data
Commits
1c6c92aa
Commit
1c6c92aa
authored
Jun 02, 2017
by
Vasyl Bodnaruk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add sort by columns
parent
3aa8ea79
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
9 deletions
+34
-9
edit_news.html
esi/templates/edit_news.html
+2
-2
list_news.html
esi/templates/list_news.html
+26
-5
views.py
esi/webapp/views.py
+6
-2
No files found.
esi/templates/edit_news.html
View file @
1c6c92aa
...
...
@@ -12,12 +12,12 @@
{% endblock %}
{% block content %}
<main
class=
"pt-
5
pb-5"
>
<main
class=
"pt-
2
pb-5"
>
<div
class=
"container"
>
<form
class=
"form"
method=
"post"
>
{% csrf_token %}
<section
class=
"mb-5"
>
<h5
class=
"offset-1 display-5 mb-
5
"
>
Edit
</h5>
<h5
class=
"offset-1 display-5 mb-
2
"
>
Edit
</h5>
<!-- Title -->
<div
class=
"form-group row"
>
<label
for=
"title"
class=
"offset-1 col-2 col-form-label"
>
Title
</label>
...
...
esi/templates/list_news.html
View file @
1c6c92aa
...
...
@@ -53,10 +53,21 @@
<span><input
id=
"select-all"
type=
"checkbox"
></span>
<span>
Title
</span>
</th>
<th>
Media
</th>
<th>
Type
</th>
<th>
Region
</th>
<th>
Publish date
</th>
<th><a
href=
"?order_by=media_id{% if request.GET.order_by == 'media_id' and request.GET.reverse != '1' %}&reverse=1{% endif %}"
>
Media {% if request.GET.order_by == 'media_id' and request.GET.reverse != '1' %}
↑
{% elif request.GET.order_by == 'media_id' and request.GET.reverse == '1' %}
↓
{% endif %}
</a></th>
<th><a
href=
"?order_by=type_id{% if request.GET.order_by == 'type_id' and request.GET.reverse != '1' %}&reverse=1{% endif %}"
>
Type {% if request.GET.order_by == 'type_id' and request.GET.reverse != '1' %}
↑
{% elif request.GET.order_by == 'type_id' and request.GET.reverse == '1' %}
↓
{% endif %}
</a></th>
<th><a
href=
"?order_by=region_id{% if request.GET.order_by == 'region_id' and request.GET.reverse != '1' %}&reverse=1{% endif %}"
>
Region {% if request.GET.order_by == 'region_id' and request.GET.reverse != '1' %}
↑
{% elif request.GET.order_by == 'region_id' and request.GET.reverse == '1' %}
↓
{% endif %}
</a></th>
<th><a
href=
"?order_by=publish_date{% if request.GET.order_by == 'publish_date' and request.GET.reverse != '1' %}&reverse=1{% endif %}"
>
Publish date {% if request.GET.order_by == 'publish_date' and request.GET.reverse != '1' %}
↑
{% elif request.GET.order_by == 'publish_date' and request.GET.reverse == '1' %}
↓
{% endif %}
</a></th>
</tr>
</thead>
<tbody>
...
...
@@ -85,5 +96,15 @@
</tbody>
</table>
</form>
{% show_pages %}
<!--<div class="pagination" align="right">-->
<!--{% show_pages %}-->
<!--</div>-->
{% get_pages %}
<ul
class=
"pagination"
>
{% for page in pages %}
<li><a
href=
"{{ page.url }}"
>
{{ page.number }}
</a></li>
{% endfor %}
</ul>
{% endblock %}
\ No newline at end of file
esi/webapp/views.py
View file @
1c6c92aa
...
...
@@ -22,6 +22,12 @@ class ListNewsView(ListView):
print
(
from_date
,
to_date
)
news
=
News
.
objects
.
filter
(
is_accepted
=
False
)
.
order_by
(
'-id'
)
#.order_by('record_date')
order_by
=
request
.
GET
.
get
(
'order_by'
)
if
order_by
in
(
'media_id'
,
'type_id'
,
'region_id'
,
'publish_date'
):
news
=
news
.
order_by
(
'-'
+
order_by
)
if
request
.
GET
.
get
(
'reverse'
)
==
'1'
:
news
=
news
.
reverse
()
if
search
:
news
=
news
.
filter
(
Q
(
title__icontains
=
search
)
|
Q
(
description__icontains
=
search
))
if
from_date
:
...
...
@@ -35,8 +41,6 @@ class ListNewsView(ListView):
min_max_date
[
'record_date__min'
]
=
str
(
min_max_date
[
'record_date__min'
]
.
date
())
min_max_date
[
'record_date__max'
]
=
str
(
min_max_date
[
'record_date__max'
]
.
date
())
# news = self.paginate(news, request.GET.get('page'))
return
render
(
request
,
self
.
template_name
,
{
'news'
:
news
,
'media'
:
media
,
'date'
:
min_max_date
})
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment