# Path: apps/members/models.py
# class Member(models.Model):
#     name = models.CharField(max_length=100)
#     nickname = models.CharField(max_length=100, null=True, blank=True)
#     phone = models.CharField(max_length=13, null=True, blank=True)
#     currently_does = models.TextField()
#     life_and_work = models.TextField()
#     function = models.CharField(max_length=100, choices=MEMBER_FUNCTIONS)
#     site = models.URLField(null=True, blank=True)
#     github = models.CharField(max_length=50, null=True, blank=True)
#     twitter = models.CharField(max_length=50, null=True, blank=True)
#     slideshare = models.CharField(max_length=50, null=True, blank=True)
#     lattes = models.URLField(null=True, blank=True)
#     photo = ImageWithThumbsField(upload_to='images/members', sizes=((100, 100), ))
#     started_nsi_date = models.DateField()
#     desertion_nsi_date = models.DateField(null=True, blank=True)
#     is_renegade = models.BooleanField(editable=False)
#     slug = models.SlugField(max_length=100, blank=True)
# 
#     def github_link(self):
#         return "http://github.com/" + self.github
# 
#     def twitter_link(self):
#         return "http://twitter.com/" + self.twitter
# 
#     def slideshare_link(self):
#         return "http://www.slideshare.net/" + self.slideshare
# 
#     def github_feed(self):
#         return self.github_link() + '.atom'
# 
#     def __unicode__(self):
#         return self.name
# 
#     def save(self, *args, **kwargs):
#         self.slug = slugify(self.name)
#         if self.desertion_nsi_date is not None:
#             self.is_renegade = True
#             super(Member, self).save(*args, **kwargs)
#         else:
#             self.is_renegade = False
#             super(Member, 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/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)
# 
# class Document(models.Model):
#     title = models.CharField(max_length=100)
#     description = models.TextField()
#     file = models.FileField(upload_to='files/projects')
#     project = models.ForeignKey(Project)
#     uploaded_at = models.DateTimeField(auto_now_add=True)
# 
#     def __unicode__(self):
#         return self.title + ' - ' + self.description


import os
import shutil
from django.conf import settings
from lettuce import step, world
from lettuce.django import django_url
from should_dsl import should
from model_mommy import mommy
from apps.members.models import Member
from apps.members.models import Participation
from apps.projects.models import Project, Document

@step(u'exist a project:')
def exist_a_project(step):
    for project in step.hashes:
        Project(**project).save()
        file_name = project['logo'].split('/')[-1]
        shutil.copy2(os.path.join(settings.PROJECT_ROOT_PATH, 'apps', 'projects',
                                'features', 'resources', file_name),
                   os.path.join(settings.MEDIA_ROOT, 'test', 'images', 'projects'))
                 
@step(u'exist a member:')
def exist_a_member(step):
    for member in step.hashes:
        mommy.make_one(Member, name=member.get('name'), site=None, lattes=None, photo=None)

@step(r'"(.*)" member started participation on "(.*)" project')
def member_started_participation_on_project(step, member_name, project_name):
    member_obj = Member.objects.get(name=member_name)
    project_obj = Project.objects.get(name=project_name)

# Path: apps/members/models.py
# class Member(models.Model):
#     name = models.CharField(max_length=100)
#     nickname = models.CharField(max_length=100, null=True, blank=True)
#     phone = models.CharField(max_length=13, null=True, blank=True)
#     currently_does = models.TextField()
#     life_and_work = models.TextField()
#     function = models.CharField(max_length=100, choices=MEMBER_FUNCTIONS)
#     site = models.URLField(null=True, blank=True)
#     github = models.CharField(max_length=50, null=True, blank=True)
#     twitter = models.CharField(max_length=50, null=True, blank=True)
#     slideshare = models.CharField(max_length=50, null=True, blank=True)
#     lattes = models.URLField(null=True, blank=True)
#     photo = ImageWithThumbsField(upload_to='images/members', sizes=((100, 100), ))
#     started_nsi_date = models.DateField()
#     desertion_nsi_date = models.DateField(null=True, blank=True)
#     is_renegade = models.BooleanField(editable=False)
#     slug = models.SlugField(max_length=100, blank=True)
# 
#     def github_link(self):
#         return "http://github.com/" + self.github
# 
#     def twitter_link(self):
#         return "http://twitter.com/" + self.twitter
# 
#     def slideshare_link(self):
#         return "http://www.slideshare.net/" + self.slideshare
# 
#     def github_feed(self):
#         return self.github_link() + '.atom'
# 
#     def __unicode__(self):
#         return self.name
# 
#     def save(self, *args, **kwargs):
#         self.slug = slugify(self.name)
#         if self.desertion_nsi_date is not None:
#             self.is_renegade = True
#             super(Member, self).save(*args, **kwargs)
#         else:
#             self.is_renegade = False
#             super(Member, 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/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)
# 
# class Document(models.Model):
#     title = models.CharField(max_length=100)
#     description = models.TextField()
#     file = models.FileField(upload_to='files/projects')
#     project = models.ForeignKey(Project)
#     uploaded_at = models.DateTimeField(auto_now_add=True)
# 
#     def __unicode__(self):
#         return self.title + ' - ' + self.description


# Path: apps/projects/features/steps.py
import os
import shutil
from django.conf import settings
from lettuce import step, world
from lettuce.django import django_url
from should_dsl import should
from model_mommy import mommy
from apps.members.models import Member
from apps.members.models import Participation
from apps.projects.models import Project, Document


@step(u'exist a project:')
def exist_a_project(step):
    for project in step.hashes:
        Project(**project).save()
        file_name = project['logo'].split('/')[-1]
        shutil.copy2(os.path.join(settings.PROJECT_ROOT_PATH, 'apps', 'projects',
                                'features', 'resources', file_name),
                   os.path.join(settings.MEDIA_ROOT, 'test', 'images', 'projects'))
                 
@step(u'exist a member:')
def exist_a_member(step):
    for member in step.hashes:
        mommy.make_one(Member, name=member.get('name'), site=None, lattes=None, photo=None)

@step(r'"(.*)" member started participation on "(.*)" project')
def member_started_participation_on_project(step, member_name, project_name):
    member_obj = Member.objects.get(name=member_name)
    project_obj = Project.objects.get(name=project_name)

    mommy.make_one(Participation, member=member_obj, project=project_obj)