Example #1
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 #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.send_message(subject, body)
Example #3
0
def single_voter_email(voter_uuid, subject_template, body_template, extra_vars={}, language=None):
    voter = Voter.objects.get(uuid = voter_uuid)

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

    previous_language = translation.get_language()
    translation.activate(language)
    try:
        subject = render_template_raw(None, subject_template, the_vars)
        body = render_template_raw(None, body_template, the_vars)
    finally:
        translation.activate(previous_language)

    voter.user.send_message(subject, body)
Example #4
0
def single_voter_email(voter_uuid,
                       subject_template,
                       body_template,
                       extra_vars={}):
    voter = Voter.objects.get(uuid=voter_uuid)
    election = Election.objects.get(id=extra_vars['election_id'])

    the_vars = copy.copy(extra_vars)
    the_vars['voter'] = voter
    the_vars['election'] = election

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

    voter.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', {
            '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.user.send_notification(notification)
Example #7
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 #8
0
def single_voter_notify(voter_uuid, notification_template, extra_vars={}):
    voter = Voter.objects.get(uuid=voter_uuid)
    election = Election.objects.get(id=extra_vars['election_id'])

    the_vars = copy.copy(extra_vars)    
    the_vars['voter'] = voter
    the_vars['election'] = election

    notification = render_template_raw(None, notification_template, the_vars)

    voter.send_notification(notification)
Example #9
0
def single_voter_notify(voter_uuid, notification_template, extra_vars={}):
    activate(settings.LANGUAGE_CODE)
    voter = Voter.objects.get(uuid=voter_uuid)

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

    try:
        default_from_name = settings.DEFAULT_FROM_NAME.decode('utf8')
    except UnicodeDecodeError:
        default_from_name = settings.DEFAULT_FROM_NAME.decode('latin1')

    the_vars.update({'default_from_name': default_from_name})

    notification = render_template_raw(None, notification_template, the_vars)

    voter.send_notification(notification)
Example #10
0
def single_voter_notify(voter_uuid, notification_template, extra_vars={}):
    activate(settings.LANGUAGE_CODE)
    voter = Voter.objects.get(uuid = voter_uuid)

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

    try:
        default_from_name = settings.DEFAULT_FROM_NAME.decode('utf8')
    except UnicodeDecodeError:
        default_from_name = settings.DEFAULT_FROM_NAME.decode('latin1')

    the_vars.update({'default_from_name': default_from_name})

    notification = render_template_raw(None, notification_template, the_vars)

    voter.send_notification(notification)