def detail_proposal(request, conference_slug, slug): conference = get_object_or_404(Conference, slug=conference_slug) proposal = get_object_or_404(Proposal, slug=slug, conference=conference) read_private_comment = _is_proposal_author_or_proposal_reviewer( request.user, conference, proposal) write_private_comment = _is_proposal_author_or_proposal_section_reviewer( request.user, conference, proposal) is_reviewer = _is_proposal_reviewer(request.user, conference) is_section_reviewer = _is_proposal_section_reviewer( request.user, conference, proposal) vote_value = 0 voting = True if conference.start_date > datetime.now().date() else False try: if request.user.is_authenticated(): proposal_vote = ProposalVote.objects.get(proposal=proposal, voter=request.user) vote_value = 1 if proposal_vote.up_vote else -1 except ProposalVote.DoesNotExist: pass ctx = { 'login_url': settings.LOGIN_URL, 'proposal': proposal, 'read_private_comment': read_private_comment, 'write_private_comment': write_private_comment, 'vote_value': vote_value, 'is_author': request.user == proposal.author, 'is_reviewer': is_reviewer, 'is_section_reviewer': is_section_reviewer, 'can_view_feedback': False, 'can_vote': voting } if proposal.scheduleitem_set.all(): schedule_item = proposal.scheduleitem_set.all()[0] ctx['can_view_feedback'] = feedback_permission.can_view_feedback( user=request.user, schedule_item=schedule_item) ctx['schedule_item'] = schedule_item comments = ProposalComment.objects.filter(proposal=proposal, deleted=False, vote=False) if read_private_comment: ctx['reviewers_comments'] = comments.get_reviewers_comments() if write_private_comment: ctx['reviewers_proposal_comment_form'] = ProposalCommentForm( initial={'private': True}) if is_reviewer: ctx['reviewers_only_proposal_comment_form'] = ProposalCommentForm( initial={'reviewer': True}) ctx['reviewers_only_comments'] = comments.get_reviewers_only_comments() ctx.update({ 'comments': comments.get_public_comments(), 'proposal_comment_form': ProposalCommentForm() }) return render(request, 'proposals/detail/base.html', ctx)
def detail_proposal(request, conference_slug, slug): conference = get_object_or_404(Conference, slug=conference_slug) proposal = get_object_or_404(Proposal, slug=slug, conference=conference) read_private_comment = permissions.is_proposal_author_or_proposal_reviewer( request.user, conference, proposal) write_private_comment = permissions.is_proposal_author_or_proposal_section_reviewer( request.user, conference, proposal) is_reviewer = permissions.is_proposal_reviewer(request.user, conference) is_section_reviewer = permissions.is_proposal_section_reviewer( request.user, conference, proposal) vote_value = 0 voting = True if conference.start_date > datetime.now().date() else False try: if request.user.is_authenticated(): proposal_vote = ProposalVote.objects.get( proposal=proposal, voter=request.user) vote_value = 1 if proposal_vote.up_vote else -1 except ProposalVote.DoesNotExist: pass ctx = { 'login_url': settings.LOGIN_URL, 'proposal': proposal, 'read_private_comment': read_private_comment, 'write_private_comment': write_private_comment, 'vote_value': vote_value, 'is_author': request.user == proposal.author, 'is_reviewer': is_reviewer, 'is_section_reviewer': is_section_reviewer, 'can_view_feedback': False, 'can_vote': voting } if proposal.scheduleitem_set.all(): schedule_item = proposal.scheduleitem_set.all()[0] ctx['can_view_feedback'] = feedback_permission.can_view_feedback( user=request.user, schedule_item=schedule_item) ctx['schedule_item'] = schedule_item comments = ProposalComment.objects.filter( proposal=proposal, deleted=False, vote=False ) if read_private_comment: ctx['reviewers_comments'] = comments.get_reviewers_comments() if write_private_comment: ctx['reviewers_proposal_comment_form'] = ProposalCommentForm( initial={'private': True}) if is_reviewer: ctx['reviewers_only_proposal_comment_form'] = ProposalCommentForm( initial={'reviewer': True}) ctx['reviewers_only_comments'] = comments.get_reviewers_only_comments() ctx.update({'comments': comments.get_public_comments(), 'proposal_comment_form': ProposalCommentForm()}) return render(request, 'proposals/detail/base.html', ctx)
def detail_proposal(request, conference_slug, slug, hashid=None): """Display a proposal detail page. """ # Here try to get a proposal by it's hashid. If the slug didn't match because # the title might have changed, redirect to the correct slug. # hashid is optional due to backward compatibility. If the hashid is not present # we still try to get the proposal by old method i.e. using just the slug, but # redirect to the correct url containing hashid. hashids = Hashids(min_length=5) id = hashids.decode(hashid) if id: proposal = get_object_or_404(Proposal, id=id[0]) if slug != proposal.get_slug(): return HttpResponseRedirect(proposal.get_absolute_url()) else: conference = get_object_or_404(Conference, slug=conference_slug) proposal = get_object_or_404(Proposal, slug=slug, conference=conference) return HttpResponseRedirect(proposal.get_absolute_url()) # Here we have obtained the proposal that we want to display. conference = proposal.conference read_private_comment = permissions.is_proposal_author_or_proposal_reviewer( request.user, conference, proposal) write_private_comment = permissions.is_proposal_author_or_proposal_section_reviewer( request.user, conference, proposal) is_reviewer = permissions.is_proposal_reviewer(request.user, conference) is_section_reviewer = permissions.is_proposal_section_reviewer( request.user, conference, proposal) public_voting = ConferenceSettingConstants.ALLOW_PUBLIC_VOTING_ON_PROPOSALS public_voting_setting = conference.conferencesetting_set.filter( name=public_voting['name']).first() vote_value, public_voting_setting_value = 0, True if public_voting_setting: public_voting_setting_value = public_voting_setting.value try: if request.user.is_authenticated(): proposal_vote = ProposalVote.objects.get(proposal=proposal, voter=request.user) vote_value = 1 if proposal_vote.up_vote else -1 except ProposalVote.DoesNotExist: pass ctx = { 'login_url': settings.LOGIN_URL, 'proposal': proposal, 'read_private_comment': read_private_comment, 'write_private_comment': write_private_comment, 'vote_value': vote_value, 'is_author': request.user == proposal.author, 'is_reviewer': is_reviewer, 'is_section_reviewer': is_section_reviewer, 'can_view_feedback': False, 'can_vote': permissions.is_proposal_voting_allowed(proposal), 'public_voting_setting': public_voting_setting_value } if proposal.scheduleitem_set.all(): schedule_item = proposal.scheduleitem_set.all()[0] ctx['can_view_feedback'] = feedback_permission.can_view_feedback( user=request.user, schedule_item=schedule_item) ctx['schedule_item'] = schedule_item comments = ProposalComment.objects.filter(proposal=proposal, deleted=False, vote=False) if read_private_comment: ctx['reviewers_comments'] = comments.get_reviewers_comments() if write_private_comment: ctx['reviewers_proposal_comment_form'] = ProposalCommentForm( initial={'private': True}) if is_reviewer: ctx['reviewers_only_proposal_comment_form'] = ProposalCommentForm( initial={'reviewer': True}) ctx['reviewers_only_comments'] = comments.get_reviewers_only_comments() ctx.update({ 'comments': comments.get_public_comments(), 'proposal_comment_form': ProposalCommentForm() }) return render(request, 'proposals/detail/base.html', ctx)
def detail_proposal(request, conference_slug, slug, hashid=None): """Display a proposal detail page. """ # Here try to get a proposal by it's hashid. If the slug didn't match because # the title might have changed, redirect to the correct slug. # hashid is optional due to backward compatibility. If the hashid is not present # we still try to get the proposal by old method i.e. using just the slug, but # redirect to the correct url containing hashid. hashids = Hashids(min_length=5) id = hashids.decode(hashid) if id: proposal = get_object_or_404(Proposal, id=id[0]) if slug != proposal.get_slug(): return HttpResponseRedirect(proposal.get_absolute_url()) else: conference = get_object_or_404(Conference, slug=conference_slug) proposal = get_object_or_404(Proposal, slug=slug, conference=conference) return HttpResponseRedirect(proposal.get_absolute_url()) # Here we have obtained the proposal that we want to display. conference = proposal.conference read_private_comment = permissions.is_proposal_author_or_proposal_reviewer( request.user, conference, proposal) write_private_comment = permissions.is_proposal_author_or_proposal_section_reviewer( request.user, conference, proposal) is_reviewer = permissions.is_proposal_reviewer(request.user, conference) is_section_reviewer = permissions.is_proposal_section_reviewer( request.user, conference, proposal) public_voting = ConferenceSettingConstants.ALLOW_PUBLIC_VOTING_ON_PROPOSALS public_voting_setting = conference.conferencesetting_set.filter( name=public_voting['name']).first() vote_value, public_voting_setting_value = 0, True if public_voting_setting: public_voting_setting_value = public_voting_setting.value try: if request.user.is_authenticated(): proposal_vote = ProposalVote.objects.get(proposal=proposal, voter=request.user) vote_value = 1 if proposal_vote.up_vote else -1 except ProposalVote.DoesNotExist: pass ctx = { 'login_url': settings.LOGIN_URL, 'proposal': proposal, 'read_private_comment': read_private_comment, 'write_private_comment': write_private_comment, 'vote_value': vote_value, 'is_author': request.user == proposal.author, 'is_reviewer': is_reviewer, 'is_section_reviewer': is_section_reviewer, 'can_view_feedback': False, 'can_vote': permissions.is_proposal_voting_allowed(proposal), 'public_voting_setting': public_voting_setting_value } if proposal.scheduleitem_set.all(): schedule_item = proposal.scheduleitem_set.all()[0] ctx['can_view_feedback'] = feedback_permission.can_view_feedback(user=request.user, schedule_item=schedule_item) ctx['schedule_item'] = schedule_item comments = ProposalComment.objects.filter(proposal=proposal, deleted=False, vote=False) if read_private_comment: ctx['reviewers_comments'] = comments.get_reviewers_comments() if write_private_comment: ctx['reviewers_proposal_comment_form'] = ProposalCommentForm(initial={'private': True}) if is_reviewer: ctx['reviewers_only_proposal_comment_form'] = ProposalCommentForm(initial={'reviewer': True}) ctx['reviewers_only_comments'] = comments.get_reviewers_only_comments() ctx.update({'comments': comments.get_public_comments(), 'proposal_comment_form': ProposalCommentForm()}) return render(request, 'proposals/detail/base.html', ctx)
def detail_proposal(request, conference_slug, slug, hashid=None): """Display a proposal detail page. """ # Here try to get a proposal by it's hashid. If the slug didn't match because # the title might have changed, redirect to the correct slug. # hashid is optional due to backward compatibility. If the hashid is not present # we still try to get the proposal by old method i.e. using just the slug, but # redirect to the correct url containing hashid. hashids = Hashids(min_length=5) id = hashids.decode(hashid) if id: proposal = get_object_or_404(Proposal, id=id[0]) if slug != proposal.get_slug(): return HttpResponseRedirect(proposal.get_absolute_url()) else: conference = get_object_or_404(Conference, slug=conference_slug) proposal = get_object_or_404(Proposal, slug=slug, conference=conference) return HttpResponseRedirect(proposal.get_absolute_url()) if proposal.deleted: raise Http404("404") # Here we have obtained the proposal that we want to display. conference = proposal.conference read_private_comment = permissions.is_proposal_author_or_proposal_reviewer( request.user, conference, proposal ) write_private_comment = permissions.is_proposal_author_or_proposal_section_reviewer( request.user, conference, proposal ) is_reviewer = permissions.is_proposal_reviewer(request.user, conference) is_section_reviewer = permissions.is_proposal_section_reviewer( request.user, conference, proposal ) public_voting = ConferenceSettingConstants.ALLOW_PUBLIC_VOTING_ON_PROPOSALS public_voting_setting = conference.conferencesetting_set.filter( name=public_voting["name"] ).first() vote_value, public_voting_setting_value = 0, True if public_voting_setting: public_voting_setting_value = public_voting_setting.value try: if request.user.is_authenticated(): proposal_vote = ProposalVote.objects.get( proposal=proposal, voter=request.user ) vote_value = 1 if proposal_vote.up_vote else -1 except ProposalVote.DoesNotExist: pass ctx = { "login_url": settings.LOGIN_URL, "proposal": proposal, "read_private_comment": read_private_comment, "write_private_comment": write_private_comment, "vote_value": vote_value, "is_author": request.user == proposal.author, "is_reviewer": is_reviewer, "is_section_reviewer": is_section_reviewer, "can_view_feedback": False, "can_vote": permissions.is_proposal_voting_allowed(proposal), "public_voting_setting": public_voting_setting_value, } if proposal.scheduleitem_set.all(): schedule_item = proposal.scheduleitem_set.all()[0] ctx["can_view_feedback"] = feedback_permission.can_view_feedback( user=request.user, schedule_item=schedule_item ) ctx["schedule_item"] = schedule_item comments = ProposalComment.objects.filter( proposal=proposal, deleted=False, vote=False ) if read_private_comment: ctx["reviewers_comments"] = comments.get_reviewers_comments() if write_private_comment: ctx["reviewers_proposal_comment_form"] = ProposalCommentForm( initial={"private": True} ) if is_reviewer: ctx["reviewers_only_proposal_comment_form"] = ProposalCommentForm( initial={"reviewer": True} ) ctx["reviewers_only_comments"] = comments.get_reviewers_only_comments() ctx.update( { "comments": comments.get_public_comments(), "proposal_comment_form": ProposalCommentForm(), } ) ctx["enable_upload_content"] = settings.ENABLE_UPLOAD_CONTENT ctx["enable_second_phase_voting"] = settings.ENABLE_SECOND_PHASE_VOTING return render(request, "proposals/detail/base.html", ctx)