Beispiel #1
0
def new(request):
	unfinished_report = get_unfinished_report()
	if unfinished_report:
		return HttpResponseRedirect('/unfinished/')
	if request.method == 'POST':
		form = StartForm(request.POST)
		if form.is_valid():
			report = Report()
			now = datetime.today()
			report.__dict__.update(fill_count(form, assignee_prefix = 'start_', update = {
				'year': now.year,
				'start_datetime': now,
				'report_id': get_last_report_id() + 1,
				'report_type_id': form.cleaned_data["report_type_id"],
			}))
			report.save()
			return redirect("/%d/" % report.id)
		return render_to_response('zrapport/start.html', {
			'form': form
		}, context_instance = RequestContext(request))
	
	rt = ReportType.objects.all()
	if(len(rt) == 0):
		return HttpResponse('Det finnes ingen rapport-typer, kontakt administrator')
	
	return render_to_response('zrapport/start.html', {
		'form': StartForm(fill_count(rt[0], source_prefix = 'start_', update = {
			'report_type_id': rt[0].id,
		}))
	}, context_instance = RequestContext(request))
Beispiel #2
0
def start(request, report_id):
    report = get_object_or_404(Report, pk=report_id)
    if request.method == 'POST':
        form = StartForm(request.POST)
        if form.is_valid():
            report.__dict__.update(
                fill_count(form,
                           assignee_prefix='start_',
                           update={
                               'report_type_id':
                               form.cleaned_data['report_type_id']
                           }))
            report.save()
            return redirect("/%d/" % report.id)
        return render_to_response('zrapport/start.html', {
            'form': form,
            'unfinished_report': get_unfinished_report(),
            'report': report,
        },
                                  context_instance=RequestContext(request))
    return render_to_response('zrapport/start.html', {
        'form':
        StartForm(
            fill_count(report,
                       source_prefix='start_',
                       update={
                           'report_type_id': report.report_type_id,
                       })),
        'unfinished_report':
        get_unfinished_report(),
        'report':
        report,
    },
                              context_instance=RequestContext(request))
Beispiel #3
0
def new(request):
    unfinished_report = get_unfinished_report()
    if unfinished_report:
        return HttpResponseRedirect('/unfinished/')
    if request.method == 'POST':
        form = StartForm(request.POST)
        if form.is_valid():
            report = Report()
            now = datetime.today()
            report.__dict__.update(
                fill_count(form,
                           assignee_prefix='start_',
                           update={
                               'year':
                               now.year,
                               'start_datetime':
                               now,
                               'report_id':
                               get_last_report_id() + 1,
                               'report_type_id':
                               form.cleaned_data["report_type_id"],
                           }))
            report.save()
            return redirect("/%d/" % report.id)
        return render_to_response('zrapport/start.html', {'form': form},
                                  context_instance=RequestContext(request))

    rt = ReportType.objects.all()
    if (len(rt) == 0):
        return HttpResponse(
            'Det finnes ingen rapport-typer, kontakt administrator')

    return render_to_response('zrapport/start.html', {
        'form':
        StartForm(
            fill_count(rt[0],
                       source_prefix='start_',
                       update={
                           'report_type_id': rt[0].id,
                       }))
    },
                              context_instance=RequestContext(request))
Beispiel #4
0
def start(request, report_id):
	report = get_object_or_404(Report, pk=report_id)
	if request.method == 'POST':
		form = StartForm(request.POST)
		if form.is_valid():
			report.__dict__.update(fill_count(form, assignee_prefix = 'start_', update = {
				'report_type_id': form.cleaned_data['report_type_id']
			}))
			report.save()
			return redirect("/%d/" % report.id)
		return render_to_response('zrapport/start.html', {
			'form': form,
			'unfinished_report': get_unfinished_report(),
			'report': report,
		}, context_instance = RequestContext(request))
	return render_to_response('zrapport/start.html', {
		'form': StartForm(fill_count(report, source_prefix = 'start_', update = {
			'report_type_id': report.report_type_id,
		})),
		'unfinished_report': get_unfinished_report(),
		'report': report,
	}, context_instance = RequestContext(request))