Example #1
0
 def dispatch(self, request, *args, **kwargs):
     if not 'fecha_desde' in request.GET:
         start, stop = get_30_days()
         return HttpResponseRedirect('%s?fecha_desde=%s&fecha_hasta=%s' % (
             request.path, format_date(start), format_date(stop)
         ))
     return super(BaseReportView, self).dispatch(request, *args, **kwargs)
Example #2
0
    def get_context_data(self, **kwargs):
        data = super(BaseReportView, self).get_context_data(**kwargs)

        try:
            data["fecha_desde"] = datetime.strptime(self.request.GET.get("fecha_desde"), '%d/%m/%Y')
            data["fecha_hasta"] = datetime.strptime(self.request.GET.get("fecha_hasta"), '%d/%m/%Y')
        except:
            start, end = get_30_days()
            data["fecha_desde"] = start
            data["fecha_hasta"] = end
        data["group_by"] = self.request.GET.get("group_by", None)
        return data