示例#1
0
def view_dac_meeting_report_spreadsheet(request):
    if not (request.user.is_authenticated and request.user.is_staff):
        return HttpResponseRedirect(get_not_logged_in_page())

    if not (request.user.is_authenticated and request.user.is_staff):
        return HttpResponseRedirect(get_not_logged_in_page())

    dac_kwargs = {}

    if request.method == 'GET' and request.GET.has_key('start_date'):
        dac_form = DacForm(request.GET)
        if dac_form.is_valid():
            dac_kwargs.update(dac_form.get_dac_kwargs())

    dac_meetings = get_dac_meetings(dac_kwargs)

    book = xlwt.Workbook(encoding="utf-8")
    # With a workbook object made we can now add some sheets.
    sheet1 = book.add_sheet(slugify('DAC'))

    date_obj = datetime.now()

    sheet1 = make_dac_report(sheet1, dac_meetings)

    # create response object
    response = HttpResponse(mimetype='application/ms-excel')
    response['Content-Disposition'] = 'attachment; filename=dac_%s.xls' % (
        date_obj.strftime('%m%d-%I-%M%p-%S').lower())

    # send .xls spreadsheet to response stream
    book.save(response)
    return response
示例#2
0
def view_dac_meeting_report_spreadsheet(request):
    if not (request.user.is_authenticated and request.user.is_staff):
        return HttpResponseRedirect(get_not_logged_in_page())
    
    if not (request.user.is_authenticated and request.user.is_staff):
        return HttpResponseRedirect(get_not_logged_in_page())

    dac_kwargs = {}

    if request.method=='GET' and request.GET.has_key('start_date'):        
         dac_form = DacForm(request.GET)
         if dac_form.is_valid():
             dac_kwargs.update(dac_form.get_dac_kwargs())

    dac_meetings = get_dac_meetings(dac_kwargs)

    
    book = xlwt.Workbook(encoding="utf-8")
    # With a workbook object made we can now add some sheets.
    sheet1 = book.add_sheet(slugify('DAC'))

    date_obj = datetime.now()

    sheet1 = make_dac_report(sheet1, dac_meetings)

    # create response object
    response = HttpResponse(mimetype='application/ms-excel')
    response['Content-Disposition'] = 'attachment; filename=dac_%s.xls' % ( date_obj.strftime('%m%d-%I-%M%p-%S').lower())

    # send .xls spreadsheet to response stream
    book.save(response)
    return response
示例#3
0
def view_dac_meeting_report(request):
    if not (request.user.is_authenticated and request.user.is_staff):
        return HttpResponseRedirect(get_not_logged_in_page())

    lu = get_basic_view_dict(request)

    lu.update( { 'DAC_MEETING_REPORT_PAGE' : True \
                  , 'IS_DAC_MEETING_PAGE' : True\
                  , 'page_title' : 'DAC Meeting Report'\
                  , 'RM_STATUS_SCHEDULED' : RM_STATUS_SCHEDULED
                  , 'RM_FAIL_STATUSES' : RM_FAIL_STATUSES
            })
    dac_kwargs = {}

    dac_meetings = None
    num_dac_meetings = 0
    if request.method == 'GET' and request.GET.has_key('start_date'):
        dac_form = DacForm(request.GET)
        if dac_form.is_valid():
            dac_kwargs.update(dac_form.get_dac_kwargs())
            dac_meetings = get_dac_meetings(dac_kwargs)
            num_dac_meetings = len(dac_meetings)
        else:
            print 'NOT valid!'
            lu.update({'ERR_form_not_valid': True})
    else:
        dac_form = DacForm()


    lu.update({ 'dac_meetings' :  dac_meetings\
            , 'num_dac_meetings' : num_dac_meetings\
            , 'dac_form' : dac_form\
            , 'QUERY_STRING' : request.META['QUERY_STRING']
        })

    return render_to_response('dac_meetings/dac_meetings.html',
                              lu,
                              context_instance=RequestContext(request))
示例#4
0
def view_dac_meeting_report(request):
    if not (request.user.is_authenticated and request.user.is_staff):
        return HttpResponseRedirect(get_not_logged_in_page())
    
    lu = get_basic_view_dict(request)
    
    lu.update( { 'DAC_MEETING_REPORT_PAGE' : True \
                  , 'IS_DAC_MEETING_PAGE' : True\
                  , 'page_title' : 'DAC Meeting Report'\
                  , 'RM_STATUS_SCHEDULED' : RM_STATUS_SCHEDULED
                  , 'RM_FAIL_STATUSES' : RM_FAIL_STATUSES
            })
    dac_kwargs = {}
    
    dac_meetings = None
    num_dac_meetings = 0
    if request.method=='GET' and request.GET.has_key('start_date'):        
         dac_form = DacForm(request.GET)
         if dac_form.is_valid():
             dac_kwargs.update(dac_form.get_dac_kwargs())
             dac_meetings =  get_dac_meetings(dac_kwargs)
             num_dac_meetings = len(dac_meetings)
         else:
             print 'NOT valid!'
             lu.update({ 'ERR_form_not_valid' : True })
    else: 
         dac_form = DacForm()

        
    lu.update({ 'dac_meetings' :  dac_meetings\
            , 'num_dac_meetings' : num_dac_meetings\
            , 'dac_form' : dac_form\
            , 'QUERY_STRING' : request.META['QUERY_STRING'] 
        })
    
    return render_to_response('dac_meetings/dac_meetings.html', lu, context_instance=RequestContext(request))