Repository: ciudadanointeligente/votainteligente-portal-electoral

Issue:
[Propuesta] Al momento de ser publicada no se envíá automáticamente a los candidatos.



Discussion:

Resolving patch:
diff --git a/popular_proposal/models.py b/popular_proposal/models.py
--- a/popular_proposal/models.py
+++ b/popular_proposal/models.py
@@ -196,12 +196,6 @@ def __str__(self):
     def get_absolute_url(self):
         return reverse('popular_proposals:detail', kwargs={'slug': self.slug})
 
-    def save(self, *args, **kwargs):
-        creating = self.pk is None
-        super(PopularProposal, self).save(*args, **kwargs)
-        if self.pk is not None and creating:
-            self.notify_candidates_of_new()
-
     def notify_candidates_of_new(self):
         if not (settings.NOTIFY_CANDIDATES and settings.NOTIFY_CANDIDATES_OF_NEW_PROPOSAL):
             return


Test patch:
diff --git a/popular_proposal/tests/subscription_tests.py b/popular_proposal/tests/subscription_tests.py
--- a/popular_proposal/tests/subscription_tests.py
+++ b/popular_proposal/tests/subscription_tests.py
@@ -243,14 +243,14 @@ def test_like_a_proposal_signal(self):
         self.assertIn(self.candidate2.name, the_mail.body)
         self.assertIn(str(2), the_mail.body)
 
-    def test_new_proposal_notification_for_candidates(self):
+    def test_proposal_notification_for_candidates(self):
         previous_amount = len(mail.outbox)
         proposal = PopularProposal.objects.create(proposer=self.fiera,
                                                   area=self.arica,
                                                   data=self.data,
                                                   title=u'This is a title'
                                                   )
-
+        proposal.notify_candidates_of_new()
         self.assertEquals(len(mail.outbox), previous_amount + 2)
         first_mail = mail.outbox[previous_amount]
         self.assertEquals(len(first_mail.to), 1)
@@ -282,6 +282,7 @@ def test_new_proposal_notification_with_login_info(self):
                                                   data=self.data,
                                                   title=u'This is a title'
                                                   )
+        proposal.notify_candidates_of_new()
         first_mail = mail.outbox[previous_amount]
         contact = self.candidate.contacts.all().first()
         self.assertIn(self.feli.username, first_mail.body)
@@ -291,8 +292,6 @@ def test_new_proposal_notification_with_media_naranja(self):
         self.feli.last_login = timezone.now()
         self.feli.save()
         self.candidate.taken_positions.all().delete()
-        for e in self.candidate.elections.all():
-            print e.id
         candidacy = Candidacy.objects.create(user=self.feli,
                                              candidate=self.candidate
                                              )
@@ -306,6 +305,7 @@ def test_new_proposal_notification_with_media_naranja(self):
                                                   data=self.data,
                                                   title=u'This is a title'
                                                   )
+        proposal.notify_candidates_of_new()
         first_mail = mail.outbox[previous_amount]
         contact = self.candidate.contacts.all().first()
         self.assertNotIn(self.feli.username, first_mail.body)