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
Political Memory
memopol
Commits
27d3dfe5
Commit
27d3dfe5
authored
Jul 22, 2015
by
Arnaud Fabre
Browse files
Design improvements
Adds-flag icons Adds fluid containers Adds a memopolVote proxy model
parent
4ecd390c
Changes
17
Expand all
Hide whitespace changes
Inline
Side-by-side
bower.json
View file @
27d3dfe5
...
...
@@ -2,7 +2,8 @@
"name"
:
"Memopol"
,
"version"
:
"3.0.0"
,
"dependencies"
:
{
"bootstrap"
:
"~3.3.5"
"bootstrap"
:
"~3.3.5"
,
"flag-icon-css"
:
"~0.7.1"
},
"devDependencies"
:
{
"fontawesome"
:
"~4.3.0"
...
...
core/templates/base.html
View file @
27d3dfe5
...
...
@@ -22,7 +22,7 @@
</head>
<body
{%
block
bodyattrs
%}{%
endblock
%}
>
{% include "core/blocks/header.html" %}
<div
class=
"container main-container"
>
<div
class=
"container
-fluid
main-container"
>
{% block content %}
{% endblock %}
</div>
...
...
core/templates/core/blocks/footer.haml
View file @
27d3dfe5
-
load
i18n
#footer
.container
#footer
.container
-fluid
-
blocktrans
Memopol is free software
<a
href=
"https://gitorious.org/memopol2-0"
>
released
</a>
...
...
core/templates/core/blocks/header.haml
View file @
27d3dfe5
...
...
@@ -3,7 +3,7 @@
-
load
cache
-
load
staticfiles
#header
.container
#header
.container
-fluid
%a
{
href:
"/"
,
id:
'logo'
}
%img
{
src:
'
{
% static
"images/logo.png"
%
}
'
}
%h1
...
...
@@ -12,6 +12,5 @@
%p
.organization
=
config
.
ORGANIZATION_NAME
#nav
.container
#nav
.container
-fluid
-
include
"core/blocks/navigation.html"
legislature/models.py
View file @
27d3dfe5
...
...
@@ -24,10 +24,10 @@ from django.db import models
from
django.core.exceptions
import
ObjectDoesNotExist
from
django.db.models.signals
import
post_save
from
django.dispatch
import
receiver
from
django.utils.functional
import
cached_property
#
from django.utils.functional import cached_property
from
representatives.models
import
Representative
,
Mandate
,
Country
from
representatives_
votes.models
import
Vote
from
votes.models
import
Memopol
Vote
from
core.utils
import
create_child_instance_from_parent
...
...
@@ -39,21 +39,7 @@ class MemopolRepresentative(Representative):
def
update_score
(
self
):
score
=
0
for
vote
in
self
.
votes
.
all
():
proposal
=
vote
.
proposal
try
:
if
proposal
.
recommendation
:
recommendation
=
proposal
.
recommendation
if
(
vote
.
position
!=
recommendation
.
recommendation
and
(
vote
.
position
==
'abstain'
or
recommendation
.
recommendation
==
'abstain'
)):
score
-=
(
recommendation
.
weight
/
2
)
elif
vote
.
position
!=
recommendation
.
recommendation
:
score
-=
recommendation
.
weight
else
:
score
+=
recommendation
.
weight
except
Exception
:
pass
score
+=
vote
.
absolute_score
self
.
score
=
score
self
.
save
()
...
...
@@ -102,10 +88,10 @@ class MemopolRepresentative(Representative):
)
def
votes_with_proposal
(
self
):
return
self
.
vote
s
.
select_related
(
return
MemopolVote
.
object
s
.
select_related
(
'proposal'
,
'proposal__recommendation'
)
)
.
filter
(
representative
=
self
)
@
receiver
(
post_save
,
sender
=
Representative
)
...
...
legislature/templates/legislature/blocks/representative_
header
.haml
→
legislature/templates/legislature/blocks/representative_
block
.haml
View file @
27d3dfe5
-
load
by_group_url
-
load
representatives_extras
.representative
%h1
.name
={
representative
.
full_name
}
={
representative
.
full_name
}
.row
.col-md-4
...
...
@@ -15,12 +15,11 @@
%tr
.score
%th
Score
%td
%span
.label.label-success
%a
{
:href
=>
'#votes'
}
=
representative
.
score
=
representative
.
score
|
score_label
%tr
%th
Country
%td
=
representative
.
country
.
name
%td
=
representative
.
country
|
country_flag
%tr
%th
Party
%td
...
...
legislature/templates/legislature/representative_detail.haml
View file @
27d3dfe5
...
...
@@ -3,29 +3,38 @@
-
extends
'base.html'
-
load
humanize
-
load
by_group_url
-
load
representatives_extras
-
load
bootstrap3
-
block
head
{{ position_form.media }}
-
block
content
-
include
'legislature/blocks/representative_header.html'
with
representative
=
representative
%h2
#votes
Votes
.row
.col-md-6
-
include
'legislature/blocks/representative_block.html'
with
representative
=
representative
.col-md-6
%h2
#votes
Votes
%table
.table.table-condensed.votes
%tr
%th
Title
%th
Position
%th
Recommendation
%th
Score
%table
.table.table-condensed.votes
%tr
%th
Title
%th
.icon-cell
Memopol recommendation
%th
.icon-cell
Representative vote
%th
.icon-cell
Score
-
for
vote
in
representative
.
votes_with_proposal
.
all
%tr
%td
=
vote
.
proposal
.
recommendation
.
title
%td
=
vote
.
position
%td
=
vote
.
proposal
.
recommendation
.
recommendation
%td
=
vote
.
proposal
.
recommendation
.
weight
-
for
vote
in
representative
.
votes_with_proposal
.
all
%tr
%td
=
vote
.
proposal
.
recommendation
.
title
%td
.icon-cell
=
vote
.
proposal
.
recommendation
.
recommendation
|
position_icon
%td
.icon-cell
=
vote
.
position
|
position_icon
%td
.icon-cell
=
vote
.
absolute_score
|
score_label
%h2
Mandates
...
...
legislature/templates/legislature/representative_list.haml
View file @
27d3dfe5
-
extends
'base.html'
-
load
by_group_url
-
load
representatives_extras
-
block
content
...
...
@@ -27,16 +27,16 @@
%td
%a
{
'href'
:
"{% url 'legislature:representative-detail' name=representative.slug %}"
}
=
{
representative
.
full_name
}
=
representative
.
full_name
%td
%a
{
'href'
:
"{% url 'legislature:representative-index' group_kind='country' group=representative.country.code %}"
}
=
{
representative
.
country
.
name
}
=
representative
.
country
|
country_flag
%td
%a
{
'href'
:
"{{ representative.main_mandate|by_group_url }}"
}
=
{
representative
.
main_mandate
.
group
.
abbreviation
}
=
representative
.
main_mandate
.
group
.
abbreviation
%td
=
{
representative
.
score
}
=
representative
.
score
|
score_label
-
include
"core/blocks/pagination.html"
legislature/templatetags/representatives_extras.py
0 → 100644
View file @
27d3dfe5
from
django
import
template
from
django.core.urlresolvers
import
reverse
from
django.utils.safestring
import
mark_safe
from
representatives.models
import
Mandate
,
Group
register
=
template
.
Library
()
@
register
.
filter
def
position_icon
(
position
):
if
position
==
'for'
:
return
mark_safe
(
'<i
\
aria-label="for"
\
class="fa fa-thumbs-up vote_positive"
\
title="for"
\
></i>'
)
elif
position
==
'against'
:
return
mark_safe
(
'<i
\
aria-label="against"
\
class="fa fa-thumbs-down vote_negative"
\
title="against"
\
></i>'
)
else
:
return
mark_safe
(
'<i
\
aria-label="abstain"
\
class="fa fa-circle-o vote_abstain"
\
title="abstain"
\
></i>'
)
@
register
.
filter
def
score_label
(
score
):
if
score
>
0
:
return
mark_safe
(
'<span class="label label-success">{}</span>'
.
format
(
score
))
elif
score
<
0
:
return
mark_safe
(
'<span class="label label-danger">{}</span>'
.
format
(
score
))
else
:
return
mark_safe
(
'<span class="label label-default">{}</span>'
.
format
(
score
))
@
register
.
filter
def
country_flag
(
country
):
return
mark_safe
(
'{} <span class="flag-icon flag-icon-{}"></span>'
.
format
(
country
.
name
,
country
.
code
.
lower
()
))
@
register
.
filter
def
by_group_url
(
group
):
if
isinstance
(
group
,
Mandate
):
group
=
group
.
group
if
not
isinstance
(
group
,
Group
):
return
''
kwargs
=
{
'group_kind'
:
group
.
kind
}
if
group
.
abbreviation
:
kwargs
[
'group'
]
=
group
.
abbreviation
else
:
kwargs
[
'group'
]
=
group
.
name
# kwargs['group_id'] = group.id
return
reverse
(
'legislature:representative-index'
,
kwargs
=
kwargs
)
static/less/base.less
View file @
27d3dfe5
...
...
@@ -10,7 +10,7 @@ body {
background: #E5E5E5;
}
.container {
.container
, .container-fluid
{
background: white;
}
...
...
static/less/legislature.less
View file @
27d3dfe5
...
...
@@ -23,3 +23,15 @@
width: 50%;
margin: auto;
}
.vote_negative {
color: red;
}
.vote_positive {
color: green;
}
.vote_abstain {
color: #333;
}
\ No newline at end of file
static/less/libs.less
View file @
27d3dfe5
@import '../libs/bootstrap/less/bootstrap';
@import '../libs/fontawesome/less/font-awesome';
// Flag icons
@import '../libs/flag-icon-css/less/variabless';
@flag-icon-css-path: '../libs/flag-icon-css/flags';
@import '../libs/flag-icon-css/less/flag-icon-base';
@import '../libs/flag-icon-css/less/flag-icon-list';
static/less/table.less
View file @
27d3dfe5
...
...
@@ -7,6 +7,10 @@ table.detail-view {
text-align: right;
}
th:after{
content: '
:';
content: '
:';
}
}
.icon-cell {
text-align: center;
}
\ No newline at end of file
static/stylesheets/base.css
View file @
27d3dfe5
...
...
@@ -79,7 +79,10 @@ table.detail-view th {
text-align
:
right
;
}
table
.detail-view
th
:after
{
content
:
' :'
;
content
:
' :'
;
}
.icon-cell
{
text-align
:
center
;
}
.representative
h1
{
text-align
:
center
;
...
...
@@ -100,6 +103,15 @@ table.detail-view th:after {
width
:
50%
;
margin
:
auto
;
}
.vote_negative
{
color
:
red
;
}
.vote_positive
{
color
:
green
;
}
.vote_abstain
{
color
:
#333
;
}
.quote
{
width
:
70%
;
margin
:
auto
;
...
...
@@ -123,7 +135,8 @@ table.detail-view th:after {
body
{
background
:
#E5E5E5
;
}
.container
{
.container
,
.container-fluid
{
background
:
white
;
}
.main-container
{
...
...
static/stylesheets/libs.css
View file @
27d3dfe5
This diff is collapsed.
Click to expand it.
votes/models.py
View file @
27d3dfe5
...
...
@@ -23,9 +23,9 @@ from django.utils.functional import cached_property
from
django.db.models.signals
import
post_save
from
django.dispatch
import
receiver
from
representatives.models
import
Representative
#
from representatives.models import Representative
from
representatives_votes.models
import
Vote
,
Proposal
,
Dossier
from
legislature.models
import
MemopolRepresentative
#
from legislature.models import MemopolRepresentative
from
core.utils
import
create_child_instance_from_parent
...
...
@@ -72,3 +72,23 @@ class MemopolDossier(Dossier):
@
receiver
(
post_save
,
sender
=
Dossier
)
def
create_memopolrepresentative_from_representative
(
instance
,
**
kwargs
):
create_child_instance_from_parent
(
MemopolDossier
,
instance
)
class
MemopolVote
(
Vote
):
class
Meta
:
proxy
=
True
@
cached_property
def
absolute_score
(
self
):
if
self
.
proposal
.
recommendation
:
recommendation
=
self
.
proposal
.
recommendation
weight
=
recommendation
.
weight
if
(
self
.
position
==
'abstain'
or
recommendation
.
recommendation
==
'abstain'
):
weight
=
weight
/
2
if
self
.
position
==
recommendation
.
recommendation
:
return
weight
else
:
return
-
weight
else
:
return
0
votes/templates/votes/dossier_index.haml
View file @
27d3dfe5
...
...
@@ -9,7 +9,7 @@
-
for
dossier
in
object_list
%tr
%td
%a
{
'href'
:
"{% url 'votes:dossier
_
detail' pk=dossier.id %}"
}
%a
{
'href'
:
"{% url 'votes:dossier
-
detail' pk=dossier.id %}"
}
{{ dossier.name }}
%td
=
dossier
.
reference
%td
=
dossier
.
proposals
.
count
...
...
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