# Path: thumbs.py
# class ImageWithThumbsField(ImageField):
#     attr_class = ImageWithThumbsFieldFile
#     """
#     Usage example:
#     ==============
#     photo = ImageWithThumbsField(upload_to='images', sizes=((125,125),(300,200),)
# 
#     To retrieve image URL, exactly the same way as with ImageField:
#         my_object.photo.url
#     To retrieve thumbnails URL's just add the size to it:
#         my_object.photo.url_125x125
#         my_object.photo.url_300x200
# 
#     Note: The 'sizes' attribute is not required. If you don't provide it,
#     ImageWithThumbsField will act as a normal ImageField
# 
#     How it works:
#     =============
#     For each size in the 'sizes' atribute of the field it generates a
#     thumbnail with that size and stores it following this format:
# 
#     available_filename.[width]x[height].extension
# 
#     Where 'available_filename' is the available filename returned by the storage
#     backend for saving the original file.
# 
#     Following the usage example above: For storing a file called "photo.jpg" it saves:
#     photo.jpg          (original file)
#     photo.125x125.jpg  (first thumbnail)
#     photo.300x200.jpg  (second thumbnail)
# 
#     With the default storage backend if photo.jpg already exists it will use these filenames:
#     photo_.jpg
#     photo_.125x125.jpg
#     photo_.300x200.jpg
# 
#     Note: django-thumbs assumes that if filename "any_filename.jpg" is available
#     filenames with this format "any_filename.[widht]x[height].jpg" will be available, too.
# 
#     To do:
#     ======
#     Add method to regenerate thubmnails
# 
#     """
#     def __init__(self, verbose_name=None, name=None, width_field=None, height_field=None, sizes=None, **kwargs):
#         self.verbose_name=verbose_name
#         self.name=name
#         self.width_field=width_field
#         self.height_field=height_field
#         self.sizes = sizes
#         super(ImageField, self).__init__(**kwargs)
# 
# Path: apps/projects/models.py
# class Project(models.Model):
#     name = models.CharField(max_length=100)
#     description = models.TextField()
#     logo = ImageWithThumbsField(upload_to='images/projects', null=True, blank=True, sizes=((200, 200), (90, 90), ))
#     sponsor = models.CharField(max_length=100)
#     github = models.CharField(max_length=80, null=True, blank=True)
#     status = models.CharField(max_length=100, choices=PROJECT_STATES)
#     start_date = models.DateField()
#     end_date = models.DateField(null=True, blank=True)
#     slug = models.SlugField(max_length=100, blank=True)
# 
#     def github_link(self):
#         return "http://github.com/" + self.github
# 
#     def github_feed(self):
#         return self.github_link() + "/commits/master.atom"
# 
# 
#     def finished(self):
#         return self.end_date is not None
# 
#     def __unicode__(self):
#         return self.name
# 
#     def save(self, *args, **kwargs):
#         self.slug = slugify(self.name)
#         if self.finished():
#             self.status = 'finalizado'
#             super(Project, self).save(*args, **kwargs)
#         else:
#             super(Project, self).save(*args, **kwargs)


from django.db import models
from django.template.defaultfilters import slugify
from thumbs import ImageWithThumbsField
from apps.projects.models import Project


MEMBER_FUNCTIONS = (
    ('0', 'gerente'),
    ('1', 'coordenador'),
    ('2', 'pesquisador'),
    ('3', 'bolsista'),
    ('4', 'colaborador'))


class Participation(models.Model):
    member = models.ForeignKey('Member')

# Path: thumbs.py
# class ImageWithThumbsField(ImageField):
#     attr_class = ImageWithThumbsFieldFile
#     """
#     Usage example:
#     ==============
#     photo = ImageWithThumbsField(upload_to='images', sizes=((125,125),(300,200),)
# 
#     To retrieve image URL, exactly the same way as with ImageField:
#         my_object.photo.url
#     To retrieve thumbnails URL's just add the size to it:
#         my_object.photo.url_125x125
#         my_object.photo.url_300x200
# 
#     Note: The 'sizes' attribute is not required. If you don't provide it,
#     ImageWithThumbsField will act as a normal ImageField
# 
#     How it works:
#     =============
#     For each size in the 'sizes' atribute of the field it generates a
#     thumbnail with that size and stores it following this format:
# 
#     available_filename.[width]x[height].extension
# 
#     Where 'available_filename' is the available filename returned by the storage
#     backend for saving the original file.
# 
#     Following the usage example above: For storing a file called "photo.jpg" it saves:
#     photo.jpg          (original file)
#     photo.125x125.jpg  (first thumbnail)
#     photo.300x200.jpg  (second thumbnail)
# 
#     With the default storage backend if photo.jpg already exists it will use these filenames:
#     photo_.jpg
#     photo_.125x125.jpg
#     photo_.300x200.jpg
# 
#     Note: django-thumbs assumes that if filename "any_filename.jpg" is available
#     filenames with this format "any_filename.[widht]x[height].jpg" will be available, too.
# 
#     To do:
#     ======
#     Add method to regenerate thubmnails
# 
#     """
#     def __init__(self, verbose_name=None, name=None, width_field=None, height_field=None, sizes=None, **kwargs):
#         self.verbose_name=verbose_name
#         self.name=name
#         self.width_field=width_field
#         self.height_field=height_field
#         self.sizes = sizes
#         super(ImageField, self).__init__(**kwargs)
# 
# Path: apps/projects/models.py
# class Project(models.Model):
#     name = models.CharField(max_length=100)
#     description = models.TextField()
#     logo = ImageWithThumbsField(upload_to='images/projects', null=True, blank=True, sizes=((200, 200), (90, 90), ))
#     sponsor = models.CharField(max_length=100)
#     github = models.CharField(max_length=80, null=True, blank=True)
#     status = models.CharField(max_length=100, choices=PROJECT_STATES)
#     start_date = models.DateField()
#     end_date = models.DateField(null=True, blank=True)
#     slug = models.SlugField(max_length=100, blank=True)
# 
#     def github_link(self):
#         return "http://github.com/" + self.github
# 
#     def github_feed(self):
#         return self.github_link() + "/commits/master.atom"
# 
# 
#     def finished(self):
#         return self.end_date is not None
# 
#     def __unicode__(self):
#         return self.name
# 
#     def save(self, *args, **kwargs):
#         self.slug = slugify(self.name)
#         if self.finished():
#             self.status = 'finalizado'
#             super(Project, self).save(*args, **kwargs)
#         else:
#             super(Project, self).save(*args, **kwargs)


# Path: apps/members/models.py
from django.db import models
from django.template.defaultfilters import slugify
from thumbs import ImageWithThumbsField
from apps.projects.models import Project



MEMBER_FUNCTIONS = (
    ('0', 'gerente'),
    ('1', 'coordenador'),
    ('2', 'pesquisador'),
    ('3', 'bolsista'),
    ('4', 'colaborador'))


class Participation(models.Model):
    member = models.ForeignKey('Member')

    project = models.ForeignKey(Project)