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
Porkepix
memopol
Commits
f1d6180d
Commit
f1d6180d
authored
Oct 09, 2016
by
Nicolas Joyard
Browse files
Add latest votes + home-related settings
parent
598ab2a9
Changes
10
Hide whitespace changes
Inline
Side-by-side
src/memopol/context_processors.py
View file @
f1d6180d
from
memopol_settings.models
import
Setting
from
representatives.models
import
Chamber
,
Group
...
...
@@ -13,3 +14,13 @@ def search_form_options(request):
d
[
'committees'
]
=
Group
.
objects
.
filter
(
kind
=
'committee'
)
return
d
def
intro_text
(
request
):
d
=
{}
for
s
in
Setting
.
objects
.
filter
(
pk__in
=
[
'HOMEPAGE_INTRO_TEXT'
,
'HOMEPAGE_INSTANCE_TEXT'
]):
d
[
s
.
pk
]
=
s
.
comment
return
d
src/memopol/settings.py
View file @
f1d6180d
...
...
@@ -130,6 +130,7 @@ TEMPLATE_LOADERS = (
TEMPLATE_CONTEXT_PROCESSORS
=
global_settings
.
TEMPLATE_CONTEXT_PROCESSORS
+
(
'django.template.context_processors.request'
,
'memopol.context_processors.search_form_options'
,
'memopol.context_processors.intro_text'
)
#
...
...
src/memopol/static/css/custom.css
View file @
f1d6180d
...
...
@@ -444,6 +444,10 @@ iframe {
margin-left
:
1em
;
}
.proposal-details
,
.proposal-details
td
{
border
:
0
!important
;
}
/***************************************************************
Icones
***************************************************************/
...
...
src/memopol/templates/_base_intro.html
View file @
f1d6180d
...
...
@@ -12,7 +12,7 @@
</h1>
<p
class=
"lead text-center hidden-xs"
>
{% trans "What is Memopol ?" %}
</p>
<p
class=
"text-justify hidden-xs"
>
{
% include "text/short_description.html" %
}
{
{ HOMEPAGE_INTRO_TEXT }
}
</p>
{% if position_form %}
<div
class=
"container-fluid hidden-xs"
>
...
...
src/memopol/templates/home.html
View file @
f1d6180d
...
...
@@ -3,6 +3,7 @@
{% load i18n %}
{% load fontawesome %}
{% load staticfiles %}
{% load memopol_tags %}
{% block content %}
<div
class=
"row"
>
...
...
@@ -13,18 +14,55 @@
<div
class=
"row"
>
<div
class=
"col-md-12"
>
<h2>
{% trans "What is Memopol ?" %}
</h2>
<p>
{
% include "text/short_description.html" %
}
{
{ HOMEPAGE_INTRO_TEXT }
}
</p>
<h2>
{% trans "What about this instance ?" %}
</h2>
<p>
{
% include "text/license.html" %
}
{
{ HOMEPAGE_INSTANCE_TEXT }
}
</p>
</div>
</div>
<div
class=
"row"
>
<div
class=
"col-md-4"
>
placeholder
<h2>
{% trans "Latest votes" %}
</h2>
<table
class=
"table table-responsive table-condensed"
>
<tr>
<th></th>
<th></th>
<th></th>
<th>
{{ "for"|position_icon }}
</th>
<th>
{{ "against"|position_icon }}
</th>
<th>
{{ "abstain"|position_icon }}
</th>
</tr>
{% for proposal in latest_votes %}
<tr
class=
"proposal-title {% if forloop.counter0|divisibleby:2 %}active{% endif %}"
>
<td
colspan=
"6"
>
<a
href=
"{% url 'dossier-detail' proposal.dossier.pk %}"
>
{{ proposal.title }}
</a>
</td>
</tr>
<tr
class=
"proposal-details {% if forloop.counter0|divisibleby:2 %}active{% endif %}"
>
<td>
{% for chamber in proposal.dossier.chambers %}
{{ chamber | chamber_icon }}
{% endfor %}
</td>
<td>
{% include "blocks/_themetags.html" with themes=proposal|proposal_themes %}
</td>
<td>
{{ proposal.status|proposal_status_label:proposal.recommendation }}
</td>
<td>
{{ proposal.total_for }}
</td>
<td>
{{ proposal.total_against }}
</td>
<td>
{{ proposal.total_abstain }}
</td>
</tr>
{% endfor %}
</table>
</div>
<div
class=
"col-md-4"
>
...
...
@@ -89,4 +127,14 @@
</div>
</div>
<div
class=
"row"
>
<div
class=
"col-md-12"
>
<p>
<br><br>
{% include "text/license.html" %}
<br><br>
</p>
</div>
</div>
{% endblock %}
src/memopol/templates/text/short_description.html
deleted
100644 → 0
View file @
598ab2a9
{% load i18n %}
{% blocktrans %}
Political Memory is a tool designed by La Quadrature du Net to help
citizens to reach their representatives and
track their voting records on issues related to fundamental
freedoms online.
{% endblocktrans %}
src/memopol/templatetags/memopol_tags.py
View file @
f1d6180d
...
...
@@ -118,3 +118,8 @@ def score_badge(score, tooltip=None):
@
register
.
filter
def
cast_str
(
val
):
return
str
(
val
)
@
register
.
filter
def
proposal_themes
(
proposal
):
return
set
(
proposal
.
themes
.
all
())
|
set
(
proposal
.
dossier
.
themes
.
all
())
src/memopol/views/home.py
View file @
f1d6180d
...
...
@@ -8,7 +8,9 @@ from django.views import generic
from
representatives.models
import
Representative
from
representatives_positions.views
import
PositionFormMixin
from
representatives_votes.models
import
Proposal
from
memopol_settings.models
import
Setting
from
memopol_themes.models
import
Theme
from
.representative_mixin
import
RepresentativeViewMixin
...
...
@@ -45,4 +47,11 @@ class HomeView(PositionFormMixin, RepresentativeViewMixin,
nb_positions
=
Count
(
'positions'
,
distinct
=
True
)
)
# Last votes
num
=
int
(
Setting
.
objects
.
get
(
pk
=
'HOMEPAGE_LATEST_VOTES'
).
value
)
c
[
'latest_votes'
]
=
Proposal
.
objects
\
.
filter
(
recommendation__isnull
=
False
)
\
.
order_by
(
'-datetime'
)[
0
:
num
]
return
c
src/memopol_settings/fixtures/homepage_settings.json
0 → 100644
View file @
f1d6180d
[
{
"model"
:
"memopol_settings.setting"
,
"pk"
:
"HOMEPAGE_LATEST_VOTES"
,
"fields"
:
{
"value"
:
"5"
,
"comment"
:
"Number of 'latest votes' to show on the homepage."
}
},
{
"model"
:
"memopol_settings.setting"
,
"pk"
:
"HOMEPAGE_INTRO_TEXT"
,
"fields"
:
{
"value"
:
"** Use comment field for this setting **"
,
"comment"
:
"Political Memory is a tool to help citizens reach their representatives and track their voting records."
}
},
{
"model"
:
"memopol_settings.setting"
,
"pk"
:
"HOMEPAGE_INSTANCE_TEXT"
,
"fields"
:
{
"value"
:
"** Use comment field for this setting **"
,
"comment"
:
"This instance of Memopol is run by La Quadrature du Net and tracks issues related to fundamental freedoms online."
}
}
]
\ No newline at end of file
src/memopol_settings/migrations/0002_homepage_settings.py
0 → 100644
View file @
f1d6180d
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
import
os
from
django.core
import
serializers
from
django.db
import
migrations
,
models
fixture_dir
=
os
.
path
.
abspath
(
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'../fixtures'
))
fixture_filename
=
'homepage_settings.json'
def
load_fixture
(
apps
,
schema_editor
):
fixture_file
=
os
.
path
.
join
(
fixture_dir
,
fixture_filename
)
fixture
=
open
(
fixture_file
,
'rb'
)
objects
=
serializers
.
deserialize
(
'json'
,
fixture
,
ignorenonexistent
=
True
)
for
obj
in
objects
:
obj
.
save
()
fixture
.
close
()
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'memopol_settings'
,
'0001_initial'
),
]
operations
=
[
migrations
.
RunPython
(
load_fixture
),
]
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