Esempio n. 1
0
def view_rating(request, paper_id):
    if not __is_session_open(request):
        return HttpResponseRedirect("/")

    user = User.objects.get(email=request.session["user_email"])
    curent_reviews = Review.objects.all().filter(paper=paper_id)
    pcc_form = PCC_Rate(request.POST or None)

    context = {"pcc_rate_form": pcc_form, "rate_paper_page": True, "review": curent_reviews}

    if pcc_form.is_valid():

        current_submission = Submission.objects.all().get(paper=paper_id)
        current_submission.rating = pcc_form.cleaned_data["rating"]

        current_submission.save()

        try:
            nm = NotificationManager.create()
            nm.send_notification(
                recipients=[current_submission.submitter],
                message='Your submission for the paper "{0}", has been given the rating: {1}'.format(
                    current_submission.paper.title, current_submission.rating
                ),
            )
        except:
            print("There was a problem sending the notification for a rated paper")

        return HttpResponseRedirect("/user_profile")

    context.update(__add_general_content_to_context(user))

    return render(request, "pcc_view_reviews.html", context)
Esempio n. 2
0
def view_report(request, paper_id):
    if not __is_session_open(request):
        return HttpResponseRedirect('/')

    user = User.objects.get(email=request.session['user_email'])
    curent_reviews = Review.objects.all().filter(paper = paper_id)
    pcc_form = PCC_Rate(request.POST or None)

    print(paper_id)

    context = {
        'pcc_rate_form': pcc_form,
        'review':curent_reviews,
        'generate_report_page': True,
    }

    if pcc_form.is_valid():
        # current_review = review.Review()

        current_submission = Submission.objects.all().get(paper = paper_id)
        current_submission.rating = pcc_form.cleaned_data['rating']

        current_submission.save()

        return HttpResponseRedirect('/user_profile')

    context.update(__add_general_content_to_context(user))

    return render(request, 'pcc_view_generate_report.html', context)