Esempio n. 1
0
def edit_report(request, report_id):
    if request.method == 'POST':
        r = Report.objects.get(pk=report_id)
        if request.FILES:
            updated_form = ReportForm(request.POST, request.FILES, instance=r)
            r.variant_set.all().delete()
        else:
            updated_form = ReportForm(request.POST, instance=r)
        if updated_form.is_valid():
            updated_form.save()
            report_parser.load_into_db(r)
            return HttpResponseRedirect(reverse('manage_report'))
    else:
        project_pk = request.session.get('viewing_project', None)
        if project_pk is None:
            return HttpResponseRedirect(reverse('no_project'))
        project = Project.objects.get(pk=project_pk)
        report_obj = Report.objects.get(pk=report_id)
        rform = ReportForm(instance=report_obj)
        rform.fields['study'].queryset = project.study_set.all()
        context = {'report_form': rform,
                   'report': report_obj.report_file,
                   'pk': report_id,}
        context.update(csrf(request))
        return render_to_response('viewer/report/edit_report.html', context,
                                  context_instance=RequestContext(request))
Esempio n. 2
0
def report(request):
    if request.method == 'POST':
        name = request.user.username
        profile = get_object_or_404(Peep, username=name)
        form = ReportForm(request.POST, instance=profile)
        form.save()
        return redirect('home')
    else:
        form = ReportForm()
    return render(request, 'report.html', {'form': form})
Esempio n. 3
0
def upload_report(request):
    if request.method == 'POST':
        rform = ReportForm(request.POST, request.FILES)
        if rform.is_valid():
            rform.save()
            return HttpResponseRedirect('/viewer/upload_report/')
    else:
        rform = ReportForm(instance=Report())
        context = {'report_form': rform}
        reports = Report.objects.all()
        context['reports'] = reports
        context.update(csrf(request))
        return render_to_response('viewer/upload_report.html',
                                  context,
                                  context_instance=RequestContext(request))
Esempio n. 4
0
def upload_report(request):
    if request.method == 'POST':
        print "POST from upload_report"
        if request.FILES:
            rform = ReportForm(request.POST, request.FILES)
        else:
            rform = ReportForm(request.POST)
        if rform.is_valid():
            report = rform.save()
            report_parser.load_into_db(report)
            return HttpResponseRedirect(reverse('manage_report'))
        else:
            print "rform (ReportForm) is Invalid"
            print str(rform)
    else:
        project_pk = request.session.get('viewing_project', None)
        if project_pk is None:
            return HttpResponseRedirect(reverse('no_project'))
        project = Project.objects.get(pk=project_pk)
        rform = ReportForm(instance=Report(), initial={})
        rform.fields['study'].queryset = project.study_set.all()
        context = {'report_form': rform}
        context.update(csrf(request))
        return render_to_response('viewer/report/upload_report.html', context,
                                  context_instance=RequestContext(request))
Esempio n. 5
0
def submit_report(request):

    if request.method == "GET":

        submit_report_form = ReportForm()
        # print submit_report_form
        return render(request,'submit_report.html', {'submit_report_form':submit_report_form})

    if request.method == 'POST':

        submit_report_form = ReportForm(request.POST,request.FILES)

        print submit_report_form

        if submit_report_form.is_valid():

            report = submit_report_form.save(commit=False)
            report.profile=UserProfile.objects.get(user=request.user)
            report.save()


            return show_report(request, report_id=report.id)


        return render(request,'submit_report.html', {'submit_report_form':submit_report_form})
Esempio n. 6
0
def edit_report(request, report_id):
    if request.method == 'POST':
        r = Report.objects.get(pk=report_id)
        if request.FILES:
            updated_form = ReportForm(request.POST, request.FILES, instance=r)
        else:
            updated_form = ReportForm(request.POST, instance=r)
        if updated_form.is_valid():
            updated_form.save()
            return HttpResponseRedirect('/viewer/report')
    else:
        report_obj = Report.objects.get(pk=report_id)
        rform = ReportForm(instance=report_obj)
        context = {'report_form': rform,
                   'report': report_obj.report_file,
                   'pk': report_id,}
        context.update(csrf(request))
        return render_to_response('viewer/report/edit_report.html', context,
                                  context_instance=RequestContext(request))
Esempio n. 7
0
def upload_report(request):
    if request.method == 'POST':
        print "POST from upload_report"
        if request.FILES:
            rform = ReportForm(request.POST, request.FILES)
        else:
            rform = ReportForm(request.POST)
        if rform.is_valid():
            rform.save()
            return HttpResponseRedirect('/viewer/report/')
        else:
            print "rform (ReportForm) is Invalid"
            print str(rform)
    else:
        rform = ReportForm(instance=Report(), initial={})
        context = {'report_form': rform}
        context.update(csrf(request))
        return render_to_response('viewer/report/upload_report.html', context,
                                  context_instance=RequestContext(request))
Esempio n. 8
0
def create_report(request):
	if request.method == 'GET':
		form = ReportForm()
		return render_to_response('add_edit_report.html', {'form': form}, context_instance=RequestContext(request))

	if request.method == 'POST':
		form = ReportForm(request.POST)
		if form.is_valid():
			new_report = form.save()
			return redirect(reverse('edit_report', args=(new_report.id,)))

		return render_to_response('add_edit_report.html', {'form': form}, context_instance=RequestContext(request))
Esempio n. 9
0
def issue(request, issue_id, context=None):
    if context is None:
        context = {}
    current_issue = get_object_or_404(Issue, pk=issue_id)
    comment_form = CommentForm()
    description_form = DescriptionForm(instance=current_issue)
    report_form = ReportForm(instance=current_issue)
    control_form = ControlForm(instance=current_issue)
    if request.method == 'POST':
        if 'comment_form' in request.POST:
            comment_form = CommentForm(request.POST)
            if comment_form.is_valid():
                curr_comment = comment_form.save(commit=False)
                curr_comment.author = request.user
                curr_comment.issue = current_issue
                curr_comment.save()
                comment_form = CommentForm()
        if 'description_form' in request.POST:
            description_form = DescriptionForm(request.POST, instance=current_issue)
            if description_form.is_valid():
                description_form.save()
                description_form = DescriptionForm(instance=current_issue)
        if 'report_form' in request.POST:
            report_form = ReportForm(request.POST, instance=current_issue)
            if report_form.is_valid():
                report_form.save()
                report_form = ReportForm(instance=current_issue)
        if 'control_form' in request.POST:
            control_form = ControlForm(request.POST, instance=current_issue)
            if control_form.is_valid():
                control_form.save()
                control_form = ControlForm(instance=current_issue)

    context['issue'] = current_issue
    context['comment_form'] = comment_form
    context['description_form'] = description_form
    context['report_form'] = report_form
    context['control_form'] = control_form
    context['status_list'] = Status.objects.all()
    return render(request, 'helpdesk/issue.html', context)
Esempio n. 10
0
def new_report(request):     
    if request.method == 'POST':
        form = ReportForm(request.POST)
        if form.is_valid():
            f = form.save(commit=False)
            f.created_by = request.user.username
            f.save()
            messages.success(request, "Created new report: %s." % f.name)
            return HttpResponseRedirect(reverse('reports.views.view_report', 
                                                    kwargs={'report':f.slug}))
    else:
        form = ReportForm()

    return render(request, 'reports/new_report.html', {'form': form })
Esempio n. 11
0
def new_report(request):     
    if request.method == 'POST':
        form = ReportForm(request.POST)
        if form.is_valid():
            f = form.save(commit=False)
            f.created_by = request.user.username
            f.save()
            messages.success(request, "Created new report: %s." % f.name)
            return HttpResponseRedirect(reverse('reports.views.view_report', 
                                                    kwargs={'report':f.slug}))
    else:
        form = ReportForm()

    return render(request, 'reports/new_report.html', {'form': form })
Esempio n. 12
0
    def post(self, request):
        """
        Aquí entra si la petición es POST (como debe ser)
        """
        success_message = ''
        report = Report()
        form = ReportForm(request.POST, instance=report)

        if form.is_valid():
            new_report = form.save()
            form = ReportForm
            success_message = u'Tu denuncia ha sido guardada con éxito!'

        context = {'form': form, 'success_message': success_message}
        return render(request, 'report/new_report.html', context)
Esempio n. 13
0
def edit_report(request, report_id):

	report = Report.objects.get(id=report_id)
	
	if request.method == 'GET':
		form = ReportForm(instance=report)

		return render_to_response('add_edit_report.html', 
			{'form':form, 'editing':True, 'report':report}, 
			context_instance=RequestContext(request)
		)

	if request.method == 'POST':
		form = ReportForm(request.POST, instance=report)
		if form.is_valid():
			report = form.save()
			return redirect(reverse('report_home'))

		return render_to_response('add_edit_report.html', 
			{'form':form, 'editing':True, 'report':report}, 
			context_instance=RequestContext(request)
		)