Exemplo n.º 1
0
def __process_period(request, is_prev):
    context = __process_dates(request)
    from_date = context['from_date']
    to_date = context['to_date']

    if is_prev:
        reference_date = context['from_date'] - relativedelta(days=1)
        op = lambda x,y: x - y
    else:
        reference_date = context['to_date'] + relativedelta(days=1)
        op = lambda x,y: x + y

    aux = '&%s=True'
    if OVERTIME_FLAG in request.GET:
        (from_date, to_date) = overtime_period(reference_date)
        aux = aux % OVERTIME_FLAG
    elif MONTHLY_FLAG in request.GET:
        (from_date, to_date) = month(reference_date)
        aux = aux % MONTHLY_FLAG
    else:
        (from_date, to_date) = period(context['from_date'],
                                      context['to_date'],
                                      op)
        aux = ''

    referer = '/'.join(request.META['HTTP_REFERER'].split('/')[3:-1])

    if referer != 'efi/charts':
        redirect_to = '/%s/?from_date=%s&to_date=%s%s' % (referer,
                                                          from_date,
                                                          to_date,
                                                          aux)
    else:
        qstring = '&%s' % '&'.join(request.META['HTTP_REFERER'].
                                   split('/').pop().split('&')[1:])
        redirect_to = '/%s/?dates=%s,%s%s%s' % (referer,
                                                from_date,
                                                to_date,
                                                qstring,
                                                aux)

    return HttpResponseRedirect(redirect_to)
Exemplo n.º 2
0
def eff_horas_extras(request):
    from_date, to_date = overtime_period(date.today())
    return HttpResponseRedirect('/efi/?from_date=%s&to_date=%s&%s=True' % (from_date, to_date, OVERTIME_FLAG))