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
598ab2a9
Commit
598ab2a9
authored
Oct 09, 2016
by
Nicolas Joyard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add themes to homepage
parent
896346f5
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
142 additions
and
51 deletions
+142
-51
src/memopol/static/css/custom.css
src/memopol/static/css/custom.css
+39
-1
src/memopol/templates/home.html
src/memopol/templates/home.html
+12
-1
src/memopol/templates/memopol_themes/_theme_card.html
src/memopol/templates/memopol_themes/_theme_card.html
+52
-0
src/memopol/templates/memopol_themes/theme_list.html
src/memopol/templates/memopol_themes/theme_list.html
+1
-46
src/memopol/views/home.py
src/memopol/views/home.py
+16
-1
src/memopol_themes/admin.py
src/memopol_themes/admin.py
+2
-2
src/memopol_themes/migrations/0002_theme_featured.py
src/memopol_themes/migrations/0002_theme_featured.py
+19
-0
src/memopol_themes/models.py
src/memopol_themes/models.py
+1
-0
No files found.
src/memopol/static/css/custom.css
View file @
598ab2a9
...
...
@@ -92,7 +92,6 @@ a.custom-invisible, a.custom-invisible:hover, a.custom-invisible:focus {
}
/***************************************************************
Forms
***************************************************************/
...
...
@@ -371,6 +370,44 @@ iframe {
right
:
0.5em
;
}
/***************************************************************
Themes
***************************************************************/
.theme-card
.description
{
margin
:
0
1em
;
line-height
:
1.2em
;
}
.theme-card
.info-container
{
display
:
flex
;
flex-flow
:
row
nowrap
;
padding
:
1em
;
}
.theme-card
.badge-container
{
display
:
flex
;
flex-flow
:
column
nowrap
;
justify-content
:
center
;
}
.theme-card
.badge-container
.label
{
margin
:
.25em
0
;
}
.theme-card
.chart-container
{
flex-grow
:
1
;
height
:
125px
;
margin-left
:
.5em
;
border
:
1px
solid
#ddd
;
background-image
:
url(../images/logo.png)
;
background-size
:
contain
;
background-position
:
center
;
background-repeat
:
no-repeat
;
}
/***************************************************************
Dossiers
***************************************************************/
...
...
@@ -444,6 +481,7 @@ iframe {
margin-left
:
.5em
;
}
.vote_positive
{
color
:
green
;
}
...
...
src/memopol/templates/home.html
View file @
598ab2a9
...
...
@@ -20,13 +20,21 @@
{% include "text/license.html" %}
</p>
</div>
</div>
<div
class=
"row"
>
<div
class=
"col-md-4"
>
placeholder
</div>
<div
class=
"col-md-4"
>
placeholder
<h2>
{% trans "Featured themes" %}
</h2>
{% for theme in featured_themes %}
{% include "memopol_themes/_theme_card.html" with theme=theme cols=12 %}
{% empty %}
{% trans "No currently featured theme :'(" %}
{% endfor %}
</div>
<div
class=
"col-md-4 todays-mep"
>
...
...
@@ -35,6 +43,9 @@
{% include "representatives/_representative_card.html" with representative=todays_mep cols=12 %}
</div>
</div>
<div
class=
"row"
>
<div
class=
"col-md-4"
>
<h3>
{% trans "More information" %}
</h3>
<div
class=
"btn-group"
>
...
...
src/memopol/templates/memopol_themes/_theme_card.html
0 → 100644
View file @
598ab2a9
{% load i18n %}
{% load fontawesome %}
<div
class=
"col-xs-12 col-md-{{ cols|default:4 }} theme-card"
>
<div
class=
"thumbnail"
>
<a
href=
"{% url 'theme-detail' slug=theme.slug %}"
class=
"custom-thumbnail custom-invisible"
>
<div
class=
"row"
>
<div
class=
"col-xs-12"
>
<h4
class=
"text-center"
>
{{ theme.name }}
</h4>
{# Double div needed for ellipsis to work #}
<div
class=
"description ellipsis"
><div>
{{ theme.description|truncatewords:20 }}
</div></div>
<div
class=
"info-container"
>
<div
class=
"badge-container"
>
{% if theme.nb_links > 0 %}
<span
class=
"label label-default"
data-toggle=
"tooltip"
data-placement=
"bottom"
title=
"{% trans 'Links' %}"
>
{% fontawesome_icon "link" %}
<span
class=
"badge"
>
{{ theme.nb_links }}
</span>
</span>
{% endif %}
{% if theme.nb_dossiers > 0 %}
<span
class=
"label label-default"
data-toggle=
"tooltip"
data-placement=
"bottom"
title=
"{% trans 'Dossiers' %}"
>
{% fontawesome_icon "book" %}
<span
class=
"badge"
>
{{ theme.nb_dossiers }}
</span>
</span>
{% endif %}
{% if theme.nb_proposals > 0 %}
<span
class=
"label label-default"
data-toggle=
"tooltip"
data-placement=
"bottom"
title=
"{% trans 'Proposals' %}"
>
{% fontawesome_icon "pencil" %}
<span
class=
"badge"
>
{{ theme.nb_proposals }}
</span>
</span>
{% endif %}
{% if theme.nb_positions > 0 %}
<span
class=
"label label-default"
data-toggle=
"tooltip"
data-placement=
"bottom"
title=
"{% trans 'Public positions' %}"
>
{% fontawesome_icon "comment" %}
<span
class=
"badge"
>
{{ theme.nb_positions }}
</span>
</span>
{% endif %}
</div>
<div
class=
"chart-container"
>
</div>
</div>
</div>
</div>
</a>
</div>
</div>
\ No newline at end of file
src/memopol/templates/memopol_themes/theme_list.html
View file @
598ab2a9
...
...
@@ -16,52 +16,7 @@
<div
class=
"row card-list"
>
{% for theme in object_list %}
<div
class=
"col-xs-12 col-md-4 theme-card"
>
<div
class=
"thumbnail"
>
<a
href=
"{% url 'theme-detail' slug=theme.slug %}"
class=
"custom-thumbnail custom-invisible"
>
<div
class=
"row"
>
<div
class=
"col-xs-12"
>
<h4
class=
"text-center"
>
{{ theme.name }}
</h4>
<p
class=
"text-center lead"
>
{% if theme.nb_links > 0 %}
<span
class=
"label label-default"
data-toggle=
"tooltip"
data-placement=
"bottom"
title=
"{% trans 'Links' %}"
>
{% fontawesome_icon "link" %}
<span
class=
"badge"
>
{{ theme.nb_links }}
</span>
</span>
{% endif %}
{% if theme.nb_dossiers > 0 %}
<span
class=
"label label-default"
data-toggle=
"tooltip"
data-placement=
"bottom"
title=
"{% trans 'Dossiers' %}"
>
{% fontawesome_icon "book" %}
<span
class=
"badge"
>
{{ theme.nb_dossiers }}
</span>
</span>
{% endif %}
{% if theme.nb_proposals > 0 %}
<span
class=
"label label-default"
data-toggle=
"tooltip"
data-placement=
"bottom"
title=
"{% trans 'Proposals' %}"
>
{% fontawesome_icon "pencil" %}
<span
class=
"badge"
>
{{ theme.nb_proposals }}
</span>
</span>
{% endif %}
{% if theme.nb_positions > 0 %}
<span
class=
"label label-default"
data-toggle=
"tooltip"
data-placement=
"bottom"
title=
"{% trans 'Public positions' %}"
>
{% fontawesome_icon "comment" %}
<span
class=
"badge"
>
{{ theme.nb_positions }}
</span>
</span>
{% endif %}
</p>
</div>
</div>
</a>
</div>
</div>
{% include "memopol_themes/_theme_card.html" with theme=theme %}
{% endfor %}
</div>
...
...
src/memopol/views/home.py
View file @
598ab2a9
...
...
@@ -3,12 +3,14 @@
import
datetime
import
random
from
django.db.models
import
Q
from
django.db.models
import
Q
,
Count
from
django.views
import
generic
from
representatives.models
import
Representative
from
representatives_positions.views
import
PositionFormMixin
from
memopol_themes.models
import
Theme
from
.representative_mixin
import
RepresentativeViewMixin
...
...
@@ -19,6 +21,8 @@ class HomeView(PositionFormMixin, RepresentativeViewMixin,
def
get_context_data
(
self
,
**
kwargs
):
c
=
super
(
HomeView
,
self
).
get_context_data
(
**
kwargs
)
# Today's mep
qs
=
Representative
.
objects
qs
=
qs
.
filter
(
Q
(
representative_score__score__lt
=
0
)
|
Q
(
representative_score__score__gt
=
0
))
...
...
@@ -30,4 +34,15 @@ class HomeView(PositionFormMixin, RepresentativeViewMixin,
self
.
add_representative_country_and_main_mandate
(
c
[
'todays_mep'
])
# Featured themes
c
[
'featured_themes'
]
=
Theme
.
objects
\
.
filter
(
featured
=
True
)
\
.
annotate
(
nb_links
=
Count
(
'links'
,
distinct
=
True
),
nb_dossiers
=
Count
(
'dossiers'
,
distinct
=
True
),
nb_proposals
=
Count
(
'proposals'
,
distinct
=
True
),
nb_positions
=
Count
(
'positions'
,
distinct
=
True
)
)
return
c
src/memopol_themes/admin.py
View file @
598ab2a9
...
...
@@ -18,10 +18,10 @@ class LinkInline(admin.StackedInline):
class
ThemeAdmin
(
admin
.
ModelAdmin
):
list_display
=
(
'name'
,
'description'
)
list_display
=
(
'name'
,
'description'
,
'featured'
)
list_editable
=
(
'name'
,
'description'
)
list_filter
=
(
'name'
,)
fields
=
(
'name'
,
'description'
)
fields
=
(
'name'
,
'description'
,
'featured'
)
inlines
=
[
LinkInline
]
...
...
src/memopol_themes/migrations/0002_theme_featured.py
0 → 100644
View file @
598ab2a9
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'memopol_themes'
,
'0001_initial'
),
]
operations
=
[
migrations
.
AddField
(
model_name
=
'theme'
,
name
=
'featured'
,
field
=
models
.
BooleanField
(
default
=
False
),
),
]
src/memopol_themes/models.py
View file @
598ab2a9
...
...
@@ -12,6 +12,7 @@ class Theme(models.Model):
name
=
models
.
CharField
(
max_length
=
255
,
unique
=
True
)
slug
=
AutoSlugField
(
populate_from
=
'name'
)
description
=
models
.
TextField
()
featured
=
models
.
BooleanField
(
default
=
False
)
dossiers
=
models
.
ManyToManyField
(
Dossier
,
related_name
=
'themes'
)
proposals
=
models
.
ManyToManyField
(
Proposal
,
related_name
=
'themes'
)
...
...
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