Skip to content

Instantly share code, notes, and snippets.

View guglielmo's full-sized avatar

Guglielmo Celata guglielmo

View GitHub Profile
@guglielmo
guglielmo / mixins.py
Created January 29, 2013 18:48
This code is related to the django rest framework project (https://github.com/tomchristie/django-rest-framework). It's an implementation of the suggestion of Alan Plum in this google groups discussion (https://groups.google.com/forum/?fromgroups=#!topic/django-rest-framework/XRHdi8ddXiw) to have different representations of list and detail views…
from django.http import Http404
from rest_framework.mixins import ListModelMixin
from rest_framework.response import Response
class ShortListModelMixin(ListModelMixin):
"""
Extends ListModelMixin,
allowing the specification of the list_fields arguments for the .list() method
different fields can be shown for list and detail views
"""
@guglielmo
guglielmo / deliberation.py
Created April 17, 2012 12:56
Deliberation class definition
class Deliberation(Act):
"""
WRITEME
"""
INIZIATIVE_CHOICES = Choices(
('COUNSELOR', 'counselor', _('Counselor')),
('PRESIDENT', 'president', _('President')),
('ASSESSOR', 'assessor', _('City Government Member')),
('GOVERNMENT', 'government', _('City Government')),
('MAYOR', 'mayor', _('Mayor')),
@guglielmo
guglielmo / Municipality.py
Created March 7, 2012 20:20
Open Municipio Internal Municipality API
## Private DB access API
class Council(object):
@property
def members(self):
return Institution.objects.get(institution_type=Institution.COUNCIL).institutioncharge_set
@property
def majority_members(self):
pass