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
14
Issues
14
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
c4f1cf88
Verified
Commit
c4f1cf88
authored
Sep 05, 2017
by
Thibaut Broggi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a search form
It can filter articles depending on their titles
parent
206bfc61
Pipeline
#1196
passed with stages
in 1 minute and 54 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
4 deletions
+10
-4
apps/rp/templates/rp/article_list_public.html
apps/rp/templates/rp/article_list_public.html
+6
-4
apps/rp/views/articles.py
apps/rp/views/articles.py
+4
-0
No files found.
apps/rp/templates/rp/article_list_public.html
View file @
c4f1cf88
...
...
@@ -65,10 +65,12 @@
{% endif %}
<li
class=
"nav-item ml-auto"
>
<a
class=
"nav-link disabled"
href=
"#"
>
<i
class=
"fa fa-search"
></i>
Rechercher
</a>
<form
method=
"get"
action=
"{% url 'rp:public-article-list' %}"
>
<div
class=
"input-group"
>
<input
type=
"search"
placeholder=
"Rechercher"
name=
"q"
class=
"fa fa-search"
/>
<button
type=
"submit"
class=
"btn btn-default input-group-addon"
><i
class=
"fa fa-search"
></i></button>
</div>
</form>
</li>
<li
class=
"nav-item"
>
...
...
apps/rp/views/articles.py
View file @
c4f1cf88
...
...
@@ -34,6 +34,9 @@ class ArticleList(ListView):
else
:
qs
=
Article
.
objects
.
filter
()
if
self
.
request
.
GET
.
get
(
'q'
,
''
)
!=
''
:
qs
=
qs
.
filter
(
title__contains
=
self
.
request
.
GET
.
get
(
'q'
,
''
))
filter_tag
=
self
.
kwargs
.
get
(
"filter_tag"
,
self
.
filter_tag
)
if
filter_tag
is
not
None
:
qs
=
qs
.
filter
(
tags__name__in
=
[
filter_tag
])
...
...
@@ -46,6 +49,7 @@ class ArticleList(ListView):
qs
=
Tag
.
objects
.
annotate
(
num_times
=
Count
(
'taggit_taggeditem_items'
)).
all
()
qs
=
qs
.
order_by
(
'-num_times'
)
context
[
"tags"
]
=
qs
context
[
"search"
]
=
self
.
request
.
GET
.
get
(
"q"
,
''
)
return
context
...
...
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