示例#1
0
文件: views.py 项目: StuJ/rua
def editorial_review_complete(request, submission_id, access_key):

	review_assignment = get_object_or_404(core_models.EditorialReviewAssignment, Q(publishing_committee_access_key = access_key) |  Q(editorial_board_access_key = access_key))
	submission = get_object_or_404(core_models.Book, pk=submission_id)
	
	if access_key  == review_assignment.editorial_board_access_key:
		editorial_board = True
		result = review_assignment.editorial_board_results
		review_form = review_assignment.editorial_board_review_form
	elif access_key  == review_assignment.publishing_committee_access_key:
		editorial_board = False
		result = review_assignment.publication_committee_results
		review_form = review_assignment.publication_committee_review_form

	
	if not result and not editorial_board:
		return redirect(reverse('editorial_review', kwargs={'submission_id': submission.id,'access_key':review_assignment.publishing_committee_access_key}))
	elif not result and editorial_board:
		return redirect(reverse('editorial_review', kwargs={'submission_id': submission.id,'access_key':review_assignment.editorial_board_access_key}))
	
	elif review_assignment.completed and review_assignment.reopened:
		if editorial_board:
			return redirect(reverse('editorial_review_complete', kwargs={'submission_id': submission.id,'access_key':review_assignment.publishing_committee_access_key}))
		else: 
			return redirect(reverse('editorial_review_complete', kwargs={'submission_id': submission.id,'access_key':review_assignment.editorial_board_access_key}))
	
	relations = models.FormElementsRelationship.objects.filter(form=result.form)
	data_ordered = core_logic.order_data(core_logic.decode_json(result.data), relations)

	template = 'review/editorial_complete.html'
	context = {
		'submission': submission,
		'review_assignment': review_assignment,
		'form_info': review_form,
		'data_ordered': data_ordered,
		'result': result,
		'editorial_board':editorial_board,
		'additional_files': logic.has_additional_files(submission),
		'editors': logic.get_editors(review_assignment),
		'instructions': core_models.Setting.objects.get(group__name='general', name='instructions_for_task_review').value
	}

	return render(request,template, context)
示例#2
0
def view_non_editorial_review(request, review_id, non_editorial_review_id):
    """As an editorial reviewer, view a completed peer review for the
    submission under review.
    """

    review = get_object_or_404(
        models.EditorialReview,
        pk=review_id,
        completed__isnull=True,
    )

    if review.content_type.model == 'proposal':
        peer_review = get_object_or_404(
            submission_models.ProposalReview.objects,
            pk=non_editorial_review_id,
            completed__isnull=False)
        submission = peer_review.proposal
    else:
        peer_review = get_object_or_404(core_models.ReviewAssignment.objects,
                                        pk=non_editorial_review_id,
                                        completed__isnull=False)
        submission = peer_review.book

    result = peer_review.results
    relations = review_models.FormElementsRelationship.objects.filter(
        form=result.form, )
    data_ordered = core_logic.order_data(
        core_logic.decode_json(result.data),
        relations,
    )

    template = 'editorialreview/view_non_editorial_review.html'
    context = {
        'review': review,
        'peer_review': peer_review,
        'data_ordered': data_ordered,
        'relations': relations,
        'result': result,
        'submission': submission,
    }

    return render(request, template, context)
示例#3
0
def view_editorial_review(request, review_id):
    """As an editorial reviewer, view a completed editorial review."""

    review = get_object_or_404(models.EditorialReview, pk=review_id)
    result = review.results
    relations = review_models.FormElementsRelationship.objects.filter(
        form=result.form, )
    data_ordered = core_logic.order_data(
        core_logic.decode_json(result.data),
        relations,
    )

    template = 'editorialreview/view_editorial_review.html'
    context = {
        'review': review,
        'relations': relations,
        'data_ordered': data_ordered,
        'result': result,
    }

    return render(request, template, context)
示例#4
0
文件: views.py 项目: NateWr/rua
def view_proposal_review(request, submission_id, assignment_id):

	submission = get_object_or_404(submission_models.Proposal, pk=submission_id)
	review_assignment = get_object_or_404(submission_models.ProposalReview, pk=assignment_id)
	result = review_assignment.results
	if result:
		relations = review_models.FormElementsRelationship.objects.filter(form=result.form)
		data_ordered = logic.order_data(logic.decode_json(result.data), relations)
	else:
		relations = None
		data_ordered = None

	template = 'core/review/review_assignment.html'
	context = {
		'submission': submission,
		'review': review_assignment,
		'data_ordered': data_ordered,
		'result': result,
		'active': 'proposal_review',
	}

	return render(request, template, context)
示例#5
0
文件: views.py 项目: StuJ/rua
def review_complete_no_redirect(request, review_type, submission_id,review_round,access_key=None):
	user = request.user
	if access_key:
		review_assignment = get_object_or_404(core_models.ReviewAssignment, access_key=access_key, results__isnull=False, declined__isnull=True, review_type=review_type, review_round=review_round, withdrawn = False)
		submission = get_object_or_404(core_models.Book, pk=submission_id)
	elif review_type == 'proposal':
		submission = get_object_or_404(submission_models.Proposal, pk=submission_id)
		review_assignment = get_object_or_404(submission_models.ProposalReview, user=user, proposal=submission, results__isnull=False)
	else:
		submission = get_object_or_404(core_models.Book, pk=submission_id)
		review_assignment = get_object_or_404(core_models.ReviewAssignment, Q(user=user), Q(results__isnull=False), Q(review_round__round_number=review_round), Q(book=submission), Q(withdrawn = False), Q(review_type=review_type), Q(access_key__isnull=True) | Q(access_key__exact=''))

	
	result = review_assignment.results

	if not request.POST and request.GET.get('download') == 'docx':
		path = create_completed_review_form(submission, review_assignment.pk)
		return serve_file(request, path)
	
	relations = models.FormElementsRelationship.objects.filter(form=result.form)
	data_ordered = core_logic.order_data(core_logic.decode_json(result.data), relations)

	if not review_assignment.review_form:
		review_assignment.review_form = submission.review_form
		review_assignment.save()

	template = 'review/complete.html'
	context = {
		'submission': submission,
		'review_assignment': review_assignment,
		'form_info': review_assignment.review_form,
		'data_ordered': data_ordered,
		'result': result,
		'additional_files': logic.has_additional_files(submission),
		'editors': logic.get_editors(review_assignment),
		'instructions': core_models.Setting.objects.get(group__name='general', name='instructions_for_task_review').value
	}

	return render(request,template, context)
示例#6
0
文件: views.py 项目: NateWr/rua
def view_review_assignment(request, submission_id, round_id, review_id):

	submission = get_object_or_404(models.Book, pk=submission_id, owner=request.user)
	review_assignment = get_object_or_404(models.ReviewAssignment, pk=review_id)
	review_rounds = models.ReviewRound.objects.filter(book=submission).order_by('-round_number')
	result = review_assignment.results
	relations = review_models.FormElementsRelationship.objects.filter(form=result.form)
	data_ordered = order_data(decode_json(result.data), relations)

	template = 'author/submission.html'
	context = {
		'author_include': 'author/review_revision.html',
		'submission_files': 'shared/view_review.html',
		'submission': submission,
		'review': review_assignment,
		'data_ordered': data_ordered,
		'result': result,
		'review_rounds': review_rounds,
		'revision_requests': revision_models.Revision.objects.filter(book=submission, revision_type='review'),
	}

	return render(request, template, context)
示例#7
0
文件: views.py 项目: StuJ/rua
def view_review_assignment(request, submission_id, round_id, review_id):

	submission = get_object_or_404(models.Book, pk=submission_id, owner=request.user)
	review_assignment = get_object_or_404(models.ReviewAssignment, pk=review_id)
	review_rounds = models.ReviewRound.objects.filter(book=submission).order_by('-round_number')
	
	if review_assignment.hide:
		return redirect(reverse('view_review_round', kwargs={'submission_id': submission_id, 'round_id': round_id}))

	result = review_assignment.results
	if result:
		relations = review_models.FormElementsRelationship.objects.filter(form=result.form)
	else:
		if review_assignment.review_form:
			relations = review_models.FormElementsRelationship.objects.filter(form=review_assignment.review_form)
		else:
			review_assignment.review_form = submission.review_form
			review_assignment.save()
			relations = review_models.FormElementsRelationship.objects.filter(form=submission.review_form)
	if result:
		data_ordered = order_data(decode_json(result.data), relations)
	else:
		data_ordered = None

	template = 'author/submission_review.html'
	context = {
		'author_include': 'shared/view_review.html',
		'submission': submission,
		'review': review_assignment,
		'round_id': round_id,
		'submission_id': submission_id,
		'review_assignment_page': True,
		'data_ordered': data_ordered,
		'result': result,
		'review_rounds': review_rounds,
		'revision_requests': revision_models.Revision.objects.filter(book=submission, revision_type='review'),
	}

	return render(request, template, context)
示例#8
0
文件: views.py 项目: NateWr/rua
def review_complete(request, review_type, submission_id,review_round,access_key=None):

	if access_key:
		review_assignment = get_object_or_404(core_models.ReviewAssignment, access_key=access_key, declined__isnull=True, review_type=review_type)
		submission = get_object_or_404(core_models.Book, pk=submission_id)
	elif review_type == 'proposal':
		submission = get_object_or_404(submission_models.Proposal, pk=submission_id)
		review_assignment = get_object_or_404(submission_models.ProposalReview, user=request.user, proposal=submission)
	else:
		submission = get_object_or_404(core_models.Book, pk=submission_id)
	 	review_assignment = get_object_or_404(core_models.ReviewAssignment, user=request.user, book=submission, review_type=review_type, access_key="")

	
	result = review_assignment.results
	if not result or not review_assignment.completed:
		if not result:
			review_assignment.completed=None
			review_assignment.save()
		if access_key:
			return redirect(reverse('review_with_access_key', kwargs={'review_type': review_type, 'submission_id': submission.id,'access_key':access_key,'review_round':review_round}))
		else: 
			return redirect(reverse('review_without_access_key', kwargs={'review_type': review_type, 'submission_id': submission.id,'review_round':review_round}))

	relations = models.FormElementsRelationship.objects.filter(form=result.form)
	data_ordered = core_logic.order_data(core_logic.decode_json(result.data), relations)

	template = 'review/complete.html'
	context = {
		'submission': submission,
		'review_assignment': review_assignment,
		'form_info': submission.review_form,
		'data_ordered': data_ordered,
		'result': result,
		'additional_files': logic.has_additional_files(submission),
		'editors': logic.get_editors(review_assignment)
	}

	return render(request,template, context)
示例#9
0
文件: views.py 项目: StuJ/rua
def editorial_review(request, submission_id, access_key):

	ci_required = core_models.Setting.objects.get(group__name='general', name='ci_required')
	print uuid4()
	# Check that this review is being access by the user, is not completed and has not been declined.
	review_assignment = get_object_or_404(core_models.EditorialReviewAssignment, Q(publishing_committee_access_key = access_key) |  Q(editorial_board_access_key = access_key))
	submission = get_object_or_404(core_models.Book, pk=submission_id)
	
	if review_assignment.completed and not review_assignment.reopened:
		return redirect(reverse('editorial_review_complete', kwargs={'submission_id': submission.pk,'access_key':access_key}))
	editorial_board = False
	
	if access_key  == review_assignment.editorial_board_access_key:
		editorial_board = True
	elif access_key  == review_assignment.publishing_committee_access_key:
		editorial_board = False

	resubmit = True
	editors = logic.get_editors(review_assignment)
	form_info = None
	if editorial_board:
		editorial_result = None
		editorial_relations = None
		editorial_data_ordered = None

		form_info = review_assignment.editorial_board_review_form
		form = forms.GeneratedForm(form=review_assignment.editorial_board_review_form)
	else:
		editorial_result = review_assignment.editorial_board_results
		editorial_relations = models.FormElementsRelationship.objects.filter(form=editorial_result.form)
		editorial_data_ordered = core_logic.order_data(core_logic.decode_json(editorial_result.data), editorial_relations)

		if not review_assignment.publication_committee_review_form:
			form_info = review_assignment.editorial_board_review_form
			form = forms.GeneratedForm(form=review_assignment.editorial_board_review_form)
		else:
			form_info = review_assignment.publication_committee_review_form
			form = forms.GeneratedForm(form=review_assignment.publication_committee_review_form)
	
	if editorial_board:
		result = review_assignment.editorial_board_results
		if result and not review_assignment.editorial_board_passed:
			initial_data = {}
			data = json.loads(result.data)
			for k,v in data.items():
				initial_data[k] = v[0]
			form.initial = initial_data
		elif not result:
			resubmit = True
		elif result and review_assignment.editorial_board_passed:
			resubmit = False
	else:
		result = review_assignment.publication_committee_results
		if result and not review_assignment.publication_committee_passed:
			initial_data = {}
			data = json.loads(result.data)
			for k,v in data.items():
				initial_data[k] = v[0]
			form.initial = initial_data
		elif not result:
			resubmit = True
		elif result and review_assignment.publication_committee_passed:
			resubmit = False

	recommendation_form = core_forms.RecommendationForm(ci_required=ci_required.value)
	
	initial_data = {}
	if editorial_board and not review_assignment.editorial_board_passed:
		initial_data[u'recommendation']=review_assignment.editorial_board_recommendation
		initial_data[u'competing_interests']=review_assignment.editorial_board_competing_interests
	elif not editorial_board and not review_assignment.publication_committee_passed:
		initial_data[u'recommendation']=review_assignment.publication_committee_recommendation
		initial_data[u'competing_interests']=review_assignment.publication_committee_competing_interests

	recommendation_form.initial=initial_data
			
	if not request.POST and request.GET.get('download') == 'docx':
		if editorial_board:
			path = create_review_form(submission, review_assignment.editorial_board_review_form)
		else:
			path = create_review_form(submission, review_assignment.publication_committee_review_form)

		return serve_file(request, path)
	elif request.POST:
		if editorial_board:
			form = forms.GeneratedForm(request.POST, request.FILES, form=review_assignment.editorial_board_review_form)
		else:
			if not review_assignment.publication_committee_review_form:
				form = forms.GeneratedForm(request.POST, request.FILES, form=review_assignment.editorial_board_review_form)
			else:
				form = forms.GeneratedForm(request.POST, request.FILES, form=review_assignment.publication_committee_review_form)
		
		recommendation_form = core_forms.RecommendationForm(request.POST, ci_required=ci_required.value)
		if form.is_valid() and recommendation_form.is_valid():
			save_dict = {}
			if editorial_board:
				file_fields = models.FormElementsRelationship.objects.filter(form=review_assignment.editorial_board_review_form, element__field_type='upload')
				data_fields = models.FormElementsRelationship.objects.filter(~Q(element__field_type='upload'), form=review_assignment.editorial_board_review_form)
			else:
				if not review_assignment.publication_committee_review_form:
					file_fields = models.FormElementsRelationship.objects.filter(form=review_assignment.editorial_board_review_form, element__field_type='upload')
					data_fields = models.FormElementsRelationship.objects.filter(~Q(element__field_type='upload'), form=review_assignment.editorial_board_review_form)
				else:
					file_fields = models.FormElementsRelationship.objects.filter(form=review_assignment.publication_committee_review_form, element__field_type='upload')
					data_fields = models.FormElementsRelationship.objects.filter(~Q(element__field_type='upload'), form=review_assignment.publication_committee_review_form)

			for field in file_fields:
				if field.element.name in request.FILES:
					# TODO change value from string to list [value, value_type]
					save_dict[field.element.name] = [handle_editorial_review_file(request.FILES[field.element.name], submission, review_assignment, 'reviewer',editorial_board)]

			for field in data_fields:
				if field.element.name in request.POST:
					# TODO change value from string to list [value, value_type]
					save_dict[field.element.name] = [request.POST.get(field.element.name), 'text']

			json_data = smart_text(json.dumps(save_dict))
			if review_assignment.reopened:

				if editorial_board:
					review_assignment.editorial_board_results.data = json_data
					review_assignment.editorial_board_results.save()
					review_assignment.reopened=False
					review_assignment.save()
				else:
					review_assignment.publication_committee_results.data = json_data
					review_assignment.publication_committee_results.save()
					review_assignment.reopened=False
					review_assignment.save()

			else:
				if editorial_board:
					form_results = models.FormResult(form=review_assignment.editorial_board_review_form, data=json_data)
					form_results.save()
					review_assignment.editorial_board_results = form_results
					review_assignment.save()
				else:
					if not review_assignment.publication_committee_review_form:
						form_results = models.FormResult(form=review_assignment.editorial_board_review_form, data=json_data)
					else:
						form_results = models.FormResult(form=review_assignment.publication_committee_review_form, data=json_data)
					form_results.save()
					review_assignment.publication_committee_results = form_results
					review_assignment.save()


			if request.FILES.get('review_file_upload'):
				handle_editorial_review_file(request.FILES.get('review_file_upload'), submission, review_assignment, 'reviewer',editorial_board)
	
			if editorial_board:
				review_assignment.editorial_board_recommendation = request.POST.get('recommendation')
				review_assignment.editorial_board_competing_interests = request.POST.get('competing_interests')
			else:
				review_assignment.publication_committee_recommendation = request.POST.get('recommendation')
				review_assignment.publication_committee_competing_interests = request.POST.get('competing_interests')

			review_assignment.save()
			message = "Editorial review assignment #%s has been completed."  % (review_assignment.id)
			press_editors = User.objects.filter(profile__roles__slug='press-editor')
			for editor in press_editors:
				notification = core_models.Task(assignee=editor,creator=request.user,text=message,workflow='editorial-review', book = submission, editorial_review = review_assignment)
				notification.save()
				print "notify"
			messages.add_message(request, messages.INFO, 'Submitted successfully')
			if editorial_board:
				return redirect(reverse('editorial_review', kwargs={'submission_id': submission.id,'access_key':review_assignment.editorial_board_access_key}))
			else:
				return redirect(reverse('editorial_review', kwargs={'submission_id': submission.id,'access_key':review_assignment.publishing_committee_access_key}))


	template = 'review/editorial_review.html'
	context = {
		'review_assignment': review_assignment,
		'submission': submission,
		'form': form,
		'editorial_board': editorial_board,
		'form_info': form_info,
		'recommendation_form': recommendation_form,
		'editors':editors,
		'resubmit': resubmit,

		'editorial_data_ordered': editorial_data_ordered,
		'editorial_result': editorial_result,

		'has_additional_files': logic.has_additional_files(submission),
		'instructions': core_models.Setting.objects.get(group__name='general', name='instructions_for_task_review').value

	}

	return render(request, template, context)
示例#10
0
def view_review_assignment(request, submission_id, round_id, review_id):
    submission = get_object_or_404(
        models.Book,
        pk=submission_id,
        owner=request.user,
    )
    review_assignment = get_object_or_404(models.ReviewAssignment,
                                          pk=review_id)
    review_rounds = models.ReviewRound.objects.filter(
        book=submission).order_by('-round_number', )

    if review_assignment.hide:
        return redirect(
            reverse('view_review_round',
                    kwargs={
                        'submission_id': submission_id,
                        'round_id': round_id
                    }))

    result = review_assignment.results
    if result:
        relations = review_models.FormElementsRelationship.objects.filter(
            form=result.form, )
    else:
        if review_assignment.review_form:
            relations = review_models.FormElementsRelationship.objects.filter(
                form=review_assignment.review_form, )
        else:
            review_assignment.review_form = submission.review_form
            review_assignment.save()
            relations = review_models.FormElementsRelationship.objects.filter(
                form=submission.review_form, )
    if result:
        data_ordered = order_data(decode_json(result.data), relations)
    else:
        data_ordered = None

    template = 'author/submission_review.html'
    context = {
        'author_include':
        'shared/view_review.html',
        'submission':
        submission,
        'review':
        review_assignment,
        'round_id':
        round_id,
        'submission_id':
        submission_id,
        'review_assignment_page':
        True,
        'data_ordered':
        data_ordered,
        'result':
        result,
        'review_rounds':
        review_rounds,
        'revision_requests':
        revision_models.Revision.objects.filter(
            book=submission,
            revision_type='review',
        ),
    }

    return render(request, template, context)