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
8a819237
Commit
8a819237
authored
Mar 12, 2015
by
luxcem
Browse files
updates to the last version of django-representatives
parent
2294d01f
Changes
10
Hide whitespace changes
Inline
Side-by-side
memopol_representatives/admin.py
View file @
8a819237
from
django.contrib
import
admin
import
representatives.models
as
models
from
memopol_representatives.models
import
MemopolRepresentative
class
EmailInline
(
admin
.
TabularInline
):
model
=
models
.
Email
extra
=
0
class
WebsiteInline
(
admin
.
TabularInline
):
model
=
models
.
WebSite
extra
=
0
class
AdressInline
(
admin
.
StackedInline
):
model
=
models
.
Address
extra
=
0
class
PhoneInline
(
admin
.
TabularInline
):
model
=
models
.
Phone
extra
=
0
class
MandateInline
(
admin
.
StackedInline
):
model
=
models
.
Mandate
extra
=
0
class
RepresentativeAdmin
(
admin
.
ModelAdmin
):
list_display
=
(
'full_name'
,
'gender'
,
'birth_place'
)
search_fields
=
(
'first_name'
,
'last_name'
,
'birth_place'
)
list_filter
=
(
'gender'
,
)
inlines
=
[
PhoneInline
,
EmailInline
,
WebsiteInline
,
AdressInline
,
MandateInline
]
class
MandateAdmin
(
admin
.
ModelAdmin
):
list_display
=
(
'kind'
,
'name'
,
'constituency'
,
'representative'
)
search_fields
=
(
'kind'
,
'name'
)
list_filter
=
(
'kind'
,)
admin
.
site
.
register
(
MemopolRepresentative
,
RepresentativeAdmin
)
admin
.
site
.
register
(
models
.
Country
)
admin
.
site
.
register
(
models
.
Mandate
,
MandateAdmin
)
memopol_representatives/management/__init__.py
deleted
100644 → 0
View file @
2294d01f
memopol_representatives/management/commands/__init__.py
deleted
100644 → 0
View file @
2294d01f
memopol_representatives/management/commands/update_representatives.py
deleted
100644 → 0
View file @
2294d01f
from
django.core.management.base
import
BaseCommand
from
django.db
import
transaction
from
memopol.utils
import
progress_bar
from
representatives.models
import
Representative
from
memopol_representatives.models
import
MemopolRepresentative
class
Command
(
BaseCommand
):
@
transaction
.
atomic
def
handle
(
self
,
*
args
,
**
options
):
n
=
Representative
.
objects
.
all
().
count
()
for
i
,
representative
in
enumerate
(
Representative
.
objects
.
all
()):
memopol_representative
=
MemopolRepresentative
(
representative_ptr
=
representative
)
memopol_representative
.
__dict__
.
update
(
representative
.
__dict__
)
# Auto set active flag of the memopol representative
memopol_representative
.
update_active
()
progress_bar
(
i
,
n
)
memopol_representatives/migrations/0001_initial.py
deleted
100644 → 0
View file @
2294d01f
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
from
django.db
import
models
,
migrations
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'representatives'
,
'0001_initial'
),
]
operations
=
[
migrations
.
CreateModel
(
name
=
'MemopolRepresentative'
,
fields
=
[
(
'representative_ptr'
,
models
.
OneToOneField
(
parent_link
=
True
,
auto_created
=
True
,
primary_key
=
True
,
serialize
=
False
,
to
=
'representatives.Representative'
)),
(
'active'
,
models
.
BooleanField
(
default
=
False
)),
],
options
=
{
},
bases
=
(
'representatives.representative'
,),
),
]
memopol_representatives/migrations/__init__.py
deleted
100644 → 0
View file @
2294d01f
memopol_representatives/models.py
View file @
8a819237
from
django.db
import
models
from
representatives.models
import
Representative
class
MemopolRepresentative
(
Representative
):
active
=
models
.
BooleanField
(
default
=
False
)
def
update_active
(
self
):
if
self
.
mandate_set
.
filter
(
end_date
=
"9999-12-31"
):
self
.
active
=
True
else
:
self
.
active
=
False
self
.
save
()
memopol_representatives/templates/memopol_representatives/list.haml
View file @
8a819237
...
...
@@ -3,13 +3,10 @@
-
block
content
.row
.large-8.columns
-
for
representative
in
memopolrepresentative_list
%p
=
representative
.
full_name
-
for
email
in
representative
.
email_set
.
all
%p
=
email
.
email
-
for
representative
in
representative_list
.row
-
include
'memopol_representatives/representative_block.html'
.large-4.columns
%p
hello
memopol_representatives/templates/memopol_representatives/representative_block.haml
0 → 100644
View file @
8a819237
%p
.small-2.columns
%img
{
'src'
:
'
=
{
representative
.
photo
}
'
}
/
%p
.small-4.columns
=
representative
.
full_name
[ ={representative.country.code} ]
%p
.small-6.columns
-
for
mandate
in
representative
.
mandate_set
.
all
={
mandate
.
group
.
name
}
-
=
{
mandate
.
end_date
}
-
=
{
mandate
.
active
}
%br
/a
memopol_representatives/views.py
View file @
8a819237
# from django.shortcuts import render
from
django.views
import
generic
from
memopol_representatives.models
import
MemopolRepresentative
from
representatives.models
import
Representative
class
IndexView
(
generic
.
ListView
):
template_name
=
'memopol_representatives/list.html'
def
get_queryset
(
self
):
return
Memopol
Representative
.
objects
.
all
()
return
Representative
.
objects
.
all
()
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