Commit 220ecc93 authored by Arnaud Fabre's avatar Arnaud Fabre

little fixes

parent b82ddb8d
......@@ -60,7 +60,10 @@ class RepresentativeAdmin(admin.ModelAdmin):
MandateInline
]
class GroupAdmin(admin.ModelAdmin):
list_display = ('id', 'name', 'abbreviation', 'kind')
list_filter = ('kind',)
class MandateAdmin(admin.ModelAdmin):
list_display = ('id', 'representative', 'group', 'role', 'constituency', 'begin_date', 'end_date')
search_fields = ('representative', 'group', 'constituency')
......@@ -69,5 +72,5 @@ class MandateAdmin(admin.ModelAdmin):
admin.site.register(Representative, RepresentativeAdmin)
admin.site.register(Country)
admin.site.register(Mandate, MandateAdmin)
admin.site.register(Group)
admin.site.register(Group, GroupAdmin)
admin.site.register(Constituency)
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('representatives', '0003_auto_20150702_1827'),
]
operations = [
migrations.AlterModelOptions(
name='representative',
options={'ordering': ['last_name', 'first_name']},
),
]
......@@ -204,7 +204,14 @@ class Constituency(HashableModel, TimeStampedModel):
return unicode(self.name)
class MandateManager(models.Manager):
def get_queryset(self):
return super(MandateManager, self).get_queryset().select_related('group', 'constituency')
class Mandate(HashableModel, TimeStampedModel):
objects = MandateManager()
group = models.ForeignKey(Group, null=True, related_name='mandates')
constituency = models.ForeignKey(Constituency, null=True, related_name='mandates')
representative = models.ForeignKey(Representative, related_name='mandates')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment