def save(self, *args, **kwargs):
        for field_key in self.cleaned_data.keys():
            self.temporary_data.comments[field_key] = self.cleaned_data[field_key]
        self.temporary_data.status = ProposalTemporaryData.Statuses.InTheirSide
        self.temporary_data.save()
        comments = {}
        for key in self.temporary_data.data.keys():
            if self.temporary_data.comments[key]:
                comments[key] = {
                    'original': self.temporary_data.data[key],
                    'comments': self.temporary_data.comments[key]
                }

        site = Site.objects.get_current()
        mail_context = {
            'area': self.temporary_data.area,
            'temporary_data': self.temporary_data,
            'moderator': self.moderator,
            'comments': comments,
            'site': site,

        }
        send_mail(mail_context, 'popular_proposal_moderation',
                  to=[self.temporary_data.proposer.email])
        return self.temporary_data
 def send(self):
     context = self.get_context()
     if not context['commitments']:
         return
     for commitment in context['commitments']:
         commitment.notifications.filter(user=self.user).update(notified=True)
     send_mail(context, self.template_prefix, to=[self.user.email])
예제 #3
0
 def notify(self):
     for person in self.get_who():
         email = self.get_mail_from(person)
         context = self.get_context(person=person)
         template = self.get_template()
         send_mail(context, template,
                   to=[email])
예제 #4
0
파일: models.py 프로젝트: lfalvarez/votai
    def create_proposal(self, moderator=None):
        self.status = ProposalTemporaryData.Statuses.Accepted
        self.save()
        title = self.get_title()
        clasification = self.data.get('clasification', '')
        one_liner = self.data.get('one_liner', '')

        creation_kwargs = self.determine_kwargs(title=title,
                                                clasification=clasification,
                                                area=self.area,
                                                proposer=self.proposer,
                                                data=self.data,
                                                one_liner=one_liner,
                                                temporary=self)
        popular_proposal = PopularProposal(**creation_kwargs)
        popular_proposal.save()
        site = Site.objects.get_current()
        mail_context = {
            'area': self.area,
            'temporary_data': self,
            'moderator': moderator,
            'site': site,
        }
        send_mail(mail_context,
                  'popular_proposal_accepted',
                  to=[self.proposer.email])
        return popular_proposal
예제 #5
0
    def save(self):
        mail = self.cleaned_data['other_email']
        context = {'candidate': self.candidate.name}
        self.contact = CandidacyContact.objects.create(
            candidate=self.candidate)
        if self.cleaned_data['tse_email']:
            self.contact.mail = self.cleaned_data['tse_email']

            send_mail(
                context,
                'contato_novo_com_candidato',
                to=[self.candidate.original_email],
            )

        if self.cleaned_data['other_email']:
            self.contact.mail = self.cleaned_data['other_email']
            send_mail(
                context,
                'contato_novo_com_candidato',
                to=[self.cleaned_data['other_email']],
            )

        if not self.cleaned_data['tse_email'] and not self.cleaned_data[
                'other_email']:
            self.candidate.is_ghost = True
            self.candidate.save()
        self.contact.save()
        VolunteerGetsCandidateEmailLog.objects.get_or_create(
            volunteer=self.volunteer, candidate=self.candidate)
예제 #6
0
파일: models.py 프로젝트: lfalvarez/votai
 def send(self):
     context = self.get_context()
     if not context['commitments']:
         return
     for commitment in context['commitments']:
         commitment.notifications.filter(user=self.user).update(
             notified=True)
     send_mail(context, self.template_prefix, to=[self.user.email])
 def create_confirmation(self):
     confirmation = MessageConfirmation.objects.create(message=self)
     site = Site.objects.get_current()
     context = {'election': self.election, 'message': self, 'site': site}
     send_mail(context,
               'confirmation',
               to=[self.author_email],
               from_email=settings.NO_REPLY_MAIL)
예제 #8
0
 def send_mail_with_link(self):
     if self.times_email_has_been_sent >= settings.MAX_AMOUNT_OF_MAILS_TO_CANDIDATE:
         return
     send_mail(
         {'contact': self},
         'candidates/join_us_pls',
         to=[self.mail],
     )
     self.times_email_has_been_sent += 1
     self.save()
def say_thanks_to_the_volunteer(sender, instance, created, raw, **kwargs):
    if raw:
        return
    if created:
        try:
            log = VolunteerGetsCandidateEmailLog.objects.get(candidate=instance.candidate)
            context = {'candidate': log.candidate}
            send_mail(context, 'candidato_com_a_gente_por_sua_acao', to=[log.volunteer.email],)
        except VolunteerGetsCandidateEmailLog.DoesNotExist:
            pass
예제 #10
0
파일: models.py 프로젝트: lfalvarez/votai
 def notify_new(self):
     site = Site.objects.get_current()
     mail_context = {
         'area': self.area,
         'temporary_data': self,
         'site': site,
     }
     if self.proposer.email:
         send_mail(mail_context,
                   'new_temporary_proposal',
                   to=[self.proposer.email])
    def save(self, *args, **kwargs):
        creating = self.pk is None
        ## Contact can be none, since a volunteer can
        ## say that she/he contacted the candidate through other means
        if creating and self.contact:
            context = {
                'candidate': self.candidate.name
            }

            send_mail(context, 'contato_novo_com_candidato', to=[self.contact.mail],)
        return super(VolunteerGetsCandidateEmailLog, self).save(*args, **kwargs)
예제 #12
0
 def send_activation_email(self, user):
     """
     Send the activation email. The activation key is the username,
     signed using TimestampSigner.
     """
     activation_key = self.get_activation_key(user)
     context = self.get_email_context(activation_key)
     context.update({
         'user': user,
     })
     send_mail(context, 'organization_activation', to=[user.email],)
예제 #13
0
 def send(self):
     proposals = self.get_proposals()
     subscriptions = self.get_subscriptions()
     if not proposals:
         return False
     context = {'proposals': proposals,
                'subscriptions': subscriptions,
                'user': self.user}
     send_mail(context, 'search_proposals_subscription',
               to=[self.user.email])
     return True
예제 #14
0
파일: models.py 프로젝트: lfalvarez/votai
 def save(self, *args, **kwargs):
     super(ProposalLike, self).save(*args, **kwargs)
     created = self.pk is not None
     if created:
         if self.user.profile.is_organization:
             template = 'new_sponsorshipnotification_to_proposer'
             context = {'like': self}
             send_mail(context, template, to=[self.proposal.proposer.email])
             template = 'new_sponsorshipnotification_to_sponsorer'
             context = {'like': self}
             send_mail(context, template, to=[self.user.email])
         self.numerical_notification()
예제 #15
0
파일: models.py 프로젝트: lfalvarez/votai
 def notify_candidates_of_new(self):
     if not (settings.NOTIFY_CANDIDATES
             and settings.NOTIFY_CANDIDATES_OF_NEW_PROPOSAL):
         return
     template = 'notification_for_candidates_of_new_proposal'
     context = {'proposal': self}
     area = Area.objects.get(id=self.area.id)
     for election in area.elections.all():
         for candidate in election.candidates.all():
             for contact in candidate.contacts.all():
                 context.update({'candidate': candidate})
                 send_mail(context, template, to=[contact.mail])
    def send_mail_with_user_and_password(self):
        if self.times_email_has_been_sent >= settings.MAX_AMOUNT_OF_MAILS_TO_CANDIDATE:
            return
        self.times_email_has_been_sent += 1
        if self.candidacy is None:
            user = self.create_and_set_user()

        site = Site.objects.get_current()
        login_url = reverse('backend_candidate:candidate_auth_login')
        full_login_url = "http://%s%s" % (site.domain, login_url)
        send_mail({'contact': self, 'login_url': full_login_url},
                  'candidates/mail_with_user_and_password', to=[self.mail],)
예제 #17
0
파일: models.py 프로젝트: lfalvarez/votai
 def reject(self, reason, moderator=None):
     self.rejected_reason = reason
     self.status = ProposalTemporaryData.Statuses.Rejected
     self.save()
     site = Site.objects.get_current()
     mail_context = {
         'area': self.area,
         'temporary_data': self,
         'moderator': moderator,
         'site': site,
     }
     send_mail(mail_context,
               'popular_proposal_rejected',
               to=[self.proposer.email])
 def send_mail(self, sleep):
     context = self.suggestion.get_context_for_candidate(self.candidate)
     context['formset'] = self.formset
     context['candidate_incremental'] = self
     for candidacy in self.candidate.candidacy_set.all():
         context['candidacy'] = candidacy
         if candidacy.user.last_login is None:
             try:
                 contact = candidacy.user.candidacy_contact
                 context['contact'] = contact
             except CandidacyContact.DoesNotExist:
                 pass
         subject = None
         if self.suggestion and self.suggestion.subject:
             subject = self.suggestion.subject
         send_mail(context, 'suggestions_for_candidates',
               subject=subject,
               to=[candidacy.user.email])
         time.sleep(sleep)
    def save(self):
        mail = self.cleaned_data['other_email']
        context = {
            'candidate': self.candidate.name
        }
        self.contact = CandidacyContact.objects.create(candidate=self.candidate)
        if self.cleaned_data['tse_email']:
            self.contact.mail = self.cleaned_data['tse_email']
            
            send_mail(context, 'contato_novo_com_candidato', to=[self.candidate.original_email],)

        if self.cleaned_data['other_email']:
            self.contact.mail = self.cleaned_data['other_email']
            send_mail(context, 'contato_novo_com_candidato', to=[self.cleaned_data['other_email']],)

        if not self.cleaned_data['tse_email'] and not self.cleaned_data['other_email']:
            self.candidate.is_ghost=True
            self.candidate.save()
        self.contact.save()
        VolunteerGetsCandidateEmailLog.objects.get_or_create(volunteer=self.volunteer, candidate=self.candidate)
예제 #20
0
 def send_mail(self, sleep):
     context = self.suggestion.get_context_for_candidate(self.candidate)
     context['formset'] = self.formset
     context['candidate_incremental'] = self
     for candidacy in self.candidate.candidacy_set.all():
         context['candidacy'] = candidacy
         if candidacy.user.last_login is None:
             try:
                 contact = candidacy.user.candidacy_contact
                 context['contact'] = contact
             except CandidacyContact.DoesNotExist:
                 pass
         subject = None
         if self.suggestion and self.suggestion.subject:
             subject = self.suggestion.subject
         send_mail(context,
                   'suggestions_for_candidates',
                   subject=subject,
                   to=[candidacy.user.email])
         time.sleep(sleep)
 def send(self):
     for person in self.people.all():
         outbound_message = OutboundMessage.objects.create(message=self,
                                                           person=person)
         reply_to = '%(localpart)s+%(key)s@%(domain)s' % {
             'localpart': settings.EMAIL_LOCALPART,
             'key': outbound_message.key,
             'domain': settings.EMAIL_DOMAIN
         }
         site = Site.objects.get_current()
         context = {
             'election': self.election,
             'candidate': person,
             'message': self,
             'site': site
         }
         send_mail(context, 'nueva_pregunta_candidato', to=[person.email], \
                   reply_to=reply_to)
     self.status.sent = True
     self.status.save()
 def send_mail_with_link(self):
     if self.times_email_has_been_sent >= settings.MAX_AMOUNT_OF_MAILS_TO_CANDIDATE:
         return
     send_mail({'contact': self}, 'candidates/join_us_pls', to=[self.mail],)
     self.times_email_has_been_sent += 1
     self.save()
예제 #23
0
 def send_mail(self):
     context = self.get_mail_context()
     if context['proposals']:
         send_mail(context, self.mail_template, to=[self.user.email])
 def send_mail(self):
     context = self.get_mail_context()
     if context['proposals']:
         send_mail(context, self.mail_template,
                   to=[self.user.email])