# 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
# class Participation(models.Model):
#     member = models.ForeignKey('Member')
#     project = models.ForeignKey(Project)
#     start_date = models.DateField()
#     end_date = models.DateField(null=True, blank=True)
# 
#     def __unicode__(self):
#         return self.member.name + ' - ' + self.project.name


from django.shortcuts import render_to_response
from django.template import RequestContext
from apps.projects.models import Project
from apps.members.models import Participation


def show_all(request):
    projects = Project.objects.all().order_by('status', 'start_date')
    return render_to_response(
        'show_all_projects.html',
        {'projects': projects, 'project_count': len(projects)},
        context_instance=RequestContext(request)
    )

def show_project(request, project_slug):
    project = Project.objects.get(slug=project_slug)

# 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
# class Participation(models.Model):
#     member = models.ForeignKey('Member')
#     project = models.ForeignKey(Project)
#     start_date = models.DateField()
#     end_date = models.DateField(null=True, blank=True)
# 
#     def __unicode__(self):
#         return self.member.name + ' - ' + self.project.name


# Path: apps/projects/views.py
from django.shortcuts import render_to_response
from django.template import RequestContext
from apps.projects.models import Project
from apps.members.models import Participation



def show_all(request):
    projects = Project.objects.all().order_by('status', 'start_date')
    return render_to_response(
        'show_all_projects.html',
        {'projects': projects, 'project_count': len(projects)},
        context_instance=RequestContext(request)
    )

def show_project(request, project_slug):
    project = Project.objects.get(slug=project_slug)

    participations = Participation.objects.all()