-
-
Save pierrejean-coudert/4690376 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@login_required | |
def report(request): | |
end = get_week_dates(datetime.now())[1] | |
begin = get_week_dates(datetime.now()-timedelta(days=7))[0] | |
if request.method == 'GET': | |
data = request.GET.copy() | |
if data: | |
form = AgendaForm(data, auto_id = True, initial={'begin':begin, 'end':end}) | |
if form.is_valid(): | |
if 'begin' in form.data and 'end' in form.data: | |
begin = form.cleaned_data['begin'] | |
end = form.cleaned_data['end'] | |
else: | |
form = AgendaForm(auto_id = True, initial={'begin':begin, 'end':end}) | |
else: | |
form = AgendaForm(auto_id = True, initial={'begin':begin, 'end':end}) | |
min_requests = [] | |
maj_requests = [] | |
for modification_request in ModificationRequest.objects.exclude(progress_status__in = ('refused', 'request_pending', 'pending')): | |
comments = modification_request.requestcomment_set.filter(date__range = (begin, end)) | |
if comments: | |
if modification_request.is_priority_max(): | |
maj_requests.append({'object':modification_request, 'comments':comments}) | |
else: | |
min_requests.append({'object':modification_request, 'comments':comments}) | |
template_name = 'om_templates/report.html' | |
if 'printable' in form.data and form.data['printable']: | |
template_name = 'om_templates/print_report.html' | |
return render_to_response(template_name, | |
{'form':form, | |
'maj_requests':maj_requests, | |
'min_requests':min_requests | |
}, | |
context_instance=RequestContext(request)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment