Skip to content

Commit

Permalink
Haciendole unos cambios en los textos de candidaturas
Browse files Browse the repository at this point in the history
  • Loading branch information
Felipe Álvarez committed Sep 20, 2017
1 parent 17fe98a commit c6808a3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
12 changes: 12 additions & 0 deletions backend_candidate/models.py
Expand Up @@ -8,9 +8,11 @@
from django.core.urlresolvers import reverse
from django.contrib.sites.models import Site
from django.conf import settings
from django.utils.encoding import python_2_unicode_compatible
import uuid


@python_2_unicode_compatible
class Candidacy(models.Model):
user = models.ForeignKey(User, related_name='candidacies')
candidate = models.ForeignKey(Candidate)
Expand All @@ -21,6 +23,12 @@ class Candidacy(models.Model):
blank=True,
null=True)

def __str__(self):
return u'{} pertenece a la candidatura de {}'.format(self.user.username, self.candidate.name)

class Meta:
verbose_name = u"Candidatura"
verbose_name_plural = u"Candidaturas"

def is_candidate(user):
if not user.is_authenticated():
Expand Down Expand Up @@ -79,6 +87,10 @@ class CandidacyContact(models.Model):
initial_password = models.CharField(max_length=255,
blank=True)

class Meta:
verbose_name = u"Contacto de Candidatura"
verbose_name_plural = u"Contactos de Candidaturas"

def send_mail_with_link(self):
if self.times_email_has_been_sent >= settings.MAX_AMOUNT_OF_MAILS_TO_CANDIDATE:
return
Expand Down
7 changes: 7 additions & 0 deletions backend_candidate/tests/candidacy_tests.py
Expand Up @@ -73,6 +73,13 @@ def test_instanciate_candidacy(self):
self.assertTrue(candidacy.created)
self.assertTrue(candidacy.updated)

def test_candidacy_str(self):
candidacy = Candidacy.objects.create(user=self.feli,
candidate=self.candidate
)
self.assertIn(self.feli.username, str(candidacy))
self.assertIn(self.candidate.name, str(candidacy))

def test_candidacy_has_logged_in(self):
user = User.objects.create_user(username='user', password='password')
candidacy = Candidacy.objects.create(user=user,
Expand Down

0 comments on commit c6808a3

Please sign in to comment.