Skip to content
GitLab
Menu
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
5061b4a2
Commit
5061b4a2
authored
Oct 11, 2016
by
Nicolas Joyard
Browse files
Add preliminary chamber cards on homepage
parent
47b8e95f
Changes
6
Hide whitespace changes
Inline
Side-by-side
src/memopol/static/css/custom.css
View file @
5061b4a2
...
...
@@ -375,28 +375,36 @@ iframe {
Themes
***************************************************************/
.theme-card
.description
{
.theme-card
.description
,
.chamber-card
.description
{
margin
:
0
1em
;
line-height
:
1.2em
;
}
.theme-card
.info-container
{
.theme-card
.info-container
,
.chamber-card
.info-container
,
.chamber-card
.title-container
{
display
:
flex
;
flex-flow
:
row
nowrap
;
justify-content
:
space-between
;
align-items
:
center
;
padding
:
1em
;
}
.theme-card
.badge-container
{
.theme-card
.badge-container
,
.chamber-card
.badge-container
{
display
:
flex
;
flex-flow
:
column
nowrap
;
justify-content
:
center
;
}
.theme-card
.badge-container
.label
{
.theme-card
.badge-container
.label
,
.chamber-card
.badge-container
.label
{
margin
:
.25em
0
;
}
.theme-card
.chart-container
{
.theme-card
.chart-container
,
.chamber-card
.chart-container
{
flex-grow
:
1
;
height
:
125px
;
margin-left
:
.5em
;
...
...
@@ -408,6 +416,14 @@ iframe {
background-repeat
:
no-repeat
;
}
.chamber-card
.chart-container
{
margin
:
1em
;
}
.chamber-card
h4
{
margin
:
0
;
}
/***************************************************************
Dossiers
***************************************************************/
...
...
src/memopol/templates/blocks/_chamber_card.html
0 → 100644
View file @
5061b4a2
{% load i18n %}
{% load fontawesome %}
{% load memopol_tags %}
<div
class=
"col-xs-12 col-md-{{ cols|default:4 }} chamber-card"
>
<div
class=
"thumbnail"
>
<div
class=
"row"
>
<div
class=
"col-xs-12"
>
<div
class=
"title-container"
>
<h4
class=
"text-center"
>
{{ chamber.name }}
</h4>
{{ chamber|chamber_icon }}
</div>
<div
class=
"description"
>
{% blocktrans with dossiers=chamber.nb_dossiers proposals=chamber.nb_proposals %}
<b>
{{ dossiers }} dossiers
</b>
and
<b>
{{ proposals }} proposals
</b>
{% endblocktrans %}
</div>
<div
class=
"chart-container"
>
</div>
</div>
</div>
</div>
</div>
src/memopol/templates/home.html
View file @
5061b4a2
...
...
@@ -83,6 +83,16 @@
</div>
<div
class=
"row"
>
<div
class=
"col-md-12"
>
<h2>
{% trans "Chambers in this instance" %}
</h2>
</div>
{% for chamber in chambers %}
{% include "blocks/_chamber_card.html" with chamber=chamber %}
{% endfor %}
</div>
<div
class=
"row"
>
<div
class=
"col-md-4"
>
<h3>
{% trans "More information" %}
</h3>
...
...
src/memopol/tests/test_home_navigation_pane.py
View file @
5061b4a2
...
...
@@ -9,19 +9,23 @@ class NavigationPaneTest(BaseTest):
self
.
client
.
get
(
self
.
url
)
"""
Today mep
- 1 for count reps with non null score
- 1 for random mep
- 1 for prefetch main mandate
Latest votes
- 1 for latest votes count setting
- 1 for latest votes (proposal)
- 1 for prefetching latest votes themes
- 1 for prefetching latest votes dossier themes
- 1 for prefetching latest votes dossier documents
- 1 for prefetching latest votes dossier documents chambers
Featured themes
- 1 for featured themes
- 3 for Today mep
- 1 for count reps with non null score
- 1 for random mep
- 1 for prefetch main mandate
- 6 for Latest votes
- 1 for latest votes count setting
- 1 for latest votes (proposal)
- 1 for prefetching latest votes themes
- 1 for prefetching latest votes dossier themes
- 1 for prefetching latest votes dossier documents
- 1 for prefetching latest votes dossier documents chambers
- 1 for Featured themes
- 1 for featured themes
- 0 for Chambers
- 1 for chambers and dossier/proposal counts
=> note: django optimizes out the chamber query for left pane
forms so this one actually does not add 1 to query count
"""
home_queries
=
10
...
...
src/memopol/views/home.py
View file @
5061b4a2
...
...
@@ -6,7 +6,7 @@ import random
from
django.db.models
import
Q
,
Count
from
django.views
import
generic
from
representatives.models
import
Representative
from
representatives.models
import
Chamber
,
Representative
from
representatives_positions.views
import
PositionFormMixin
from
representatives_votes.models
import
Proposal
...
...
@@ -57,4 +57,12 @@ class HomeView(PositionFormMixin, RepresentativeViewMixin,
'dossier__documents__chamber'
)
\
.
order_by
(
'-datetime'
)[
0
:
num
]
# Chambers
c
[
'chambers'
]
=
Chamber
.
objects
.
all
()
\
.
annotate
(
nb_dossiers
=
Count
(
'documents__dossier'
,
distinct
=
True
),
nb_proposals
=
Count
(
'documents__dossier__proposals'
,
distinct
=
True
))
return
c
src/representatives_votes/models.py
View file @
5061b4a2
...
...
@@ -38,7 +38,7 @@ class Dossier(TimeStampedModel):
class
Document
(
TimeStampedModel
):
dossier
=
models
.
ForeignKey
(
Dossier
,
related_name
=
'documents'
)
chamber
=
models
.
ForeignKey
(
Chamber
)
chamber
=
models
.
ForeignKey
(
Chamber
,
related_name
=
'documents'
)
title
=
models
.
CharField
(
max_length
=
1000
)
kind
=
models
.
CharField
(
max_length
=
255
,
blank
=
True
,
default
=
''
)
link
=
models
.
URLField
(
max_length
=
1000
)
...
...
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