Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Anthony
memopol
Commits
c9101d25
Commit
c9101d25
authored
Jun 10, 2016
by
Nicolas Joyard
Browse files
Add pagination and active filter to group views
parent
2ca64493
Changes
2
Hide whitespace changes
Inline
Side-by-side
memopol/views/group_list.py
View file @
c9101d25
...
...
@@ -2,19 +2,24 @@
import
datetime
from
core.views
import
PaginationMixin
,
ActiveLegislatureMixin
from
django.db
import
models
from
django.views
import
generic
from
representatives.models
import
Group
class
GroupList
(
generic
.
ListView
):
class
GroupList
(
PaginationMixin
,
ActiveLegislatureMixin
,
generic
.
ListView
):
def
get_queryset
(
self
):
qs
=
Group
.
objects
.
filter
(
models
.
Q
(
mandates__end_date__gte
=
datetime
.
date
.
today
())
|
models
.
Q
(
mandates__end_date__isnull
=
True
)
)
qs
=
Group
.
objects
.
all
()
if
self
.
get_active_only
():
qs
=
qs
.
filter
(
models
.
Q
(
mandates__end_date__gte
=
datetime
.
date
.
today
())
|
models
.
Q
(
mandates__end_date__isnull
=
True
)
)
kind
=
self
.
kwargs
.
get
(
'kind'
,
None
)
if
kind
:
...
...
templates/representatives/group_list.haml
View file @
c9101d25
...
...
@@ -3,25 +3,29 @@
-
load
memopol_tags
-
load
representatives_tags
-
block
content
%table
.table
-
for
group
in
object_list
%tr
-
if
group
.
kind
!=
'country'
and
group
.
kind
!=
'chamber'
%td
%a
{
'href'
:
"{% chamber_url group.chamber %}"
}
=
group
.
chamber
|
chamber_icon
%td
%a
{
'href'
:
"{% group_url group %}"
}
-
if
group
.
abbreviation
={
group
.
abbreviation
}
%td
%a
{
'href'
:
"{% group_url group %}"
}=
-
if
group
.
kind
==
'chamber'
=
group
|
chamber_icon
-
elif
group
.
kind
==
'group'
=
group
|
group_long_icon
-
else
=
group
.
name
-
include
'core/blocks/pagination.html'
-
block
list
%table
.table
-
for
group
in
object_list
%tr
-
if
group
.
kind
!=
'country'
and
group
.
kind
!=
'chamber'
%td
%a
{
'href'
:
"{% chamber_url group.chamber %}"
}
=
group
.
chamber
|
chamber_icon
%td
%a
{
'href'
:
"{% group_url group %}"
}
-
if
group
.
abbreviation
={
group
.
abbreviation
}
%td
%a
{
'href'
:
"{% group_url group %}"
}=
-
if
group
.
kind
==
'chamber'
=
group
|
chamber_icon
-
elif
group
.
kind
==
'group'
=
group
|
group_long_icon
-
else
=
group
.
name
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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