# Path: montanha/models.py
# class Legislator(models.Model):
# 
#     class Meta:
#         verbose_name = _("Legislator")
#         verbose_name_plural = _("Legislators")
# 
#     name = models.CharField(max_length=2048,
#                             verbose_name=_("Full name"))
# 
#     alternative_names = models.ManyToManyField('AlternativeLegislatorName')
# 
#     picture = ThumbnailerImageField(
#         verbose_name=_('Picture'),
#         upload_to='legislator',
#         max_length=256,
#         blank=True,
#         null=True)
# 
#     site = models.URLField(
#         verbose_name=_('Site'),
#         blank=True,
#         null=True)
# 
#     email = models.EmailField(
#         verbose_name=_('Email'),
#         blank=True,
#         null=True)
# 
#     about = models.TextField(
#         verbose_name=_('About'),
#         blank=True,
#         null=True)
# 
#     gender = models.CharField(
#         verbose_name=_('Gender'),
#         choices=(
#             ('F', _('Female')),
#             ('M', _('Male'))),
#         blank=True,
#         null=True,
#         max_length=1)
# 
#     date_of_birth = models.DateField(
#         verbose_name=_('Date of Birth'),
#         blank=True,
#         null=True)
# 
#     def __unicode__(self):
#         return u"Legislator %s" % (self.name)
# 
#     @property
#     def party(self):
#         party = self.mandate_set.order_by("-date_start")[0].party
#         if party and party.siglum:
#             return party.siglum
#         return u"Partido não informado"


import os
import urllib2
import urllib
from BeautifulSoup import BeautifulSoup
from django.core.files import File
from montanha.models import Legislator
# Copyright (C) 2013 Marcelo Jorge Vieira <metal@alucinados.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 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
# General Public License for more details.
#
# You should have received a copy of the GNU General Public
# License along with this program; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
##





SITE_URL = "http://www.almg.gov.br"
PAGE_URL = "%s/%s" % (
    SITE_URL, (
        "/deputados/conheca_deputados/index.html?aba=js_tabAtual"
        "&rdSituacaoAnt=Exercicio&sltResult=0&formato=imagem"
        "&sltLegAnt=16&rdSituacao=Exercicio"
    )
)

# Path: montanha/models.py
# class Legislator(models.Model):
# 
#     class Meta:
#         verbose_name = _("Legislator")
#         verbose_name_plural = _("Legislators")
# 
#     name = models.CharField(max_length=2048,
#                             verbose_name=_("Full name"))
# 
#     alternative_names = models.ManyToManyField('AlternativeLegislatorName')
# 
#     picture = ThumbnailerImageField(
#         verbose_name=_('Picture'),
#         upload_to='legislator',
#         max_length=256,
#         blank=True,
#         null=True)
# 
#     site = models.URLField(
#         verbose_name=_('Site'),
#         blank=True,
#         null=True)
# 
#     email = models.EmailField(
#         verbose_name=_('Email'),
#         blank=True,
#         null=True)
# 
#     about = models.TextField(
#         verbose_name=_('About'),
#         blank=True,
#         null=True)
# 
#     gender = models.CharField(
#         verbose_name=_('Gender'),
#         choices=(
#             ('F', _('Female')),
#             ('M', _('Male'))),
#         blank=True,
#         null=True,
#         max_length=1)
# 
#     date_of_birth = models.DateField(
#         verbose_name=_('Date of Birth'),
#         blank=True,
#         null=True)
# 
#     def __unicode__(self):
#         return u"Legislator %s" % (self.name)
# 
#     @property
#     def party(self):
#         party = self.mandate_set.order_by("-date_start")[0].party
#         if party and party.siglum:
#             return party.siglum
#         return u"Partido não informado"


# Path: scripts/get_legislator_picture.py
import os
import urllib2
import urllib
from BeautifulSoup import BeautifulSoup
from django.core.files import File
from montanha.models import Legislator

# Copyright (C) 2013 Marcelo Jorge Vieira <metal@alucinados.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 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
# General Public License for more details.
#
# You should have received a copy of the GNU General Public
# License along with this program; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
##





SITE_URL = "http://www.almg.gov.br"
PAGE_URL = "%s/%s" % (
    SITE_URL, (
        "/deputados/conheca_deputados/index.html?aba=js_tabAtual"
        "&rdSituacaoAnt=Exercicio&sltResult=0&formato=imagem"
        "&sltLegAnt=16&rdSituacao=Exercicio"
    )
)

req = urllib2.Request(PAGE_URL, headers={"User-Agent": "Mozilla/5.0"})