Пример #1
0
def contact_us(request):

    contact_us_form = ContactUsForm(request.POST or None)
    success_message = ''

    if request.POST and contact_us_form.is_valid():
        subject = '[Olho Neles]: Fale Conosco'

        message = ('Nome: %s\nEmail: %s\nIP: %s\nMensagem:\n\n%s') % (
            contact_us_form.cleaned_data['name'],
            contact_us_form.cleaned_data['email'],
            request.META['REMOTE_ADDR'],
            contact_us_form.cleaned_data['message'])

        from_field = '%s <%s>' % (contact_us_form.cleaned_data['name'],
                                  contact_us_form.cleaned_data['email'])

        send_mail(subject, message, from_field, [settings.CONTACT_US_EMAIL])

        success_message = ("""Sua mensagem foi enviada com sucesso. """
                           """Em breve entraremos em contato!""")

        contact_us_form = ContactUsForm(None)

    c = {'contact_us_form': contact_us_form,
         'success_message': success_message}

    return original_render(request, 'contact_us.html', c)
Пример #2
0
def render(request, to_disable, template, context):
    disable_list = to_disable and [item for item in to_disable[3:].split(',')] or []

    institutions = Institution.objects.all()
    institution_dicts = []
    for institution in institutions:
        d = {}
        d["siglum"] = institution.siglum
        d["name"] = institution.name
        d["logo"] = institution.logo
        d["enabled"] = institution.siglum not in disable_list
        legislatures = institution.legislature_set.all()
        if legislatures.count() > 1:
            legislature_dicts = []
            for legislature in legislatures:
                l = {}
                l["date_start"] = legislature.date_start
                l["date_end"] = legislature.date_end
                legislature_string = '%s-%d' % (institution.siglum, legislature.date_start.year)
                l["enabled"] = legislature_string in disable_list
                legislature_dicts.append(l)
            d["legislatures"] = legislature_dicts
        else:
            d["legislatures"] = None
        institution_dicts.append(d)
    context['institutions'] = institution_dicts
    context['extra_uri'] = to_disable

    # This is just to simplify the conversion to the single-institution-or-all view model,
    # so that we can reuse templates between both code paths for a while.
    context['institution'] = None

    return original_render(request, template, context)
Пример #3
0
def contact_us(request):

    contact_us_form = ContactUsForm(request.POST or None)
    success_message = ''

    if request.POST and contact_us_form.is_valid():
        subject = '[Olho Neles]: Fale Conosco'

        message = (u'Nome: %s\nEmail: %s\nIP: %s\nMensagem:\n\n%s') % (
            contact_us_form.cleaned_data['name'],
            contact_us_form.cleaned_data['email'], request.META['REMOTE_ADDR'],
            contact_us_form.cleaned_data['message'])

        from_field = u'%s <%s>' % (contact_us_form.cleaned_data['name'],
                                   contact_us_form.cleaned_data['email'])

        send_mail(subject, message, from_field, [settings.CONTACT_US_EMAIL])

        success_message = ("""Sua mensagem foi enviada com sucesso. """
                           """Em breve entraremos em contato!""")

        contact_us_form = ContactUsForm(None)

    c = {
        'contact_us_form': contact_us_form,
        'success_message': success_message
    }

    return original_render(request, 'contact_us.html', c)
Пример #4
0
def render(request, to_disable, template, context):
    disable_list = to_disable and [item for item in to_disable[3:].split(',')
                                   ] or []

    institutions = Institution.objects.all()
    institution_dicts = []
    for institution in institutions:
        d = {}
        d["siglum"] = institution.siglum
        d["name"] = institution.name
        d["logo"] = institution.logo
        d["enabled"] = institution.siglum not in disable_list
        legislatures = institution.legislature_set.all()
        if legislatures.count() > 1:
            legislature_dicts = []
            for legislature in legislatures:
                l = {}
                l["date_start"] = legislature.date_start
                l["date_end"] = legislature.date_end
                legislature_string = '%s-%d' % (institution.siglum,
                                                legislature.date_start.year)
                l["enabled"] = legislature_string in disable_list
                legislature_dicts.append(l)
            d["legislatures"] = legislature_dicts
        else:
            d["legislatures"] = None
        institution_dicts.append(d)
    context['institutions'] = institution_dicts
    context['extra_uri'] = to_disable

    # This is just to simplify the conversion to the single-institution-or-all view model,
    # so that we can reuse templates between both code paths for a while.
    context['institution'] = None

    return original_render(request, template, context)
Пример #5
0
def new_render(request, filter_spec, template, context):
    context['institution'] = None
    context['legislature'] = None
    context['filter_spec'] = None
    if filter_spec:
        institution, legislature = parse_filter(filter_spec)
        context['institution'] = institution
        context['legislature'] = legislature
        context['filter_spec'] = filter_spec
    return original_render(request, template, context)
Пример #6
0
def render(request, template, data, *args, **kwargs):
    help_text = None
    if 'help_text' in kwargs:
        help_text = kwargs['help_text']
        del kwargs['help_text']
    if help_text is not None:
        help_text = markdown.markdown(help_text)
    if help_text is not None or 'help_text' not in data:
        data['help_text'] = help_text
    return original_render(request, template, data, *args, **kwargs)
Пример #7
0
def render(request, template, data, *args, **kwargs):
    help_text = None
    if 'help_text' in kwargs:
        help_text = kwargs['help_text']
        del kwargs['help_text']
    if help_text is not None:
        help_text = markdown.markdown(help_text)
    if help_text is not None or 'help_text' not in data:
        data['help_text'] = help_text
    return original_render(request, template, data, *args, **kwargs)
Пример #8
0
def new_render(request, filter_spec, template, context):
    context['institution'] = None
    context['legislature'] = None
    context['filter_spec'] = None
    if filter_spec:
        institution, legislature = parse_filter(filter_spec)
        context['institution'] = institution
        context['legislature'] = legislature
        context['filter_spec'] = filter_spec
    return original_render(request, template, context)
Пример #9
0
def what_is_expenses(request):

    c = {}

    return original_render(request, 'what_is_expenses.html', c)
Пример #10
0
def error_404(request):
    c = {}
    return original_render(request, '404.html', c)
Пример #11
0
def error_500(request):
    c = {}
    return original_render(request, '500.html', c)
Пример #12
0
def what_is_expenses(request):

    c = {}

    return original_render(request, 'what_is_expenses.html', c)
Пример #13
0
def error_404(request):
    c = {}
    return original_render(request, '404.html', c)
Пример #14
0
def error_500(request):
    c = {}
    return original_render(request, '500.html', c)
Пример #15
0
def new_render(request, institution, template, context):
    context['institution'] = None
    if institution:
        context['institution'] = Institution.objects.get(siglum=institution)
    return original_render(request, template, context)
Пример #16
0
def new_render(request, institution, template, context):
    context['institution'] = None
    if institution:
        context['institution'] = Institution.objects.get(siglum=institution)
    return original_render(request, template, context)