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
M
memopol
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
32
Issues
32
List
Boards
Labels
Service Desk
Milestones
Merge Requests
6
Merge Requests
6
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Political Memory
memopol
Commits
f1d6180d
Commit
f1d6180d
authored
Oct 09, 2016
by
Nicolas Joyard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add latest votes + home-related settings
parent
598ab2a9
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
143 additions
and
12 deletions
+143
-12
src/memopol/context_processors.py
src/memopol/context_processors.py
+11
-0
src/memopol/settings.py
src/memopol/settings.py
+1
-0
src/memopol/static/css/custom.css
src/memopol/static/css/custom.css
+4
-0
src/memopol/templates/_base_intro.html
src/memopol/templates/_base_intro.html
+1
-1
src/memopol/templates/home.html
src/memopol/templates/home.html
+51
-3
src/memopol/templates/text/short_description.html
src/memopol/templates/text/short_description.html
+0
-8
src/memopol/templatetags/memopol_tags.py
src/memopol/templatetags/memopol_tags.py
+5
-0
src/memopol/views/home.py
src/memopol/views/home.py
+9
-0
src/memopol_settings/fixtures/homepage_settings.json
src/memopol_settings/fixtures/homepage_settings.json
+26
-0
src/memopol_settings/migrations/0002_homepage_settings.py
src/memopol_settings/migrations/0002_homepage_settings.py
+35
-0
No files found.
src/memopol/context_processors.py
View file @
f1d6180d
from
memopol_settings.models
import
Setting
from
representatives.models
import
Chamber
,
Group
from
representatives.models
import
Chamber
,
Group
...
@@ -13,3 +14,13 @@ def search_form_options(request):
...
@@ -13,3 +14,13 @@ def search_form_options(request):
d
[
'committees'
]
=
Group
.
objects
.
filter
(
kind
=
'committee'
)
d
[
'committees'
]
=
Group
.
objects
.
filter
(
kind
=
'committee'
)
return
d
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 = (
...
@@ -130,6 +130,7 @@ TEMPLATE_LOADERS = (
TEMPLATE_CONTEXT_PROCESSORS
=
global_settings
.
TEMPLATE_CONTEXT_PROCESSORS
+
(
TEMPLATE_CONTEXT_PROCESSORS
=
global_settings
.
TEMPLATE_CONTEXT_PROCESSORS
+
(
'django.template.context_processors.request'
,
'django.template.context_processors.request'
,
'memopol.context_processors.search_form_options'
,
'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 {
...
@@ -444,6 +444,10 @@ iframe {
margin-left
:
1em
;
margin-left
:
1em
;
}
}
.proposal-details
,
.proposal-details
td
{
border
:
0
!important
;
}
/***************************************************************
/***************************************************************
Icones
Icones
***************************************************************/
***************************************************************/
...
...
src/memopol/templates/_base_intro.html
View file @
f1d6180d
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +12,7 @@
</h1>
</h1>
<p
class=
"lead text-center hidden-xs"
>
{% trans "What is Memopol ?" %}
</p>
<p
class=
"lead text-center hidden-xs"
>
{% trans "What is Memopol ?" %}
</p>
<p
class=
"text-justify hidden-xs"
>
<p
class=
"text-justify hidden-xs"
>
{
% include "text/short_description.html" %
}
{
{ HOMEPAGE_INTRO_TEXT }
}
</p>
</p>
{% if position_form %}
{% if position_form %}
<div
class=
"container-fluid hidden-xs"
>
<div
class=
"container-fluid hidden-xs"
>
...
...
src/memopol/templates/home.html
View file @
f1d6180d
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
{% load i18n %}
{% load i18n %}
{% load fontawesome %}
{% load fontawesome %}
{% load staticfiles %}
{% load staticfiles %}
{% load memopol_tags %}
{% block content %}
{% block content %}
<div
class=
"row"
>
<div
class=
"row"
>
...
@@ -13,18 +14,55 @@
...
@@ -13,18 +14,55 @@
<div
class=
"row"
>
<div
class=
"row"
>
<div
class=
"col-md-12"
>
<div
class=
"col-md-12"
>
<h2>
{% trans "What is Memopol ?" %}
</h2>
<p>
<p>
{
% include "text/short_description.html" %
}
{
{ HOMEPAGE_INTRO_TEXT }
}
</p>
</p>
<h2>
{% trans "What about this instance ?" %}
</h2>
<p>
<p>
{
% include "text/license.html" %
}
{
{ HOMEPAGE_INSTANCE_TEXT }
}
</p>
</p>
</div>
</div>
</div>
</div>
<div
class=
"row"
>
<div
class=
"row"
>
<div
class=
"col-md-4"
>
<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>
<div
class=
"col-md-4"
>
<div
class=
"col-md-4"
>
...
@@ -89,4 +127,14 @@
...
@@ -89,4 +127,14 @@
</div>
</div>
</div>
</div>
<div
class=
"row"
>
<div
class=
"col-md-12"
>
<p>
<br><br>
{% include "text/license.html" %}
<br><br>
</p>
</div>
</div>
{% endblock %}
{% 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):
...
@@ -118,3 +118,8 @@ def score_badge(score, tooltip=None):
@
register
.
filter
@
register
.
filter
def
cast_str
(
val
):
def
cast_str
(
val
):
return
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
...
@@ -8,7 +8,9 @@ from django.views import generic
from
representatives.models
import
Representative
from
representatives.models
import
Representative
from
representatives_positions.views
import
PositionFormMixin
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
memopol_themes.models
import
Theme
from
.representative_mixin
import
RepresentativeViewMixin
from
.representative_mixin
import
RepresentativeViewMixin
...
@@ -45,4 +47,11 @@ class HomeView(PositionFormMixin, RepresentativeViewMixin,
...
@@ -45,4 +47,11 @@ class HomeView(PositionFormMixin, RepresentativeViewMixin,
nb_positions
=
Count
(
'positions'
,
distinct
=
True
)
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
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
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