# Path: montanha/models.py
# class Institution(models.Model):
# 
#     class Meta:
#         verbose_name = _("Institution")
#         verbose_name_plural = _("Institutions")
# 
#     name = models.CharField(max_length=2048,
#                             verbose_name=_("Name"))
# 
#     siglum = models.CharField(max_length=10,
#                               verbose_name=_("Siglum"),
#                               unique=True)
# 
#     logo = ThumbnailerImageField(
#         verbose_name=_('Logo'),
#         upload_to='institution',
#         blank=True,
#         null=True)
# 
#     def __unicode__(self):
#         return u"%s" % (self.name)
# 
# class Legislature(models.Model):
# 
#     class Meta:
#         verbose_name = _("Legislature")
#         verbose_name_plural = _("Legislatures")
# 
#     institution = models.ForeignKey("Institution")
# 
#     original_id = models.CharField(blank=True, null=True,
#                                    max_length=512,
#                                    verbose_name=_("Original ID"))
# 
#     date_start = models.DateField(verbose_name=_("Date started"),
#                                   help_text=_("""Date in which this legislature started."""),
#                                   db_index=True)
# 
#     date_end = models.DateField(blank=True, null=True,
#                                 verbose_name=_("Date ended"),
#                                 help_text=_("""Date in which this legislature ended."""),
#                                 db_index=True)
# 
#     def __unicode__(self):
#         return u"%s's legislature starting at %s, ending at %s" % (self.institution.siglum,
#                                                                    str(self.date_start),
#                                                                    str(self.date_end))


from datetime import date
from montanha.models import Institution, Legislature
# -*- coding: utf-8 -*-
#
# Copyright (©) 2013 Marcelo Jorge Vieira <metal@alucinados.com>
# Copyright (©) 2013 Gustavo Noronha Silva <gustavo@noronha.eti.br>
#
#  This program is free software: you can redistribute it and/or modify
#  it under the terms of the GNU Affero General Public License as
#  published by the Free Software Foundation, either version 3 of the
#  License, or (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU Affero General Public License for more details.
#
#  You should have received a copy of the GNU Affero General Public License
#  along with this program.  If not, see <http://www.gnu.org/licenses/>.




def filter_for_institution(data, institution):
    if not institution:
        return data

    if not isinstance(institution, Institution):

# Path: montanha/models.py
# class Institution(models.Model):
# 
#     class Meta:
#         verbose_name = _("Institution")
#         verbose_name_plural = _("Institutions")
# 
#     name = models.CharField(max_length=2048,
#                             verbose_name=_("Name"))
# 
#     siglum = models.CharField(max_length=10,
#                               verbose_name=_("Siglum"),
#                               unique=True)
# 
#     logo = ThumbnailerImageField(
#         verbose_name=_('Logo'),
#         upload_to='institution',
#         blank=True,
#         null=True)
# 
#     def __unicode__(self):
#         return u"%s" % (self.name)
# 
# class Legislature(models.Model):
# 
#     class Meta:
#         verbose_name = _("Legislature")
#         verbose_name_plural = _("Legislatures")
# 
#     institution = models.ForeignKey("Institution")
# 
#     original_id = models.CharField(blank=True, null=True,
#                                    max_length=512,
#                                    verbose_name=_("Original ID"))
# 
#     date_start = models.DateField(verbose_name=_("Date started"),
#                                   help_text=_("""Date in which this legislature started."""),
#                                   db_index=True)
# 
#     date_end = models.DateField(blank=True, null=True,
#                                 verbose_name=_("Date ended"),
#                                 help_text=_("""Date in which this legislature ended."""),
#                                 db_index=True)
# 
#     def __unicode__(self):
#         return u"%s's legislature starting at %s, ending at %s" % (self.institution.siglum,
#                                                                    str(self.date_start),
#                                                                    str(self.date_end))


# Path: montanha/util.py
from datetime import date
from montanha.models import Institution, Legislature

# -*- coding: utf-8 -*-
#
# Copyright (©) 2013 Marcelo Jorge Vieira <metal@alucinados.com>
# Copyright (©) 2013 Gustavo Noronha Silva <gustavo@noronha.eti.br>
#
#  This program is free software: you can redistribute it and/or modify
#  it under the terms of the GNU Affero General Public License as
#  published by the Free Software Foundation, either version 3 of the
#  License, or (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU Affero General Public License for more details.
#
#  You should have received a copy of the GNU Affero General Public License
#  along with this program.  If not, see <http://www.gnu.org/licenses/>.




def filter_for_institution(data, institution):
    if not institution:
        return data

    if not isinstance(institution, Institution):

        institution = Institution.objects.get(siglum=institution)