Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
rp
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
15
Issues
15
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
La Quadrature du Net
rpteam
rp
Commits
361504f4
Commit
361504f4
authored
Apr 28, 2017
by
cynddl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement priority on/off for the article lists
parent
7fef9c56
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
10 deletions
+39
-10
apps/rp/api/views.py
apps/rp/api/views.py
+14
-0
apps/rp/templates/rp/article_list.html
apps/rp/templates/rp/article_list.html
+18
-3
apps/rp/views/articles.py
apps/rp/views/articles.py
+2
-2
static/src/components/table.css
static/src/components/table.css
+5
-5
No files found.
apps/rp/api/views.py
View file @
361504f4
...
...
@@ -37,3 +37,17 @@ class ArticleViewSet(viewsets.ModelViewSet):
article
=
self
.
get_object
()
article
.
downvote
(
user_object
=
request
.
user
.
username
)
return
self
.
response_serialized_object
(
article
)
@
detail_route
(
methods
=
[
"post"
],
url_path
=
"priority/on"
)
def
priority_on
(
self
,
request
,
pk
=
None
,
priority
=
True
):
article
=
self
.
get_object
()
article
.
priority
=
True
article
.
save
()
return
self
.
response_serialized_object
(
article
)
@
detail_route
(
methods
=
[
"post"
],
url_path
=
"priority/off"
)
def
priority_off
(
self
,
request
,
pk
=
None
,
priority
=
True
):
article
=
self
.
get_object
()
article
.
priority
=
False
article
.
save
()
return
self
.
response_serialized_object
(
article
)
apps/rp/templates/rp/article_list.html
View file @
361504f4
...
...
@@ -76,7 +76,7 @@
<table
class=
"article-table table table-sm my-4"
>
<thead>
<tr>
<th>
Priority
</th>
{% if filter_view != "published" %}
<th>
Priority
</th>
{% endif %}
<th>
ID
</th>
<th>
Date
</th>
<th>
Language
</th>
...
...
@@ -90,12 +90,19 @@
{% for article in object_list|slice:":10" %}
<tr
id=
"row_empty_{{article.id}}"
class=
"empty-row"
><td
colspan=
"8"
></td></tr>
<tr
id=
"row_{{article.id}}"
>
<td
class=
"icon-cell"
><i
class=
"fa fa-dot-circle-o"
aria-hidden=
"true"
style=
"color:red"
></i></td>
{% if filter_view != "published" %}
<td
class=
"icon-cell actions-item"
onclick=
"javascript:call_priority({{article.id}}, {{article.priority|yesno:"
false
,
true
"}})"
>
<i
id=
"priority_{{article.id}}"
class=
"fa fa-star{{ article.priority|yesno:"
,
-o
"
}}"
aria-hidden=
"true"
></i>
</td>
{% endif %}
<td>
{{article.id}}
</td>
<td>
{{article.created_at |date:'d/m/y'}}
<br
/>
{{article.created_at |date:'H:i'}}
</td>
<td>
{{article.lang}}
</td>
<td
class=
"title-cell"
><a
target=
"_blank"
href=
"{{article.url}}"
><strong>
{{article.title}}
</strong></a></td>
<td>
{% if filter_view == "published" %}
{{article.und_score}}
{% else %}
<ul
class=
"votes-list"
>
<li
class=
"actions-item"
onclick=
"javascript:call_upvote({{article.id}})"
>
<span
id=
"count_up_{{article.id}}"
>
{{article.und_score_up}}
</span>
...
...
@@ -106,8 +113,9 @@
<i
class=
"fa fa-thumbs-down"
aria-hidden=
"true"
style=
"color:red"
></i>
</li>
</ul>
{% endif %}
</td>
<td>
{{article.
und_votes.first.username
}}
</td>
<td>
{{article.
created_by
}}
</td>
<td
class=
"actions-cell"
>
<ul
class=
"actions-list"
>
{% if filter_view == 'flux' %}
...
...
@@ -201,5 +209,12 @@
$
(
"
#row_tags_
"
+
id
).
hide
();
});
}
function
call_priority
(
id
,
flag
)
{
var
url
=
"
/api/articles/
"
+
id
+
"
/priority/
"
+
(
flag
?
"
on/
"
:
"
off/
"
);
$
.
post
(
url
,
{
'
priority
'
:
flag
},
function
response
(
data
)
{
$
(
"
#priority_
"
+
id
).
toggleClass
(
"
fa-star
"
).
toggleClass
(
"
fa-star-o
"
);
});
}
</script>
{% endblock %}
apps/rp/views/articles.py
View file @
361504f4
...
...
@@ -27,7 +27,7 @@ class ArticleListFlux(UDList):
qs
=
Article
.
objects
.
filter
(
status
=
"PUBLISHED"
)
elif
filter_view
==
"draft"
:
qs
=
Article
.
objects
.
extra
(
where
=
[
"
und_score_up + und_score_down >= 3
"
,
"
(und_score_up + und_score_down >= 3) or priority
"
,
"status='PENDING'"
])
elif
filter_view
==
"rejected"
:
...
...
@@ -41,7 +41,7 @@ class ArticleListFlux(UDList):
context
=
super
().
get_context_data
(
**
kwargs
)
context
[
"filter_view"
]
=
self
.
kwargs
.
get
(
"filter_view"
,
"draft"
)
context
[
"nb_draft"
]
=
Article
.
objects
.
extra
(
where
=
[
"
und_score_up + und_score_down >= 3
"
,
"
(und_score_up + und_score_down >= 3) or priority
"
,
"status='PENDING'"
]).
count
()
return
context
...
...
static/src/components/table.css
View file @
361504f4
...
...
@@ -55,12 +55,12 @@ table.article-table td.icon-cell {
table
.article-table
ul
{
padding
:
0
;
margin
:
0
;
}
&
li
.actions-item
{
cursor
:
pointer
;
.actions-item
{
cursor
:
pointer
;
&:--enter
{
font-weight
:
600
;
}
&:--enter
{
font-weight
:
600
;
}
}
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