Ejemplo n.º 1
0
def view_submissions():
    """This function enables the view of the ranking of items submitted to a
    venue.  It is assumed that the people accessing this can have full
    information about the venue, including the identity of the submitters."""
    c = db.venue(request.args(0)) or redirect(URL('default', 'index'))
    props = db(db.user_properties.user == get_user_email()).select().first()
    if not access.can_view_submissions(c, props):
        session.flash = T(
            'You do not have access to the submissions of this venue.')
        redirect(URL('venues', 'view_venue', args=[c.id]))
    # Prepares the query for the grid.
    q = (db.submission.venue_id == c.id)
    db.submission.quality.readable = False
    db.submission.error.readable = False
    db.submission.content.readable = False
    db.submission.content.writable = False
    db.submission.comment.writable = False
    db.submission.n_assigned_reviews.readable = True
    db.submission.n_assigned_reviews.label = T('Reviews Assigned')
    db.submission.n_completed_reviews.label = T('Done')
    db.submission.n_rejected_reviews.label = T('Declined')
    if c.allow_link_submission:
        db.submission.link.readable = True
    # Sets the fields.
    fields = [
        db.submission.user, db.submission.percentile,
        db.submission.n_assigned_reviews, db.submission.n_completed_reviews,
        db.submission.n_rejected_reviews
    ]
    # Sets the link to view/edit the feedback.
    links = []
    if access.can_view_feedback(c, props):
        links.append(
            dict(header=T('Feedback'),
                 body=lambda r:
                 A(T('View'),
                   _class='btn',
                   _href=URL('feedback', 'view_feedback', args=['s', r.id]))))
    grid = SQLFORM.grid(
        q,
        field_id=db.submission.id,
        csv=True,
        args=request.args[:1],
        user_signature=False,
        details=False,
        create=False,
        editable=False,
        deletable=False,
        fields=fields,
        links=links,
        links_placement='left',
        maxtextlength=24,
    )
    title = A(c.name, _href=URL('venues', 'view_venue', args=[c.id]))
    return dict(title=title, grid=grid)
Ejemplo n.º 2
0
def view_venue():
    """This function enables the view of the ranking of items submitted to a
    venue.  It is assumed that the people accessing this can have full
    information about the venue, including the identity of the submitters."""
    def represent_n_completed_reviews(v, r):
        if v is None:
            return None
        url = A(str(v), _href=URL('ranking',
            'view_comparisons_given_submission' ,args=[r.id]))
        return url
    c = db.venue(request.args(0)) or redirect(URL('default', 'index'))
    props = db(db.user_properties.user == auth.user.email).select().first()
    if not access.can_view_submissions(c, props):
	session.flash = T('You do not have access to the submissions of this venue.')
	redirect(URL('venues', 'view_venue', args=[c.id]))
    can_view_ratings = access.can_view_ratings(c, props)
    # Prepares the query for the grid.
    q = (db.submission.venue_id == c.id)
    db.submission.quality.readable = can_view_ratings
    db.submission.error.readable = can_view_ratings
    db.submission.content.readable = False
    db.submission.title.writable = False
    db.submission.content.writable = False
    db.submission.comment.writable = False
    db.submission.n_assigned_reviews.readable = True
    db.submission.n_assigned_reviews.label = T('Reviews Assigned')
    db.submission.n_completed_reviews.label = T('Completed')
    db.submission.n_rejected_reviews.label = T('Rejected')
    db.submission.n_completed_reviews.represent = represent_n_completed_reviews
    if c.allow_link_submission:
	db.submission.link.readable = True
    is_editable = False
    if access.can_view_feedback(c, props):
	db.submission.user.label = T('Submission')
	db.submission.user.represent = lambda v, r : A(v, 
			    _href=URL('feedback', 'view_feedback', args=['s', r.id]))
    fields=[db.submission.user, db.submission.percentile,
	    db.submission.n_assigned_reviews, db.submission.n_completed_reviews,
	    db.submission.n_rejected_reviews]
    if access.can_enter_true_quality:
	fields.append(db.submission.true_quality)
	is_editable = True
	db.submission.true_quality.readable = db.submission.true_quality.writable = True
    grid = SQLFORM.grid(q,
	field_id=db.submission.id,
	csv=True,
	args=request.args[:1],
	user_signature=False,
	details=False, create=False,
	editable=is_editable,
	deletable=False,
	fields=fields,
	)
    title = A(c.name, _href=URL('venues', 'view_venue', args=[c.id]))
    return dict(title=title, grid=grid)
Ejemplo n.º 3
0
def view_venue():
    """This function enables the view of the ranking of items submitted to a
    venue.  It is assumed that the people accessing this can have full
    information about the venue, including the identity of the submitters."""
    c = db.venue(request.args(0)) or redirect(URL('default', 'index'))
    props = db(db.user_properties.email == auth.user.email).select().first()
    if not access.can_view_submissions(c, props):
	session.flash = T('You do not have access to the submissions of this venue.')
	redirect(URL('venues', 'view_venue', args=[c.id]))
    can_view_ratings = access.can_view_ratings(c, props)
    # Prepares the query for the grid.
    q = (db.submission.venue_id == c.id)
    db.submission.quality.readable = can_view_ratings
    db.submission.error.readable = can_view_ratings
    db.submission.content.readable = False
    db.submission.title.writable = False
    db.submission.content.writable = False
    db.submission.comment.writable = False
    db.submission.n_assigned_reviews.readable = True
    db.submission.n_assigned_reviews.label = T('Reviews Assigned')
    db.submission.n_completed_reviews.label = T('Done')
    db.submission.n_rejected_reviews.label = T('Rejected')
    if c.allow_link_submission:
	db.submission.link.readable = True
    is_editable = False
    fields=[db.submission.title, db.submission.email, db.submission.quality,
	    db.submission.percentile, db.submission.n_assigned_reviews, db.submission.n_completed_reviews,
	    db.submission.n_rejected_reviews, db.submission.error, db.submission.content]
    if access.can_enter_true_quality:
	fields.append(db.submission.true_quality)
	is_editable = True
	db.submission.true_quality.readable = db.submission.true_quality.writable = True
    links = [
	# dict(header=T('N. reviews'), body = lambda r: get_num_reviews(r.id, c.id)),
	dict(header=T('Download'), body = lambda r:
	     A(T('Download'), _class='btn',
	       _href=URL('submission', 'download_viewer', args=[r.id, r.content])))]
    if access.can_view_feedback(c, props):
	links.append(dict(header=T('Feedback'), body = lambda r:
			  A(T('Read comments'), 
			    _href=URL('feedback', 'view_feedback', args=[r.id]))))
    grid = SQLFORM.grid(q,
	field_id=db.submission.id,
	csv=True,
	args=request.args[:1],
	user_signature=False,
	details=False, create=False,
	editable=is_editable,
	deletable=False,
	fields=fields,
	links=links,
	)
    title = A(c.name, _href=URL('venues', 'view_venue', args=[c.id]))
    return dict(title=title, grid=grid)
Ejemplo n.º 4
0
def view_venue():
    c = db.venue(request.args(0)) or redirect(URL("default", "index"))
    props = db(db.user_properties.user == auth.user.email).select().first()
    # if c.raters_equal_submitters:
    db.venue.rate_constraint.readable = False
    if props == None:
        can_submit = False
        can_rate = False
        has_submitted = False
        has_rated = False
        can_manage = False
        can_observe = False
        can_view_ratings = False
    else:
        can_submit = c.id in util.get_list(props.venues_can_submit)
        can_rate = c.id in util.get_list(props.venues_can_rate)
        has_submitted = c.id in util.get_list(props.venues_has_submitted)
        has_rated = c.id in util.get_list(props.venues_has_rated)
        can_manage = c.id in util.get_list(props.venues_can_manage)
        can_observe = c.id in util.get_list(props.venues_can_observe)
        # MAYDO(luca): Add option to allow only raters, or only submitters, to view
        # all ratings.
        can_view_ratings = access.can_view_ratings(c, props)
    if access.can_observe(c, props):
        db.venue.grading_instructions.readable = True
    venue_form = SQLFORM(db.venue, record=c, readonly=True)
    link_list = []
    if can_manage:
        link_list.append(
            A(T("Edit"), _href=URL("venues", "managed_index", args=["edit", "venue", c.id], user_signature=True))
        )
    if can_submit:
        link_list.append(A(T("Submit to this venue"), _href=URL("submission", "submit", args=[c.id])))
    if can_manage:
        link_list.append(A(T("Add submission"), _href=URL("submission", "manager_submit", args=[c.id])))
    if has_submitted:
        link_list.append(A(T("View my submissions"), _href=URL("feedback", "index", args=[c.id])))
    if can_view_ratings or access.can_view_submissions(c, props):
        link_list.append(A(T("View submissions"), _href=URL("ranking", "view_venue", args=[c.id])))
    if can_rate:
        link_list.append(
            A(T("Review a submission"), _href=URL("rating", "accept_review", args=[c.id], user_signature=True))
        )
    if can_observe or can_manage:
        # link_list.append(A(T('View reviewing tasks'), _href=URL('ranking', 'view_tasks', args=[c.id])))
        link_list.append(A(T("View comparisons"), _href=URL("ranking", "view_comparisons_index", args=[c.id])))
    if can_manage:
        link_list.append(A(T("Run reputation system"), _href=URL("rating", "run_rep_system", args=[c.id])))
    if can_view_ratings:
        link_list.append(A(T("View grades"), _href=URL("ranking", "view_final_grades", args=[c.id])))
    if auth.user.email in ["*****@*****.**", "*****@*****.**"]:
        link_list.append(A(T("Research view"), _href=URL("view_venue_research", args=[c.id])))
    return dict(form=venue_form, link_list=link_list, venue=c, has_rated=has_rated)
Ejemplo n.º 5
0
def download_viewer():
    """This method allows the download of a submission by someone who has access to
    all the submissions of the venue.  We need to do all access control here."""
    subm = db.submission(request.args(0)) or redirect(URL('default', 'index'))
    c = db.venue(subm.venue_id) or redirect(URL('default', 'index'))
    props = db(db.user_properties.user == get_user_email()).select().first()
    # Does the user have access to the venue submissions?
    if not access.can_view_submissions(c, props):
        session.flash(T('Not authorized.'))
        redirect(URL('default', 'index'))
    # Creates an appropriate file name for the submission.
    original_ext = util.get_original_extension(subm.original_filename)
    filename = c.name + '_' + subm.user
    filename += '.' + original_ext
    # Allows the download.
    return my_download(filename, subm_content=s.content)
Ejemplo n.º 6
0
def download_viewer():
    """This method allows the download of a submission by someone who has access to
    all the submissions of the venue.  We need to do all access control here."""
    subm = db.submission(request.args(0)) or redirect(URL('default', 'index'))
    c = db.venue(subm.venue_id) or redirect(URL('default', 'index'))
    props = db(db.user_properties.user == get_user_email()).select().first()
    # Does the user have access to the venue submissions?
    if not access.can_view_submissions(c, props): 
        session.flash(T('Not authorized.'))
        redirect(URL('default', 'index'))
    # Creates an appropriate file name for the submission.
    original_ext = util.get_original_extension(subm.original_filename)
    filename = c.name + '_' + subm.user
    filename += '.' + original_ext
    # Allows the download.
    return my_download(filename, subm_content=s.content)
Ejemplo n.º 7
0
def view_submissions():
    """This function enables the view of the ranking of items submitted to a
    venue.  It is assumed that the people accessing this can have full
    information about the venue, including the identity of the submitters."""
    c = db.venue(request.args(0)) or redirect(URL('default', 'index'))
    props = db(db.user_properties.user == get_user_email()).select().first()
    if not access.can_view_submissions(c, props):
        session.flash = T('You do not have access to the submissions of this venue.')
        redirect(URL('venues', 'view_venue', args=[c.id]))
    # Prepares the query for the grid.
    q = (db.submission.venue_id == c.id)
    db.submission.quality.readable = False
    db.submission.error.readable = False
    db.submission.content.readable = False
    db.submission.content.writable = False
    db.submission.comment.writable = False
    db.submission.n_assigned_reviews.readable = True
    db.submission.n_assigned_reviews.label = T('Reviews Assigned')
    db.submission.n_completed_reviews.label = T('Done')
    db.submission.n_rejected_reviews.label = T('Declined')
    if c.allow_link_submission:
        db.submission.link.readable = True
    # Sets the fields.
    fields=[db.submission.user, db.submission.percentile,
            db.submission.n_assigned_reviews, db.submission.n_completed_reviews,
            db.submission.n_rejected_reviews]
    # Sets the link to view/edit the feedback.
    links=[]
    if access.can_view_feedback(c, props):
        links.append(dict(header=T('Feedback'), 
                          body = lambda r: A(T('View'), _class='btn', 
                                             _href=URL('feedback', 'view_feedback', args=['s', r.id]))))
    grid = SQLFORM.grid(q,
        field_id=db.submission.id,
        csv=True,
        args=request.args[:1],
        user_signature=False,
        details=False, create=False,
        editable=False,
        deletable=False,
        fields=fields,
        links=links,
        links_placement='left',
        maxtextlength=24,
        )
    title = A(c.name, _href=URL('venues', 'view_venue', args=[c.id]))
    return dict(title=title, grid=grid)
Ejemplo n.º 8
0
def view_venue_research():
    c = db.venue(request.args(0)) or redirect(URL("default", "index"))
    props = db(db.user_properties.user == auth.user.email).select().first()
    if props == None:
        can_submit = False
        can_rate = False
        has_submitted = False
        has_rated = False
        can_manage = False
        can_observe = False
        can_view_ratings = False
    else:
        can_submit = c.id in util.get_list(props.venues_can_submit) or util.is_none(c.submit_constraint)
        can_rate = c.id in util.get_list(props.venues_can_rate) or util.is_none(c.rate_constraint)
        has_submitted = c.id in util.get_list(props.venues_has_submitted)
        has_rated = c.id in util.get_list(props.venues_has_rated)
        can_manage = c.id in util.get_list(props.venues_can_manage)
        can_observe = c.id in util.get_list(props.venues_can_observe)
        # MAYDO(luca): Add option to allow only raters, or only submitters, to view
        # all ratings.
        can_view_ratings = access.can_view_ratings(c, props)
    db.venue.ranking_algo_description.readable = True
    venue_form = SQLFORM(db.venue, record=c, readonly=True)
    link_list = []
    if can_submit:
        link_list.append(A(T("Submit to this venue"), _href=URL("submission", "submit", args=[c.id])))
    if can_rate:
        link_list.append(A(T("Review a submission"), _href=URL("rating", "accept_review", args=[c.id])))
    if has_submitted:
        link_list.append(A(T("View my submissions"), _href=URL("feedback", "index", args=[c.id])))
    if can_manage:
        link_list.append(A(T("Edit"), _href=URL("managed_index", vars=dict(cid=c.id))))
        link_list.append(A(T("Add submission"), _href=URL("submission", "manager_submit", args=[c.id])))
        link_list.append(A(T("Rep sys - small alpha"), _href=URL("rating", "run_rep_sys_research", args=[c.id, 3])))
        link_list.append(A(T("Rep sys - all compar"), _href=URL("rating", "run_rep_sys_research", args=[c.id, 2])))
        link_list.append(A(T("Ranking without rep sys"), _href=URL("rating", "run_rep_sys_research", args=[c.id, 1])))
    if can_observe or can_manage:
        link_list.append(A(T("View reviewing tasks"), _href=URL("ranking", "view_tasks", args=[c.id])))
        link_list.append(A(T("View comparisons"), _href=URL("ranking", "view_comparisons_index", args=[c.id])))
    if can_view_ratings or access.can_view_submissions(c, props):
        link_list.append(A(T("View submissions"), _href=URL("ranking", "view_venue", args=[c.id])))
    if access.can_view_rating_contributions(c, props):
        link_list.append(A(T("View reviewer contribution"), _href=URL("ranking", "view_raters", args=[c.id])))
    if can_view_ratings:
        link_list.append(A(T("View final grades"), _href=URL("ranking", "view_final_grades", args=[c.id])))
    return dict(form=venue_form, link_list=link_list, venue=c, has_rated=has_rated)
Ejemplo n.º 9
0
def view_venue():
    c = db.venue(request.args(0)) or redirect(URL('default', 'index'))
    props = db(db.user_properties.user == get_user_email()).select().first()
    # if c.raters_equal_submitters:
    db.venue.rate_constraint.readable = False
    if props == None and not is_user_admin(): 
        session.flash = T('Not Authorized.')
        redirect(URL('default', 'index'))
    # Checks view permission
    can_submit = access.can_submit(c, props)
    can_rate = access.can_rate(c, props)
    has_submitted = access.has_submitted(c, props)
    has_rated = access.has_rated(c, props)
    can_manage = access.can_manage(c, props)
    can_observe = access.can_observe(c, props)
    can_view_ratings = access.can_view_ratings(c, props)
    # Builds some links that are useful to give out to people.
    submission_link = URL('submission', 'submit', args=[c.id])
    review_link = URL('venues', 'reviewing_duties')
    if not (can_submit or can_rate or has_submitted or has_rated or can_manage or can_observe or can_view_ratings):
        session.flash = T('Not authorized.')
        redirect(URL('default', 'index'))
    if can_observe:
        db.venue.grading_instructions.readable = True
    venue_form = SQLFORM(db.venue, record=c, readonly=True)
    link_list = []
    if can_manage:
        link_list.append(A(T('Edit'), _href=URL('venues', 'edit', args=[c.id], user_signature=True)))
    if can_submit:
        link_list.append(A(T('Submit to this venue'), _href=URL('submission', 'submit', args=[c.id])))
    if can_manage:
        link_list.append(A(T('Add submission'), _href=URL('submission', 'manager_submit', args=[c.id])))
    if has_submitted:
        link_list.append(A(T('My submissions'), _href=URL('feedback', 'index', args=[c.id])))
    if can_view_ratings or access.can_view_submissions(c, props):
        link_list.append(A(T('Submissions'), _href=URL('ranking', 'view_submissions', args=[c.id])))
    if can_rate and not can_manage:
        link_list.append(A(T('Review'), _href=URL('rating', 'accept_review', args=[c.id], user_signature=True)))
    if can_observe or can_manage:
        link_list.append(A(T('Comparisons'), _href=URL('ranking', 'view_comparisons_index', args=[c.id])))
    if can_view_ratings:
        link_list.append(A(T('Crowd-grades'), _href=URL('ranking', 'view_grades', args=[c.id])))
    if is_user_admin():
        link_list.append(A(T('Experimental grades'), _href=URL('ranking', 'view_exp_grades', args=[c.id])))
    return dict(form=venue_form, link_list=link_list, venue=c, has_rated=has_rated,
                submission_link=submission_link, review_link=review_link)
Ejemplo n.º 10
0
def view_venue_research():
    c = db.venue(request.args(0)) or redirect(URL('default', 'index'))
    props = db(db.user_properties.user == auth.user.email).select().first()
    if props == None: 
        can_submit = False
        can_rate = False
        has_submitted = False
        has_rated = False
        can_manage = False
	can_observe = False
        can_view_ratings = False
    else:
        can_submit = c.id in util.get_list(props.venues_can_submit) or util.is_none(c.submit_constraint)
        can_rate = c.id in util.get_list(props.venues_can_rate) or util.is_none(c.rate_constraint)
        has_submitted = c.id in util.get_list(props.venues_has_submitted)
        has_rated = c.id in util.get_list(props.venues_has_rated)
        can_manage = c.id in util.get_list(props.venues_can_manage)
        can_observe = c.id in util.get_list(props.venues_can_observe)
	# MAYDO(luca): Add option to allow only raters, or only submitters, to view
	# all ratings.
	can_view_ratings = access.can_view_ratings(c, props)
    db.venue.ranking_algo_description.readable = True
    venue_form = SQLFORM(db.venue, record=c, readonly=True)
    link_list = []
    if can_submit:
        link_list.append(A(T('Submit to this venue'), _href=URL('submission', 'submit', args=[c.id])))
    if can_rate:
        link_list.append(A(T('Review a submission'), _href=URL('rating', 'accept_review', args=[c.id])))
    if has_submitted:
        link_list.append(A(T('View my submissions'), _href=URL('feedback', 'index', args=[c.id])))
    if can_manage:
        link_list.append(A(T('Edit'), _href=URL('managed_index', vars=dict(cid=c.id))))
	link_list.append(A(T('Add submission'), _href=URL('submission', 'manager_submit', args=[c.id])))
        link_list.append(A(T('Rep sys - small alpha'), _href=URL('rating', 'run_rep_sys_research', args=[c.id, 3])))
        link_list.append(A(T('Rep sys - all compar'), _href=URL('rating', 'run_rep_sys_research', args=[c.id, 2])))
        link_list.append(A(T('Ranking without rep sys'), _href=URL('rating', 'run_rep_sys_research', args=[c.id, 1])))
    if can_observe or can_manage:
	link_list.append(A(T('View reviewing tasks'), _href=URL('ranking', 'view_tasks', args=[c.id])))
	link_list.append(A(T('View comparisons'), _href=URL('ranking', 'view_comparisons_index', args=[c.id])))
    if can_view_ratings or access.can_view_submissions(c, props):
        link_list.append(A(T('View submissions'), _href=URL('ranking', 'view_venue', args=[c.id])))
    if access.can_view_rating_contributions(c, props):
        link_list.append(A(T('View reviewer contribution'), _href=URL('ranking', 'view_raters', args=[c.id])))
    if can_view_ratings:
        link_list.append(A(T('View final grades'), _href=URL('ranking', 'view_final_grades', args=[c.id])))
    return dict(form=venue_form, link_list=link_list, venue=c, has_rated=has_rated)
Ejemplo n.º 11
0
def view_venue():
    c = db.venue(request.args(0)) or redirect(URL('default', 'index'))
    props = db(db.user_properties.email == auth.user.email).select().first()
    if props == None: 
        can_submit = False
        can_rate = False
        has_submitted = False
        has_rated = False
        can_manage = False
	can_observe = False
        can_view_ratings = False
    else:
        can_submit = c.id in util.get_list(props.venues_can_submit) or util.is_none(c.submit_constraint)
        can_rate = c.id in util.get_list(props.venues_can_rate) or util.is_none(c.rate_constraint)
        has_submitted = c.id in util.get_list(props.venues_has_submitted)
        has_rated = c.id in util.get_list(props.venues_has_rated)
        can_manage = c.id in util.get_list(props.venues_can_manage)
        can_observe = c.id in util.get_list(props.venues_can_observe)
	# MAYDO(luca): Add option to allow only raters, or only submitters, to view
	# all ratings.
	can_view_ratings = access.can_view_ratings(c, props)
    venue_form = SQLFORM(db.venue, record=c, readonly=True)
    link_list = []
    if can_submit:
        link_list.append(A(T('Submit to this venue'), _href=URL('submission', 'submit', args=[c.id])))
    if can_rate:
        link_list.append(A(T('Review a submission'), _href=URL('rating', 'accept_review', args=[c.id])))
    if has_submitted:
        link_list.append(A(T('View my submissions'), _href=URL('submission', 'my_submissions_index', args=[c.id])))
    if can_manage:
        link_list.append(A(T('Edit'), _href=URL('managed_index', vars=dict(cid=c.id))))
	link_list.append(A(T('Add submission'), _href=URL('submission', 'manager_submit', args=[c.id])))
        link_list.append(A(T('Recompute submission ranking'), _href=URL('rating', 'recompute_ranks', args=[c.id])))
        link_list.append(A(T('Run reputation system'), _href=URL('rating', 'run_rep_system', args=[c.id])))
        link_list.append(A(T('Evaluate reviewers'), _href=URL('rating', 'evaluate_reviewers', args=[c.id])))
        link_list.append(A(T('Compute final grades'), _href=URL('rating', 'compute_final_grades', args=[c.id])))
    if can_observe or can_manage:
	link_list.append(A(T('View reviewing tasks'), _href=URL('ranking', 'view_tasks', args=[c.id])))
	link_list.append(A(T('View comparisons'), _href=URL('ranking', 'view_comparisons_index', args=[c.id])))
    if can_view_ratings or access.can_view_submissions(c, props):
        link_list.append(A(T('View submissions'), _href=URL('ranking', 'view_venue', args=[c.id])))
    if access.can_view_rating_contributions(c, props):
        link_list.append(A(T('View reviewer contribution'), _href=URL('ranking', 'view_raters', args=[c.id])))
    if can_view_ratings:
        link_list.append(A(T('View final grades'), _href=URL('ranking', 'view_final_grades', args=[c.id])))
    return dict(form=venue_form, link_list=link_list, venue=c, has_rated=has_rated)
Ejemplo n.º 12
0
def view_venue():
    """This function enables the view of the ranking of items submitted to a
    venue.  It is assumed that the people accessing this can have full
    information about the venue, including the identity of the submitters."""
    def represent_n_completed_reviews(v, r):
        if v is None:
            return None
        url = A(str(v),
                _href=URL('ranking',
                          'view_comparisons_given_submission',
                          args=[r.id]))
        return url

    c = db.venue(request.args(0)) or redirect(URL('default', 'index'))
    props = db(db.user_properties.user == auth.user.email).select().first()
    if not access.can_view_submissions(c, props):
        session.flash = T(
            'You do not have access to the submissions of this venue.')
        redirect(URL('venues', 'view_venue', args=[c.id]))
    can_view_ratings = access.can_view_ratings(c, props)
    # Prepares the query for the grid.
    q = (db.submission.venue_id == c.id)
    db.submission.quality.readable = can_view_ratings
    db.submission.error.readable = can_view_ratings
    db.submission.content.readable = False
    db.submission.title.writable = False
    db.submission.content.writable = False
    db.submission.comment.writable = False
    db.submission.n_assigned_reviews.readable = True
    db.submission.n_assigned_reviews.label = T('Reviews Assigned')
    db.submission.n_completed_reviews.label = T('Comparisons')
    db.submission.n_rejected_reviews.label = T('Rejected')
    db.submission.n_completed_reviews.represent = represent_n_completed_reviews
    if c.allow_link_submission:
        db.submission.link.readable = True
    is_editable = False
    fields = [
        db.submission.title, db.submission.user, db.submission.quality,
        db.submission.percentile, db.submission.n_assigned_reviews,
        db.submission.n_completed_reviews, db.submission.n_rejected_reviews,
        db.submission.error, db.submission.content
    ]
    if access.can_enter_true_quality:
        fields.append(db.submission.true_quality)
        is_editable = True
        db.submission.true_quality.readable = db.submission.true_quality.writable = True
    links = [
        # dict(header=T('N. reviews'), body = lambda r: get_num_reviews(r.id, c.id)),
        dict(header=T('Download'),
             body=lambda r: A(T('Download'),
                              _class='btn',
                              _href=URL('submission',
                                        'download_viewer',
                                        args=[r.id, r.content])))
    ]
    if access.can_view_feedback(c, props):
        links.append(
            dict(header=T('Feedback'),
                 body=lambda r: A(
                     T('Read comments'),
                     _href=URL('feedback', 'view_feedback', args=[r.id]))))
    grid = SQLFORM.grid(
        q,
        field_id=db.submission.id,
        csv=True,
        args=request.args[:1],
        user_signature=False,
        details=False,
        create=False,
        editable=is_editable,
        deletable=False,
        fields=fields,
        links=links,
    )
    title = A(c.name, _href=URL('venues', 'view_venue', args=[c.id]))
    return dict(title=title, grid=grid)
Ejemplo n.º 13
0
def view_venue():
    c = db.venue(request.args(0)) or redirect(URL('default', 'index'))
    props = db(db.user_properties.user == get_user_email()).select().first()
    # if c.raters_equal_submitters:
    db.venue.rate_constraint.readable = False
    if props == None and not is_user_admin():
        session.flash = T('Not Authorized.')
        redirect(URL('default', 'index'))
    # Checks view permission
    can_submit = access.can_submit(c, props)
    can_rate = access.can_rate(c, props)
    has_submitted = access.has_submitted(c, props)
    has_rated = access.has_rated(c, props)
    can_manage = access.can_manage(c, props)
    can_observe = access.can_observe(c, props)
    can_view_ratings = access.can_view_ratings(c, props)
    # Builds some links that are useful to give out to people.
    submission_link = URL('submission', 'submit', args=[c.id])
    review_link = URL('venues', 'reviewing_duties')
    if not (can_submit or can_rate or has_submitted or has_rated or can_manage
            or can_observe or can_view_ratings):
        session.flash = T('Not authorized.')
        redirect(URL('default', 'index'))
    if can_observe:
        db.venue.grading_instructions.readable = True
    venue_form = SQLFORM(db.venue, record=c, readonly=True)
    link_list = []
    if can_manage:
        link_list.append(
            A(T('Edit'),
              _href=URL('venues', 'edit', args=[c.id], user_signature=True)))
    if can_submit:
        link_list.append(
            A(T('Submit to this venue'),
              _href=URL('submission', 'submit', args=[c.id])))
    if can_manage:
        link_list.append(
            A(T('Add submission'),
              _href=URL('submission', 'manager_submit', args=[c.id])))
    if has_submitted:
        link_list.append(
            A(T('My submissions'), _href=URL('feedback', 'index',
                                             args=[c.id])))
    if can_view_ratings or access.can_view_submissions(c, props):
        link_list.append(
            A(T('Submissions'),
              _href=URL('ranking', 'view_submissions', args=[c.id])))
    if can_rate and not can_manage:
        link_list.append(
            A(T('Review'),
              _href=URL('rating',
                        'accept_review',
                        args=[c.id],
                        user_signature=True)))
    if can_observe or can_manage:
        link_list.append(
            A(T('Comparisons'),
              _href=URL('ranking', 'view_comparisons_index', args=[c.id])))
    if can_view_ratings:
        link_list.append(
            A(T('Crowd-grades'),
              _href=URL('ranking', 'view_grades', args=[c.id])))
    if is_user_admin():
        link_list.append(
            A(T('Experimental grades'),
              _href=URL('ranking', 'view_exp_grades', args=[c.id])))
    return dict(form=venue_form,
                link_list=link_list,
                venue=c,
                has_rated=has_rated,
                submission_link=submission_link,
                review_link=review_link)