Example #1
0
def editReport(request, product_id, asset_id, report_id):
	assetReport = get_object_or_404(AssetReport, pk=report_id)

	if request.GET.get('return'):
		returnPage = request.GET['return']
	else:
		returnPage = ''	

	if request.method == 'POST':
		form = CreateAssetReportForm(request.POST, instance=assetReport)
		if form.is_valid():
			# create a new item
			assetReport = form.save(commit=False)			
			contents = form.cleaned_data['contents'],
			work_order = form.cleaned_data['work_order'],
			#response_to = form.cleaned_data['response_to'],
			submitted = form.cleaned_data['submitted'],
			submitted_by = request.user
			assetReport.save()
			# Always redirect after a POST

			asset = get_object_or_404(Asset, pk=asset_id)
			if submitted:
				asset.status = AssetStatus.objects.get(status='Awaiting QA')
			else:
				asset.status = AssetStatus.objects.get(status='QA Submission Required')			
					#asset.status = AssetStatus.objects.get(status='In Progress')
			asset.save()

			if returnPage == 'testing':
				return HttpResponseRedirect(reverse('testing-submit'))
			else:
				return HttpResponseRedirect(reverse('asset-detail', kwargs={'product_id': assetReport.asset.product.id, 'asset_id': assetReport.asset.id})+'#'+ str(assetReport.id))
	else:        
		form = CreateAssetReportForm(instance=assetReport, initial={'status': assetReport.asset.status})
	context = {'page_title': 'Edit Asset Report', 'title': assetReport.asset.product_id, 'form': form, 'instance': assetReport.asset, 'returnPage': returnPage}
	return render(request, 'authoring/report_form.html', context)
Example #2
0
def editReport(request, product_id, asset_id, report_id):
    assetReport = get_object_or_404(AssetReport, pk=report_id)

    if request.GET.get('return'):
        returnPage = request.GET['return']
    else:
        returnPage = ''

    if request.method == 'POST':
        form = CreateAssetReportForm(request.POST, instance=assetReport)
        if form.is_valid():
            # create a new item
            assetReport = form.save(commit=False)
            contents = form.cleaned_data['contents'],
            work_order = form.cleaned_data['work_order'],
            #response_to = form.cleaned_data['response_to'],
            submitted = form.cleaned_data['submitted'],
            submitted_by = request.user
            assetReport.save()
            # Always redirect after a POST

            asset = get_object_or_404(Asset, pk=asset_id)
            if submitted:
                asset.status = AssetStatus.objects.get(status='Awaiting QA')
            else:
                asset.status = AssetStatus.objects.get(
                    status='QA Submission Required')
                #asset.status = AssetStatus.objects.get(status='In Progress')
            asset.save()

            if returnPage == 'testing':
                return HttpResponseRedirect(reverse('testing-submit'))
            else:
                return HttpResponseRedirect(
                    reverse('asset-detail',
                            kwargs={
                                'product_id': assetReport.asset.product.id,
                                'asset_id': assetReport.asset.id
                            }) + '#' + str(assetReport.id))
    else:
        form = CreateAssetReportForm(
            instance=assetReport, initial={'status': assetReport.asset.status})
    context = {
        'page_title': 'Edit Asset Report',
        'title': assetReport.asset.product_id,
        'form': form,
        'instance': assetReport.asset,
        'returnPage': returnPage
    }
    return render(request, 'authoring/report_form.html', context)
Example #3
0
def createReport(request, product_id, asset_id):
    asset = get_object_or_404(Asset, pk=asset_id)
    discNumber = ''
    reportStatus = ''

    if request.GET.get('type'):
        reportType = request.GET['type']
    else:
        reportType = 'test'

    if reportType == 'test':
        reportStatus = AssetReportStatus.objects.get(status='QA Request')

        if request.method == 'POST':
            form = CreateAssetReportForm(request.POST)
            if form.is_valid():
                # create a new item
                try:
                    discNumber = AssetReport.objects.filter(
                        disc_number__isnull=False).latest(
                            'disc_number').disc_number + 1
                except AssetReport.DoesNotExist:
                    discNumber = 1

                assetReport = AssetReport.objects.create(
                    asset=asset,
                    status=reportStatus,
                    contents=form.cleaned_data['contents'],
                    work_order=form.cleaned_data['work_order'],
                    disc_number=discNumber,
                    #response_to = form.cleaned_data['response_to'],
                    submitted=form.cleaned_data['submitted'],
                    created_by=request.user,
                    submitted_by=request.user)
                submitted = form.cleaned_data['submitted']

                if submitted:
                    asset.status = AssetStatus.objects.get(
                        status='Awaiting QA')
                else:
                    asset.status = AssetStatus.objects.get(
                        status='QA Submission Pending')
                    #asset.status = AssetStatus.objects.get(status='In Progress')
                asset.save()
            # Always redirect after a POST
            return HttpResponseRedirect(
                reverse('asset-detail',
                        kwargs={
                            'product_id': asset.product.id,
                            'asset_id': asset.id
                        }) + '#' + str(assetReport.id))
        else:
            form = CreateAssetReportForm(
                initial={
                    'product': asset.product_id,
                    'asset_type': asset.asset_type,
                    'status': reportStatus
                })
            #form.initial['asset'] = asset.pk

    elif reportType == 'comment':
        reportStatus = AssetReportStatus.objects.get(status='Comment')

        if request.method == 'POST':
            form = CreateBareAssetReportForm(request.POST)
            if form.is_valid():
                # create a new item
                assetReport = AssetReport.objects.create(
                    asset=asset,
                    status=reportStatus,
                    contents=form.cleaned_data['contents'],
                    #work_order = form.cleaned_data['work_order'],
                    #disc_number = discNumber,
                    #response_to = form.cleaned_data['response_to'],
                    completed=True,
                    submitted=True,
                    created_by=request.user,
                    submitted_by=request.user)
                if asset.status == AssetStatus.objects.get(status='New'):
                    asset.status = AssetStatus.objects.get(
                        status='In Progress')
                    asset.save()
            # Always redirect after a POST
            #return HttpResponseRedirect(reverse('asset-detail', kwargs={'product_id': asset.product.id, 'asset_id': asset.id})+'#'+ str(assetReport.id))

            #send email
            email_list = send_comment(assetReport.id)
            title = 'Comment Posted'

            context = {
                'title': title,
                'email_list': email_list,
                'assetReport': assetReport
            }
            return render(request, 'authoring/comment_submit.html', context)
        else:
            form = CreateBareAssetReportForm(
                initial={
                    'product': asset.product_id,
                    'asset_type': asset.asset_type,
                    'status': reportStatus
                })
            #form.initial['asset'] = asset.pk

    context = {'page_title': 'Report', 'form': form, 'instance': asset}
    return render(request, 'authoring/report_form.html', context)
Example #4
0
def createReport(request, product_id, asset_id):
	asset = get_object_or_404(Asset, pk=asset_id)
	discNumber = ''
	reportStatus = ''

	if request.GET.get('type'):
		reportType = request.GET['type']
	else:
		reportType = 'test'	

	if reportType == 'test':
		reportStatus = AssetReportStatus.objects.get(status='QA Request')

		if request.method == 'POST':
			form = CreateAssetReportForm(request.POST)
			if form.is_valid():
				# create a new item
				try: 
					discNumber = AssetReport.objects.filter(disc_number__isnull=False).latest('disc_number').disc_number + 1					
				except AssetReport.DoesNotExist:
					discNumber = 1

				assetReport = AssetReport.objects.create(
					asset = asset,
					status = reportStatus,				
					contents = form.cleaned_data['contents'],
					work_order = form.cleaned_data['work_order'],
					disc_number = discNumber,
					#response_to = form.cleaned_data['response_to'],
					submitted = form.cleaned_data['submitted'],
					created_by = request.user,
					submitted_by = request.user
				)
				submitted = form.cleaned_data['submitted']

				if submitted:
					asset.status = AssetStatus.objects.get(status='Awaiting QA')
				else:
					asset.status = AssetStatus.objects.get(status='QA Submission Pending')			
					#asset.status = AssetStatus.objects.get(status='In Progress')
				asset.save()
			# Always redirect after a POST
			return HttpResponseRedirect(reverse('asset-detail', kwargs={'product_id': asset.product.id, 'asset_id': asset.id})+'#'+ str(assetReport.id ))
		else:        
			form = CreateAssetReportForm(initial={'product': asset.product_id, 'asset_type': asset.asset_type, 'status': reportStatus})
			#form.initial['asset'] = asset.pk

	elif reportType == 'comment':
		reportStatus = AssetReportStatus.objects.get(status='Comment')

		if request.method == 'POST':
			form = CreateBareAssetReportForm(request.POST)
			if form.is_valid():
				# create a new item
				assetReport = AssetReport.objects.create(
					asset = asset,
					status = reportStatus,				
					contents = form.cleaned_data['contents'],
					#work_order = form.cleaned_data['work_order'],
					#disc_number = discNumber,
					#response_to = form.cleaned_data['response_to'],
					completed = True,
					submitted = True,
					created_by = request.user,
					submitted_by = request.user
				)
				if asset.status == AssetStatus.objects.get(status='New'):
					asset.status = AssetStatus.objects.get(status='In Progress')
					asset.save()
			# Always redirect after a POST
			#return HttpResponseRedirect(reverse('asset-detail', kwargs={'product_id': asset.product.id, 'asset_id': asset.id})+'#'+ str(assetReport.id))

			#send email
			email_list = send_comment(assetReport.id)
			title = 'Comment Posted'

			context = {'title': title, 'email_list': email_list, 'assetReport': assetReport }
			return render(request, 'authoring/comment_submit.html', context)
		else:        
			form = CreateBareAssetReportForm(initial={'product': asset.product_id, 'asset_type': asset.asset_type, 'status': reportStatus})
			#form.initial['asset'] = asset.pk
	

	context = {'page_title': 'Report', 'form': form, 'instance': asset}
	return render(request, 'authoring/report_form.html', context)