Example #1
0
def single_voter_email(voter_uuid,
                       subject_template,
                       body_template,
                       extra_vars={},
                       update_date=True,
                       update_booth_invitation_date=False):
    voter = Voter.objects.get(uuid=voter_uuid)
    lang = voter.poll.election.communication_language
    with translation.override(lang):
        the_vars = copy.copy(extra_vars)
        the_vars.update({
            'voter': voter,
            'poll': voter.poll,
            'election': voter.poll.election
        })
        subject = render_template_raw(None, subject_template, the_vars)
        body = render_template_raw(None, body_template, the_vars)
        linked_voters = voter.linked_voters
        if update_date:
            for voter in linked_voters:
                voter.last_email_send_at = datetime.datetime.now()
                voter.save()
        if update_booth_invitation_date:
            for voter in linked_voters:
                voter.last_booth_invitation_send_at = datetime.datetime.now()
                voter.save()
        voter.user.send_message(subject, body)
Example #2
0
def single_voter_email(voter_uuid, subject_template, body_template, extra_vars={}):
    voter = Voter.objects.get(uuid = voter_uuid)

    the_vars = copy.copy(extra_vars)
    the_vars.update({'voter' : voter})

    subject = render_template_raw(None, subject_template, the_vars)
    body = render_template_raw(None, body_template, the_vars)

    voter.user.send_message(subject, body)
Example #3
0
def single_voter_email(voter_uuid,
                       subject_template,
                       body_template,
                       extra_vars={}):
    voter = Voter.objects.get(uuid=voter_uuid)

    the_vars = copy.copy(extra_vars)
    the_vars.update({"voter": voter})

    subject = render_template_raw(None, subject_template, the_vars)
    body = render_template_raw(None, body_template, the_vars)

    voter.send_message(subject, body)
Example #4
0
def single_voter_email(voter_uuid, subject_template, body_template,
                       extra_vars={}, update_date=True):
    voter = Voter.objects.get(uuid = voter_uuid)

    the_vars = copy.copy(extra_vars)
    the_vars.update({'voter' : voter})

    subject = render_template_raw(None, subject_template, the_vars)
    body = render_template_raw(None, body_template, the_vars)

    if update_date:
      voter.last_email_send_at = datetime.datetime.now()
      voter.save()

    voter.user.send_message(subject, body)
Example #5
0
def login_box_raw(request, return_url="/", auth_systems=None):
    """
    a chunk of HTML that shows the various login options
    """
    default_auth_system_obj = None
    if helios_auth.DEFAULT_AUTH_SYSTEM:
        default_auth_system_obj = AUTH_SYSTEMS[helios_auth.DEFAULT_AUTH_SYSTEM]

    # make sure that auth_systems includes only available and enabled auth systems
    if auth_systems is not None:
        enabled_auth_systems = (set(auth_systems).intersection(
            set(helios_auth.ENABLED_AUTH_SYSTEMS)).intersection(
                set(AUTH_SYSTEMS.keys())))
    else:
        enabled_auth_systems = set(
            helios_auth.ENABLED_AUTH_SYSTEMS).intersection(
                set(AUTH_SYSTEMS.keys()))

    form = password.LoginForm()

    return render_template_raw(
        request,
        "login_box.html",
        {
            "enabled_auth_systems": enabled_auth_systems,
            "return_url": return_url,
            "default_auth_system": helios_auth.DEFAULT_AUTH_SYSTEM,
            "default_auth_system_obj": default_auth_system_obj,
            "form": form,
        },
    )
Example #6
0
def single_voter_notify(voter_uuid, notification_template, extra_vars={}):
    voter = Voter.objects.get(uuid=voter_uuid)

    the_vars = copy.copy(extra_vars)
    the_vars.update({"voter": voter})

    notification = render_template_raw(None, notification_template, the_vars)

    voter.send_notification(notification)
Example #7
0
def vote_cast_send_message(user, voter, election, cast_vote, **kwargs):
    ## FIXME: this doesn't work for voters that are not also users
    # prepare the message
    subject_template = 'email/cast_vote_subject.txt'
    body_template = 'email/cast_vote_body.txt'

    extra_vars = {
        'election': election,
        'voter': voter,
        'cast_vote': cast_vote,
        'cast_vote_url': helios.views.get_castvote_url(cast_vote),
        'custom_subject': "%s - vote cast" % election.name
    }
    subject = render_template_raw(None, subject_template, extra_vars)
    body = render_template_raw(None, body_template, extra_vars)

    # send it via the notification system associated with the auth system
    user.send_message(subject, body)
Example #8
0
def vote_cast_send_message(user, voter, election, cast_vote, **kwargs):
  ## FIXME: this doesn't work for voters that are not also users
  # prepare the message
  subject_template = 'email/cast_vote_subject.txt'
  body_template = 'email/cast_vote_body.txt'
  
  extra_vars = {
    'election' : election,
    'voter': voter,
    'cast_vote': cast_vote,
    'cast_vote_url': helios.views.get_castvote_url(cast_vote),
    'custom_subject' : _("[vote cast] - %(election_name)s") % {'election_name' : election.name}
  }
  subject = render_template_raw(None, subject_template, extra_vars)
  body = render_template_raw(None, body_template, extra_vars)
  
  # send it via the notification system associated with the auth system
  user.send_message(subject, body)
Example #9
0
def single_voter_notify(voter_uuid, notification_template, extra_vars={}):
    voter = Voter.objects.get(uuid = voter_uuid)

    the_vars = copy.copy(extra_vars)
    the_vars.update({'voter' : voter})

    notification = render_template_raw(None, notification_template, the_vars)

    voter.user.send_notification(notification)
Example #10
0
def vote_cast_send_message(user, voter, election, cast_vote, **kwargs):
    # FIXME: this doesn't work for voters that are not also users
    # prepare the message
    subject_template = "email/cast_vote_subject.txt"
    body_template = "email/cast_vote_body.txt"

    extra_vars = {
        "election": election,
        "voter": voter,
        "cast_vote": cast_vote,
        "cast_vote_url": helios.views.get_castvote_url(cast_vote),
        "custom_subject": "%s - vote cast" % election.name,
    }
    subject = render_template_raw(None, subject_template, extra_vars)
    body = render_template_raw(None, body_template, extra_vars)

    # send it via the notification system associated with the auth system
    user.send_message(subject, body)
Example #11
0
def single_voter_email(voter_uuid, subject_template, body_template,
                       extra_vars={}, update_date=True,
                       update_booth_invitation_date=False):
    voter = Voter.objects.get(uuid=voter_uuid)
    lang = voter.poll.election.communication_language
    with translation.override(lang):
        the_vars = copy.copy(extra_vars)
        the_vars.update({'voter' : voter, 'poll': voter.poll,
                         'election': voter.poll.election})
        subject = render_template_raw(None, subject_template, the_vars)
        body = render_template_raw(None, body_template, the_vars)
        linked_voters = voter.linked_voters
        if update_date:
            for voter in linked_voters:
                voter.last_email_send_at = datetime.datetime.now()
                voter.save()
        if update_booth_invitation_date:
            for voter in linked_voters:
                voter.last_booth_invitation_send_at = datetime.datetime.now()
                voter.save()
        voter.user.send_message(subject, body)
Example #12
0
 def render_template(self, tpl, tpl_vars):
     return render_template_raw(None, tpl, tpl_vars)
Example #13
0
 def render_template(self, tpl, tpl_vars):
     return render_template_raw(None, tpl, tpl_vars)