def view_comparisons_given_submission(): """This function displays comparisons wich contains given submission.""" props = db(db.user_properties.user == auth.user.email).select().first() subm = db.submission(request.args(0)) or redirect(URL('default', 'index')) c = db.venue(subm.venue_id) or redirect(URL('default', 'index')) if not access.can_observe(c, props): session.flash = T('Not authorized') redirect(URL('default', 'index')) # Create query. # First, determine the people who have reviewed this submission. reviewers_r = db(db.task.submission_id == subm.id).select( db.task.user).as_list() reviewers = [x['user'] for x in reviewers_r] # Second, displays all the comparisons by these users in this venue. q = ((db.comparison.venue_id == c.id) & (db.comparison.user.belongs(reviewers))) db.comparison.ordering.represent = represent_ordering grid = SQLFORM.grid( q, field_id=db.comparison.id, fields=[ db.comparison.user, db.comparison.submission_nicknames, db.comparison.ordering, db.comparison.grades, db.comparison.is_valid, db.comparison.date ], csv=True, args=request.args[:1], user_signature=False, details=False, create=False, editable=False, deletable=False, ) return dict(subm=subm, venue=c, grid=grid)
def view_tasks(): """This function enables the view of the reviewing tasks, as well as the comparisons that they led to.""" 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_observe(c, props): session.flash = T('Not authorized') redirect(URL('default', 'index')) q = (db.task.venue_id == c.id) db.task.user_id.readable = True db.task.submission_name.readable = True db.task.comments.readable = True db.task.rejection_comment.readable = True db.task.rejected.readable = True db.task.submission_name.represent = represent_task_name_view_feedback db.task.submission_name.label = T('Submission feedback') grid = SQLFORM.grid(q, field_id=db.task.id, csv=True, args=request.args[:1], user_signature=False, details=True, create=False, editable=False, deletable=False, fields=[db.task.user_id, db.task.submission_id, db.task.venue_id, db.task.submission_name, db.task.completed_date, db.task.comments, db.task.rejected, db.task.rejection_comment], links=[ dict(header=T('Comparison'), body = lambda r: A(T('View comparison'), _class='btn', _href=URL('ranking', 'view_comparison', args=[r.venue_id, r.user_id, r.submission_id]))), ] ) title = T('Tasks for venue ' + c.name) return dict(title=title, grid=grid)
def view_comparisons_given_submission(): """This function displays comparisons wich contains given submission.""" props = db(db.user_properties.email == auth.user.email).select().first() subm = db.submission(request.args(0)) or redirect(URL('default', 'index')) c = db.venue(subm.venue_id) or redirect(URL('default', 'index')) if not access.can_observe(c, props): session.flash = T('Not authorized') redirect(URL('default', 'index')) # Create query. q = ((db.comparison.venue_id == c.id) & (db.comparison.ordering.contains(subm.id))) db.comparison.ordering.represent = represent_ordering grid = SQLFORM.grid(q, field_id=db.comparison.id, fields=[db.comparison.author, db.comparison.date, db.comparison.ordering, db.comparison.grades, db.comparison.new_item, db.comparison.is_valid], csv=True, args=request.args[:1], user_signature=False, details=True, create=False, editable=False, deletable=False, ) title = T('Comparisons with submission ' + str(subm.id) + ' (by ' + subm.email + ') for ' + c.name) return dict(title=title, grid=grid)
def view_comparisons_given_submission(): """This function displays comparisons wich contains given submission.""" props = db(db.user_properties.user == auth.user.email).select().first() subm = db.submission(request.args(0)) or redirect(URL('default', 'index')) c = db.venue(subm.venue_id) or redirect(URL('default', 'index')) if not access.can_observe(c, props): session.flash = T('Not authorized') redirect(URL('default', 'index')) # Create query. # First, determine the people who have reviewed this submission. reviewers_r = db(db.task.submission_id == subm.id).select(db.task.user).as_list() reviewers = [x['user'] for x in reviewers_r] # Second, displays all the comparisons by these users in this venue. q = ((db.comparison.venue_id == c.id) & (db.comparison.user.belongs(reviewers))) db.comparison.ordering.represent = represent_ordering grid = SQLFORM.grid(q, field_id=db.comparison.id, fields=[db.comparison.user, db.comparison.submission_nicknames, db.comparison.ordering, db.comparison.grades, db.comparison.is_valid, db.comparison.date], csv=True, args=request.args[:1], user_signature=False, details=False, create=False, editable=False, deletable=False, ) return dict(subm=subm, venue=c, grid=grid)
def view_comparisons_given_user(): """This function displays comparisons for a user in a given venue. The arguments are user, venue_id.""" props = db(db.user_properties.user == get_user_email()).select().first() user = request.args(0) or redirect(URL('default', 'index')) venue_id = request.args(1) or redirect(URL('default', 'index')) c = db.venue(venue_id) or redirect(URL('default', 'index')) if not access.can_observe(c, props): session.flash = T('Not authorized') redirect(URL('default', 'index')) # Create query. q = ((db.comparison.venue_id == venue_id) & (db.comparison.user == user) & (db.comparison.is_valid == True)) db.comparison.ordering.represent = represent_ordering db.comparison.venue_id.readable = False db.comparison.user.represent = represent_user_by_submission_feedback fields=[db.comparison.user, db.comparison.venue_id, db.comparison.grades, db.comparison.submission_nicknames, db.comparison.date,] if is_user_admin(): fields=[db.comparison.user, db.comparison.venue_id, db.comparison.grades, db.comparison.submission_nicknames, db.comparison.is_valid, db.comparison.date,] q = ((db.comparison.venue_id == venue_id) & (db.comparison.user == user)) grid = SQLFORM.grid(q, field_id=db.comparison.id, fields=fields, csv=True, args=request.args[:2], user_signature=False, details=False, create=False, editable=False, deletable=False, maxtextlength=24, ) return dict(user=user, venue=c, grid=grid)
def edit_feedback(): """This function is used by TAs and instructors to give feedback on a submission.""" subm = db.submission(request.args(0)) c = db.venue(subm.venue_id) if subm is None or c is None: session.flash = T('No such submission.') redirect(URL('default', 'index')) props = db(db.user_properties.user == get_user_email()).select().first() if not access.can_observe(c, props): session.flash = T('Not authorized.') redirect(URL('default', 'index')) # Sets the correct permissions. 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 = False db.submission.n_completed_reviews.readable = False db.submission.n_rejected_reviews.readable = False if c.allow_link_submission: db.submission.link.readable = True # Produces the form. form = SQLFORM(db.submission, record=subm, upload=URL('download_manager', args=[subm.id]), deletable=False) old_feedback_key = subm.feedback form.vars.feedback = keystore_read(old_feedback_key) if form.process(onvalidation=update_feedback_to_keystore(old_feedback_key)).accepted: session.flash = T('The feedback has been updated.') redirect(URL('feedback', 'view_feedback', args=['s', subm.id])) return dict(form=form)
def view_comparisons_index(): """This function displays all comparisons for a venue.""" props = db(db.user_properties.user == get_user_email()).select().first() c = db.venue(request.args(0)) or redirect(URL('default', 'index')) if not access.can_observe(c, props): session.flash = T('Not authorized') redirect(URL('default', 'index')) q = ((db.comparison.venue_id == c.id) & (db.comparison.is_valid == True)) db.comparison.ordering.represent = represent_ordering db.comparison.user.represent = represent_user_by_submission_feedback db.comparison.venue_id.readable = False fields=[db.comparison.user, db.comparison.venue_id, db.comparison.grades, db.comparison.submission_nicknames, db.comparison.date,] if is_user_admin(): fields=[db.comparison.user, db.comparison.venue_id, db.comparison.grades, db.comparison.submission_nicknames, db.comparison.is_valid, db.comparison.date,] q = (db.comparison.venue_id == c.id) grid = SQLFORM.grid(q, field_id=db.comparison.id, fields=fields, csv=True, args=request.args[:1], user_signature=False, details=False, create=False, editable=False, deletable=False, maxtextlength=24, ) title = T('Comparisons for venue ' + c.name) return dict(title=title, grid=grid)
def review(): """Enters the review, and comparisons, for a particular task. This also allows to decline a review. This can be used both for old, and new, reviews. The function is accessed by task id.""" t = db.task(request.args(0)) or redirect(URL('default', 'index')) if t.user != get_user_email(): session.flash = T('Invalid request.') redirect(URL('default', 'index')) props = db(db.user_properties.user == get_user_email()).select().first() # Check that the venue rating deadline is currently open, or that the ranker # is a manager or observer. venue = db.venue(t.venue_id) if ((not access.can_observe(venue, props)) and (datetime.utcnow() < venue.rate_open_date or datetime.utcnow() > venue.rate_close_date)): session.flash = T('Reviewing for this venue is closed.') redirect(URL('venues', 'view_venue', args=[venue.id])) # Ok, the task belongs to the user. # Gets the valid comparison for the venue, so we can read the grades. last_comparison = db((db.comparison.user == get_user_email()) & (db.comparison.venue_id == t.venue_id) & (db.comparison.is_valid == True)).select().first() if last_comparison == None: last_ordering = [] subm_id_to_nickname = {} else: last_ordering = util.get_list(last_comparison.ordering) try: subm_id_to_nickname = simplejson.loads(last_comparison.submission_nicknames) except Exception, e: logger.warning("Failed to decode submission_nicknames: " + str(last_comparison.submission_nicknames)) subm_id_to_nickname = {}
def edit_feedback(): """This function is used by TAs and instructors to give feedback on a submission.""" subm = db.submission(request.args(0)) c = db.venue(subm.venue_id) if subm is None or c is None: session.flash = T('No such submission.') redirect(URL('default', 'index')) props = db(db.user_properties.user == get_user_email()).select().first() if not access.can_observe(c, props): session.flash = T('Not authorized.') redirect(URL('default', 'index')) # Sets the correct permissions. 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 = False db.submission.n_completed_reviews.readable = False db.submission.n_rejected_reviews.readable = False if c.allow_link_submission: db.submission.link.readable = True # Produces the form. form = SQLFORM(db.submission, record=subm, upload=URL('download_manager', args=[subm.id]), deletable=False) old_feedback_key = subm.feedback form.vars.feedback = keystore_read(old_feedback_key) if form.process(onvalidation=update_feedback_to_keystore( old_feedback_key)).accepted: session.flash = T('The feedback has been updated.') redirect(URL('feedback', 'view_feedback', args=['s', subm.id])) return dict(form=form)
def view_comparisons_index(): """This function displays all comparisons for a venue.""" props = db(db.user_properties.user == auth.user.email).select().first() c = db.venue(request.args(0)) or redirect(URL('default', 'index')) if not access.can_observe(c, props): session.flash = T('Not authorized') redirect(URL('default', 'index')) q = (db.comparison.venue_id == c.id) db.comparison.ordering.represent = represent_ordering grid = SQLFORM.grid( q, field_id=db.comparison.id, fields=[ db.comparison.user, db.comparison.ordering, db.comparison.grades, db.comparison.submission_nicknames, db.comparison.is_valid, db.comparison.date, ], csv=True, args=request.args[:1], user_signature=False, details=True, create=False, editable=False, deletable=False, ) title = T('Comparisons for venue ' + c.name) return dict(title=title, grid=grid)
def view_submission_by_manager(): """Allows viewing a submission by a contest manager. The argument is the submission id.""" 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 == auth.user.email).select().first() if not access.can_observe(c, props): session.flash = T('Not authorized.') redirect(URL('default', 'index')) download_link = None subm_link = None if c.allow_link_submission: subm_link = A(subm.link, _href=subm.link) db.submission.content.readable = False form = SQLFORM(db.submission, subm, readonly=True, upload=URL('download_manager', args=[subm.id]), buttons=[]) download_link = A(T('download'), _class='btn', _href=URL('download_author', args=[subm.id, subm.content])) return dict(form=form, subm=subm, download_link=download_link, subm_link=subm_link)
def view_comparison(): """This function displays an individual task.""" # We are given the task id. t = db.task(request.args(0)) or redirect(URL('default', 'index')) rating_user = t.user submission_id = t.submission_id # We need to get the most recent comparison by the user who has done this task. comp = db((db.comparison.venue_id == t.venue_id) & (db.comparison.user == t.user)).select(orderby=~db.comparison.date).first() c = db.venue(t.venue_id) or redirect(URL('default', 'index')) props = db(db.user_properties.user == auth.user.email).select().first() if not access.can_observe(c, props): session.flash = T('Not authorized') redirect(URL('default', 'index')) db.comparison.id.readable = False db.comparison.ordering.readable = False db.comparison.grades.represent = represent_grades db.comparison.date.readable = False db.task.user.readable = True db.task.user.label = T('Reviewer') db.task.venue_id.readable = True db.task.venue_id.represent = represent_venue_id db.comparison.venue_id.readable = (t is None) db.comparison.venue_id.represent = represent_venue_id db.comparison.user.readable = (comp is None) db.comparison.user.label = T('Reviewer') db.comparison.new_item.readable = False if comp is None: comp_form = T('No corresponding comparison found.') else: comp_form = SQLFORM(db.comparison, comp, readonly=True) task_form = SQLFORM(db.task, t, readonly=True) return dict(comp_form=comp_form, task_form=task_form, user=rating_user, subm_id=submission_id)
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)
def view_comparisons_given_user(): """This function displays comparisons for a user in a given venue. The arguments are user, venue_id.""" props = db(db.user_properties.user == get_user_email()).select().first() user = request.args(0) or redirect(URL('default', 'index')) venue_id = request.args(1) or redirect(URL('default', 'index')) c = db.venue(venue_id) or redirect(URL('default', 'index')) if not access.can_observe(c, props): session.flash = T('Not authorized') redirect(URL('default', 'index')) # Create query. q = ((db.comparison.venue_id == venue_id) & (db.comparison.user == user) & (db.comparison.is_valid == True)) db.comparison.ordering.represent = represent_ordering db.comparison.venue_id.readable = False db.comparison.user.represent = represent_user_by_submission_feedback fields = [ db.comparison.user, db.comparison.venue_id, db.comparison.grades, db.comparison.submission_nicknames, db.comparison.date, ] if is_user_admin(): fields = [ db.comparison.user, db.comparison.venue_id, db.comparison.grades, db.comparison.submission_nicknames, db.comparison.is_valid, db.comparison.date, ] q = ((db.comparison.venue_id == venue_id) & (db.comparison.user == user)) grid = SQLFORM.grid( q, field_id=db.comparison.id, fields=fields, csv=True, args=request.args[:2], user_signature=False, details=False, create=False, editable=False, deletable=False, maxtextlength=24, ) return dict(user=user, venue=c, grid=grid)
def view_comparison(): """This function displays an individual comparison, given parameters that can be known from a task.""" comp = db((db.comparison.venue_id == request.args(0)) & (db.comparison.author == request.args(1)) & (db.comparison.new_item == request.args(2))).select().first() props = db(db.user_properties.email == auth.user.email).select().first() c = db.venue(request.args(0)) or redirect(URL('default', 'index')) if not access.can_observe(c, props): session.flash = T('Not authorized') redirect(URL('default', 'index')) if comp is None: form = T('No corresponding comparison found.') else: form = SQLFORM(db.comparison, comp, readonly=True) return dict(form=form)
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)
def view_comparison(): """This function displays an individual task.""" # We are given the task id. t = db.task(request.args(0)) or redirect(URL('default', 'index')) rating_user = t.user submission_id = t.submission_id # We need to get the most recent comparison by the user who has done this task. comp = db((db.comparison.venue_id == t.venue_id) & (db.comparison.user == t.user)).select( orderby=~db.comparison.date).first() c = db.venue(t.venue_id) or redirect(URL('default', 'index')) props = db(db.user_properties.user == get_user_email()).select().first() subm = db.submission(submission_id) if not access.can_observe(c, props): session.flash = T('Not authorized') redirect(URL('default', 'index')) db.comparison.id.readable = False db.comparison.ordering.readable = False db.comparison.grades.represent = represent_grades db.comparison.date.readable = False db.comparison.is_valid.readable = False db.task.user.readable = True db.task.user.label = T('Reviewer') db.task.user.represent = lambda v, r: A( v, _href=URL('feedback', 'view_feedback', args=['u', c.id, v])) db.task.venue_id.readable = True db.task.venue_id.represent = represent_venue_id db.task.comments.readable = True db.task.is_completed.readable = True db.task.rejected.readable = True db.task.helpfulness.readable = True db.task.feedback.readable = True db.comparison.venue_id.readable = (t is None) db.comparison.venue_id.represent = represent_venue_id db.comparison.user.readable = (comp is None) db.comparison.user.label = T('Reviewer') if comp is None: comp_form = T('No corresponding comparison found.') else: comp_form = SQLFORM(db.comparison, record=comp, readonly=True) task_form = SQLFORM(db.task, record=t, readonly=True) return dict(comp_form=comp_form, task_form=task_form, user=rating_user, subm_id=submission_id, subm=subm)
def view_tasks(): """This function enables the view of the reviewing tasks, as well as the comparisons that they led to.""" 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_observe(c, props): session.flash = T('Not authorized') redirect(URL('default', 'index')) q = (db.task.venue_id == c.id) db.task.user.readable = True db.task.submission_name.readable = True db.task.comments.readable = False db.task.rejection_comment.readable = False db.task.rejected.readable = True db.task.submission_name.represent = represent_task_name_view_feedback db.task.submission_name.label = T('Submission details') db.task.is_bogus.readable = True db.task.is_bogus.label = T('Bogus') grid = SQLFORM.grid( q, field_id=db.task.id, csv=True, args=request.args[:1], user_signature=False, details=False, create=False, editable=False, deletable=False, fields=[ db.task.user, db.task.submission_id, db.task.venue_id, db.task.submission_name, db.task.completed_date, db.task.comments, db.task.rejected, db.task.rejection_comment, db.task.is_bogus ], links=[ dict(header=T('Review details'), body=lambda r: A( T('View feedback'), _class='btn', _href=URL('ranking', 'view_comparison', args=[r.id]))), ]) title = T('Tasks for venue ' + c.name) return dict(title=title, grid=grid)
def view_comparison(): """This function displays an individual task.""" # We are given the task id. t = db.task(request.args(0)) or redirect(URL('default', 'index')) rating_user = t.user submission_id = t.submission_id # We need to get the most recent comparison by the user who has done this task. comp = db((db.comparison.venue_id == t.venue_id) & (db.comparison.user == t.user)).select(orderby=~db.comparison.date).first() c = db.venue(t.venue_id) or redirect(URL('default', 'index')) props = db(db.user_properties.user == get_user_email()).select().first() subm = db.submission(submission_id) if not access.can_observe(c, props): session.flash = T('Not authorized') redirect(URL('default', 'index')) db.comparison.id.readable = False db.comparison.ordering.readable = False db.comparison.grades.represent = represent_grades db.comparison.date.readable = False db.comparison.is_valid.readable = False db.task.user.readable = True db.task.user.label = T('Reviewer') db.task.user.represent = lambda v, r: A(v, _href=URL('feedback', 'view_feedback', args=['u', c.id, v])) db.task.venue_id.readable = True db.task.venue_id.represent = represent_venue_id db.task.comments.readable = True db.task.is_completed.readable = True db.task.rejected.readable = True db.task.helpfulness.readable = True db.task.feedback.readable = True db.comparison.venue_id.readable = (t is None) db.comparison.venue_id.represent = represent_venue_id db.comparison.user.readable = (comp is None) db.comparison.user.label = T('Reviewer') if comp is None: comp_form = T('No corresponding comparison found.') else: comp_form = SQLFORM(db.comparison, record=comp, readonly=True) task_form = SQLFORM(db.task, record=t, readonly=True) return dict(comp_form=comp_form, task_form=task_form, user=rating_user, subm_id=submission_id, subm=subm)
def view_comparisons_index(): """This function displays all comparisons for a venue.""" props = db(db.user_properties.email == auth.user.email).select().first() c = db.venue(request.args(0)) or redirect(URL('default', 'index')) if not access.can_observe(c, props): session.flash = T('Not authorized') redirect(URL('default', 'index')) q = (db.comparison.venue_id == c.id) db.comparison.ordering.represent = represent_ordering grid = SQLFORM.grid(q, field_id=db.comparison.id, fields=[db.comparison.author, db.comparison.date, db.comparison.ordering, db.comparison.grades, db.comparison.new_item, db.comparison.is_valid], csv=True, args=request.args[:1], user_signature=False, details=True, create=False, editable=False, deletable=False, ) title = T('Comparisons for venue ' + c.name) return dict(title=title, grid=grid)
def view_comparison(): """This function displays an individual task.""" # We are given the task id. t = db.task(request.args(0)) or redirect(URL('default', 'index')) rating_user = t.user submission_id = t.submission_id # We need to get the most recent comparison by the user who has done this task. comp = db((db.comparison.venue_id == t.venue_id) & (db.comparison.user == t.user)).select( orderby=~db.comparison.date).first() c = db.venue(t.venue_id) or redirect(URL('default', 'index')) props = db(db.user_properties.user == auth.user.email).select().first() if not access.can_observe(c, props): session.flash = T('Not authorized') redirect(URL('default', 'index')) db.comparison.id.readable = False db.comparison.ordering.readable = False db.comparison.grades.represent = represent_grades db.comparison.date.readable = False db.task.user.readable = True db.task.user.label = T('Reviewer') db.task.venue_id.readable = True db.task.venue_id.represent = represent_venue_id db.comparison.venue_id.readable = (t is None) db.comparison.venue_id.represent = represent_venue_id db.comparison.user.readable = (comp is None) db.comparison.user.label = T('Reviewer') db.comparison.new_item.readable = False if comp is None: comp_form = T('No corresponding comparison found.') else: comp_form = SQLFORM(db.comparison, comp, readonly=True) task_form = SQLFORM(db.task, t, readonly=True) return dict(comp_form=comp_form, task_form=task_form, user=rating_user, subm_id=submission_id)
def view_feedback(): """Shows detailed feedback for a user in a venue. This controller accepts various types of arguments: * 's', submission_id * 'u', venue_id, username * 'v', venue_id (in which case, shows own submission to that venue) """ if len(request.args) == 0: redirect(URL('default', 'index')) if request.args(0) == 's': # submission_id n_args = 2 subm = db.submission(request.args(1)) or redirect(URL('default', 'index')) c = db.venue(subm.venue_id) or redirect(URL('default', 'index')) username = subm.user elif request.args(0) == 'v': # venue_id n_args = 2 c = db.venue(request.args(1)) or redirect(URL('default', 'index')) username = get_user_email() subm = db((db.submission.user == username) & (db.submission.venue_id == c.id)).select().first() else: # venue_id, username n_args = 3 c = db.venue(request.args(1)) or redirect(URL('default', 'index')) username = request.args(2) or redirect(URL('default', 'index')) subm = db((db.submission.user == username) & (db.submission.venue_id == c.id)).select().first() # Checks permissions. props = db(db.user_properties.user == get_user_email()).select().first() if props == None: session.flash = T('Not authorized.') redirect(URL('default', 'index')) is_author = (username == get_user_email()) can_view_feedback = access.can_view_feedback(c, props) or is_author if (not can_view_feedback): session.flash = T('Not authorized.') redirect(URL('default', 'index')) if not (access.can_view_feedback(c, props) or datetime.utcnow() > c.rate_close_date): session.flash = T('The ratings are not yet available.') redirect(URL('feedback', 'index', args=['all'])) # Produces the link to edit the feedback. edit_feedback_link = None if subm is not None and access.can_observe(c, props): edit_feedback_link = A(T('Edit feedback'), _class='btn', _href=URL('submission', 'edit_feedback', args=[subm.id])) # Produces the download link. download_link = None if subm is not None and c.allow_file_upload and subm.content is not None: if is_author: download_link = A(T('Download'), _class='btn', _href=URL('submission', 'download_author', args=[subm.id, subm.content])) else: download_link = A(T('Download'), _class='btn', _href=URL('submission', 'download_manager', args=[subm.id, subm.content])) venue_link = A(c.name, _href=URL('venues', 'view_venue', args=[c.id])) # Submission link. subm_link = None if subm is not None and c.allow_link_submission: subm_link = A(subm.link, _href=subm.link) # Submission content and feedback. subm_comment = None subm_feedback = None if subm is not None: raw_subm_comment = keystore_read(subm.comment) if raw_subm_comment is not None and len(raw_subm_comment) > 0: subm_comment = MARKMIN(keystore_read(subm.comment)) raw_feedback = keystore_read(subm.feedback) if raw_feedback is not None and len(raw_feedback) > 0: subm_feedback = MARKMIN(raw_feedback) # Display settings. db.submission.percentile.readable = True db.submission.comment.readable = True db.submission.feedback.readable = True if access.can_observe(c, props): db.submission.quality.readable = True db.submission.error.readable = True # Reads the grade information. submission_grade = submission_percentile = None review_grade = review_percentile = user_reputation = None final_grade = final_percentile = None assigned_grade = None if c.grades_released: grade_info = db((db.grades.user == username) & (db.grades.venue_id == c.id)).select().first() if grade_info is not None: submission_grade = represent_quality(grade_info.submission_grade, None) submission_percentile = represent_percentage(grade_info.submission_percentile, None) review_grade = represent_quality_10(grade_info.accuracy, None) review_percentile = represent_percentage(grade_info.accuracy_percentile, None) user_reputation = represent_01_as_percentage(grade_info.reputation, None) final_grade = represent_quality(grade_info.grade, None) final_percentile = represent_percentage(grade_info.percentile, None) assigned_grade = represent_quality(grade_info.assigned_grade, None) # Makes a grid of comments. db.task.submission_name.readable = False db.task.assigned_date.readable = False db.task.completed_date.readable = False db.task.rejected.readable = True db.task.helpfulness.readable = db.task.helpfulness.writable = True # Prevent editing the comments; the only thing editable should be the "is bogus" field. db.task.comments.writable = False db.task.comments.readable = True ranking_link = None if access.can_observe(c, props): db.task.user.readable = True db.task.completed_date.readable = True links = [ dict(header=T('Review details'), body= lambda r: A(T('View'), _class='btn', _href=URL('ranking', 'view_comparison', args=[r.id]))), ] details = False if subm is not None: ranking_link = A(T('details'), _href=URL('ranking', 'view_comparisons_given_submission', args=[subm.id])) reviews_link = A(T('details'), _href=URL('ranking', 'view_comparisons_given_user', args=[username, c.id])) db.task.user.represent = lambda v, r: A(v, _href=URL('ranking', 'view_comparisons_given_user', args=[v, c.id], user_signature=True)) else: user_reputation = None links = [ dict(header=T('Review feedback'), body = lambda r: A(T('Give feedback'), _class='btn', _href=URL('feedback', 'reply_to_review', args=[r.id], user_signature=True))), ] details = False ranking_link = None reviews_link = None if subm is not None: q = ((db.task.submission_id == subm.id) & (db.task.is_completed == True)) # q = (db.task.submission_id == subm.id) else: q = (db.task.id == -1) grid = SQLFORM.grid(q, fields=[db.task.id, db.task.user, db.task.rejected, db.task.comments, db.task.helpfulness, ], details = details, csv=False, create=False, editable=False, deletable=False, searchable=False, links=links, args=request.args[:n_args], maxtextlength=24, ) return dict(subm=subm, download_link=download_link, subm_link=subm_link, username=username, subm_comment=subm_comment, subm_feedback=subm_feedback, edit_feedback_link=edit_feedback_link, is_admin=is_user_admin(), submission_grade=submission_grade, submission_percentile=submission_percentile, review_grade=review_grade, review_percentile=review_percentile, user_reputation=user_reputation, final_grade=final_grade, final_percentile=final_percentile, assigned_grade=assigned_grade, venue_link=venue_link, grid=grid, ranking_link=ranking_link, reviews_link=reviews_link)
def view_feedback(): """Shows detailed information and feedback for a given submission.""" subm = db.submission(request.args(0)) or redirect(URL('default', 'index')) # Checks whether the user is a manager for the venue. c = db.venue(subm.venue_id) or redirect(URL('default', 'index')) props = db(db.user_properties.user == auth.user.email).select().first() if props == None: session.flash = T('Not authorized.') redirect(URL('default', 'index')) is_author = (subm.user == auth.user.email) can_view_feedback = access.can_view_feedback(c, props) or is_author if (not can_view_feedback): session.flash = T('Not authorized.') redirect(URL('default', 'index')) if can_view_feedback and ( not ((datetime.utcnow() > c.rate_close_date) or c.feedback_accessible_immediately)): session.flash = T('The ratings are not yet available.') redirect(URL('feedback', 'index', args=['all'])) if is_author: download_link = A(T('Download'), _class='btn', _href=URL('submission', 'download_author', args=[subm.id, subm.content])) else: download_link = A(T('Download'), _class='btn', _href=URL('submission', 'download_manager', args=[subm.id, subm.content])) venue_link = A(c.name, _href=URL('venues', 'view_venue', args=[c.id])) subm_link = None if c.allow_link_submission: subm_link = A(subm.link, _href=subm.link) db.submission.identifier.readable = True db.submission.percentile.readable = True db.submission.comment.readable = True db.submission.feedback.readable = True if access.can_observe(c, props): db.submission.quality.readable = True db.submission.error.readable = True # Reads the grade information. percentile = None if c.latest_rank_update_date is not None and c.latest_rank_update_date < datetime.utcnow(): percentile = represent_percentage(subm.percentile, None) final_grade = None if c.latest_final_grades_evaluation_date is not None and c.latest_final_grades_evaluation_date < datetime.utcnow(): fg = db((db.grades.user == subm.user) & (db.grades.venue_id == c.id)).select(db.grades.grade).first() if fg != None: final_grade = represent_percentage(fg.grade, None) review_accuracy = None if c.latest_reviewers_evaluation_date is not None and c.latest_reviewers_evaluation_date < datetime.utcnow(): ra = db((db.user_accuracy.user == subm.user) & (db.user_accuracy.venue_id == c.id)).select().first() if ra != None: review_accuracy = represent_percentage(ra.reputation * 100.0, None) # Makes a grid of comments. db.task.submission_name.readable = False db.task.assigned_date.readable = False db.task.completed_date.readable = False db.task.rejected.readable = True db.task.is_bogus.readable = db.task.is_bogus.writable = True db.task.why_bogus.readable = db.task.why_bogus.writable = True db.task.why_bogus.label = T('Reason why the review is bogus') # Prevent editing the comments; the only thing editable should be the "is bogus" field. db.task.comments.writable = False db.task.rejection_comment.writable = False if access.can_observe(c, props): db.task.user.readable = True db.task.completed_date.readable = True links = [ dict(header=T('Review'), body= lambda r: A(T('View'), _class='btn', _href=URL('ranking', 'view_comparison', args=[r.id]))), ] details = False ranking_link = A(T('details'), _href=URL('ranking', 'view_comparisons_given_submission', args=[subm.id])) else: links = [] details = True ranking_link = None q = (db.task.submission_id == subm.id) grid = SQLFORM.grid(q, details = details, csv=False, create=False, editable=True, deletable=False, searchable=False, links=links, user_signature=False, args=request.args[:1], ) return dict(subm=subm, download_link=download_link, subm_link=subm_link, percentile=percentile, final_grade=final_grade, review_accuracy=review_accuracy, venue_link=venue_link, grid=grid, ranking_link=ranking_link)
def view_feedback(): """Shows detailed feedback for a user in a venue. This controller accepts various types of arguments: * 's', submission_id * 'u', venue_id, username * 'v', venue_id """ if len(request.args) == 0: redirect(URL('default', 'index')) if request.args(0) == 's': # submission_id n_args = 2 subm = db.submission(request.args(1)) or redirect(URL('default', 'index')) c = db.venue(subm.venue_id) or redirect(URL('default', 'index')) username = subm.user elif request.args(0) == 'v': # venue_id n_args = 2 c = db.venue(request.args(1)) or redirect(URL('default', 'index')) username = auth.user.email subm = db((db.submission.user == username) & (db.submission.venue_id == c.id)).select().first() else: # venue_id, username n_args = 3 c = db.venue(request.args(1)) or redirect(URL('default', 'index')) username = request.args(2) or redirect(URL('default', 'index')) subm = db((db.submission.user == username) & (db.submission.venue_id == c.id)).select().first() # Checks permissions. props = db(db.user_properties.user == auth.user.email).select().first() if props == None: session.flash = T('Not authorized.') redirect(URL('default', 'index')) is_author = (username == auth.user.email) can_view_feedback = access.can_view_feedback(c, props) or is_author if (not can_view_feedback): session.flash = T('Not authorized.') redirect(URL('default', 'index')) if ((not access.can_view_feedback(c, props)) and not ((datetime.utcnow() > c.rate_close_date) or c.feedback_accessible_immediately)): session.flash = T('The ratings are not yet available.') redirect(URL('feedback', 'index', args=['all'])) download_link = None if subm is not None and c.allow_file_upload and subm.content is not None: if is_author: download_link = A(T('Download'), _class='btn', _href=URL('submission', 'download_author', args=[subm.id, subm.content])) else: download_link = A(T('Download'), _class='btn', _href=URL('submission', 'download_manager', args=[subm.id, subm.content])) venue_link = A(c.name, _href=URL('venues', 'view_venue', args=[c.id])) # Submission link. subm_link = None if subm is not None and c.allow_link_submission: subm_link = A(subm.link, _href=subm.link) # Display settings. db.submission.identifier.readable = True db.submission.percentile.readable = True db.submission.comment.readable = True db.submission.feedback.readable = True if access.can_observe(c, props): db.submission.quality.readable = True db.submission.error.readable = True # Reads the grade information. grade_info = db((db.grades.user == username) & (db.grades.venue_id == c.id)).select().first() if grade_info is not None: percentile = represent_percentage(grade_info.submission_percentile, None) final_grade = represent_percentage(grade_info.percentile, None) review_accuracy = represent_01_as_percentage(grade_info.accuracy, None) user_reputation = represent_01_as_percentage(grade_info.reputation, None) else: percentile = final_grade = review_accuracy = user_reputation = None # Makes a grid of comments. db.task.submission_name.readable = False db.task.assigned_date.readable = False db.task.completed_date.readable = False db.task.rejected.readable = True db.task.is_bogus.readable = db.task.is_bogus.writable = True db.task.why_bogus.readable = db.task.why_bogus.writable = True db.task.why_bogus.label = T('Reason why the review is incorrect') # Prevent editing the comments; the only thing editable should be the "is bogus" field. db.task.comments.writable = False db.task.comments.readable = True db.task.rejection_comment.readable = True db.task.rejection_comment.writable = False ranking_link = None if access.can_observe(c, props): db.task.user.readable = True db.task.completed_date.readable = True links = [ dict(header=T('Review'), body= lambda r: A(T('View'), _class='btn', _href=URL('ranking', 'view_comparison', args=[r.id]))), ] details = False if subm is not None: ranking_link = A(T('details'), _href=URL('ranking', 'view_comparisons_given_submission', args=[subm.id])) reviews_link = A(T('details'), _href=URL('ranking', 'view_comparisons_given_user', args=[username, c.id])) db.task.user.represent = lambda v, r: A(v, _href=URL('ranking', 'view_comparisons_given_user', args=[v, c.id])) else: user_reputation = None links = [] details = True ranking_link = None reviews_link = None if subm is not None: q = ((db.task.submission_id == subm.id) & (db.task.is_completed == True)) # q = (db.task.submission_id == subm.id) else: q = (db.task.id == -1) grid = SQLFORM.grid(q, fields=[db.task.id, db.task.user, db.task.rejected, db.task.is_bogus, db.task.comments], details = details, csv=False, create=False, editable=True, deletable=False, searchable=False, links=links, args=request.args[:n_args], ) return dict(subm=subm, download_link=download_link, subm_link=subm_link, username=username, is_admin=is_user_admin(), percentile=percentile, final_grade=final_grade, review_accuracy=review_accuracy, venue_link=venue_link, grid=grid, ranking_link=ranking_link, user_reputation=user_reputation, reviews_link=reviews_link)
def view_feedback(): """Shows detailed feedback for a user in a venue. This controller accepts various types of arguments: * 's', submission_id * 'u', venue_id, username * 'v', venue_id (in which case, shows own submission to that venue) """ if len(request.args) == 0: redirect(URL('default', 'index')) if request.args(0) == 's': # submission_id n_args = 2 subm = db.submission(request.args(1)) or redirect( URL('default', 'index')) c = db.venue(subm.venue_id) or redirect(URL('default', 'index')) username = subm.user elif request.args(0) == 'v': # venue_id n_args = 2 c = db.venue(request.args(1)) or redirect(URL('default', 'index')) username = get_user_email() subm = db((db.submission.user == username) & (db.submission.venue_id == c.id)).select().first() else: # venue_id, username n_args = 3 c = db.venue(request.args(1)) or redirect(URL('default', 'index')) username = request.args(2) or redirect(URL('default', 'index')) subm = db((db.submission.user == username) & (db.submission.venue_id == c.id)).select().first() # Checks permissions. props = db(db.user_properties.user == get_user_email()).select().first() if props == None: session.flash = T('Not authorized.') redirect(URL('default', 'index')) is_author = (username == get_user_email()) can_view_feedback = access.can_view_feedback(c, props) or is_author if (not can_view_feedback): session.flash = T('Not authorized.') redirect(URL('default', 'index')) if not (access.can_view_feedback(c, props) or datetime.utcnow() > c.rate_close_date): session.flash = T('The ratings are not yet available.') redirect(URL('feedback', 'index', args=['all'])) # Produces the link to edit the feedback. edit_feedback_link = None if subm is not None and access.can_observe(c, props): edit_feedback_link = A(T('Edit feedback'), _class='btn', _href=URL('submission', 'edit_feedback', args=[subm.id])) # Produces the download link. download_link = None if subm is not None and c.allow_file_upload and subm.content is not None: if is_author: download_link = A(T('Download'), _class='btn', _href=URL('submission', 'download_author', args=[subm.id, subm.content])) else: download_link = A(T('Download'), _class='btn', _href=URL('submission', 'download_manager', args=[subm.id, subm.content])) venue_link = A(c.name, _href=URL('venues', 'view_venue', args=[c.id])) # Submission link. subm_link = None if subm is not None and c.allow_link_submission: subm_link = A(subm.link, _href=subm.link) # Submission content and feedback. subm_comment = None subm_feedback = None if subm is not None: raw_subm_comment = keystore_read(subm.comment) if raw_subm_comment is not None and len(raw_subm_comment) > 0: subm_comment = MARKMIN(keystore_read(subm.comment)) raw_feedback = keystore_read(subm.feedback) if raw_feedback is not None and len(raw_feedback) > 0: subm_feedback = MARKMIN(raw_feedback) # Display settings. db.submission.percentile.readable = True db.submission.comment.readable = True db.submission.feedback.readable = True if access.can_observe(c, props): db.submission.quality.readable = True db.submission.error.readable = True # Reads the grade information. submission_grade = submission_percentile = None review_grade = review_percentile = user_reputation = None final_grade = final_percentile = None assigned_grade = None if c.grades_released: grade_info = db((db.grades.user == username) & (db.grades.venue_id == c.id)).select().first() if grade_info is not None: submission_grade = represent_quality(grade_info.submission_grade, None) submission_percentile = represent_percentage( grade_info.submission_percentile, None) review_grade = represent_quality_10(grade_info.accuracy, None) review_percentile = represent_percentage( grade_info.accuracy_percentile, None) user_reputation = represent_01_as_percentage( grade_info.reputation, None) final_grade = represent_quality(grade_info.grade, None) final_percentile = represent_percentage(grade_info.percentile, None) assigned_grade = represent_quality(grade_info.assigned_grade, None) # Makes a grid of comments. db.task.submission_name.readable = False db.task.assigned_date.readable = False db.task.completed_date.readable = False db.task.rejected.readable = True db.task.helpfulness.readable = db.task.helpfulness.writable = True # Prevent editing the comments; the only thing editable should be the "is bogus" field. db.task.comments.writable = False db.task.comments.readable = True ranking_link = None if access.can_observe(c, props): db.task.user.readable = True db.task.completed_date.readable = True links = [ dict(header=T('Review details'), body=lambda r: A( T('View'), _class='btn', _href=URL('ranking', 'view_comparison', args=[r.id]))), ] details = False if subm is not None: ranking_link = A(T('details'), _href=URL('ranking', 'view_comparisons_given_submission', args=[subm.id])) reviews_link = A(T('details'), _href=URL('ranking', 'view_comparisons_given_user', args=[username, c.id])) db.task.user.represent = lambda v, r: A( v, _href=URL('ranking', 'view_comparisons_given_user', args=[v, c.id], user_signature=True)) else: user_reputation = None links = [ dict(header=T('Review feedback'), body=lambda r: A(T('Give feedback'), _class='btn', _href=URL('feedback', 'reply_to_review', args=[r.id], user_signature=True))), ] details = False ranking_link = None reviews_link = None if subm is not None: q = ((db.task.submission_id == subm.id) & (db.task.is_completed == True)) # q = (db.task.submission_id == subm.id) else: q = (db.task.id == -1) grid = SQLFORM.grid( q, fields=[ db.task.id, db.task.user, db.task.rejected, db.task.comments, db.task.helpfulness, ], details=details, csv=False, create=False, editable=False, deletable=False, searchable=False, links=links, args=request.args[:n_args], maxtextlength=24, ) return dict(subm=subm, download_link=download_link, subm_link=subm_link, username=username, subm_comment=subm_comment, subm_feedback=subm_feedback, edit_feedback_link=edit_feedback_link, is_admin=is_user_admin(), submission_grade=submission_grade, submission_percentile=submission_percentile, review_grade=review_grade, review_percentile=review_percentile, user_reputation=user_reputation, final_grade=final_grade, final_percentile=final_percentile, assigned_grade=assigned_grade, venue_link=venue_link, grid=grid, ranking_link=ranking_link, reviews_link=reviews_link)
def view_feedback(): """Shows detailed information and feedback for a given submission.""" subm = db.submission(request.args(0)) or redirect(URL('default', 'index')) # Checks whether the user is a manager for the venue. c = db.venue(subm.venue_id) or redirect(URL('default', 'index')) props = db(db.user_properties.email == auth.user.email).select().first() if props == None: session.flash = T('Not authorized.') redirect(URL('default', 'index')) is_author = (subm.author == auth.user_id) can_view_feedback = access.can_view_feedback(c, props) or is_author if (not can_view_feedback): session.flash = T('Not authorized.') redirect(URL('default', 'index')) if can_view_feedback and ( not ((datetime.utcnow() > c.rate_close_date) or c.feedback_accessible_immediately)): session.flash = T('The ratings are not yet available.') redirect(URL('feedback', 'index', args=['all'])) if is_author: download_link = A(T('Download'), _class='btn', _href=URL('submission', 'download_author', args=[subm.id, subm.content])) else: download_link = A(T('Download'), _class='btn', _href=URL('submission', 'download_manager', args=[subm.id, subm.content])) venue_link = A(c.name, _href=URL('venues', 'view_venue', args=[c.id])) subm_link = None if c.allow_link_submission: subm_link = A(subm.link, _href=subm.link) db.submission.identifier.readable = True db.submission.percentile.readable = True db.submission.comment.readable = True db.submission.feedback.readable = True if access.can_observe(c, props): db.submission.quality.readable = True db.submission.error.readable = True # Reads the grade information. percentile = None if c.latest_rank_update_date < datetime.utcnow(): percentile = represent_percentage(subm.percentile, None) final_grade = None if c.latest_final_grades_evaluation_date < datetime.utcnow(): fg = db((db.grades.author == subm.author) & (db.grades.venue_id == c.id)).select(db.grades.grade).first() if fg != None: final_grade = represent_percentage(fg.grade, None) review_accuracy = None if c.latest_reviewers_evaluation_date < datetime.utcnow(): ra = db((db.user_accuracy.user_id == subm.author) & (db.user_accuracy.venue_id == c.id)).select().first() if ra != None: review_accuracy = represent_percentage(ra.reputation * 100.0, None) # Makes a grid of comments. db.task.submission_name.readable = False db.task.assigned_date.readable = False db.task.completed_date.readable = False db.task.rejected.readable = True if access.can_observe(c, props): db.task.user_id.readable = True db.task.completed_date.readable = True q = (db.task.submission_id == subm.id) grid = SQLFORM.grid(q, details=True, csv=False, create=False, editable=False, deletable=False, searchable=False, user_signature=False, args=request.args[:1], ) return dict(subm=subm, download_link=download_link, subm_link=subm_link, percentile=percentile, final_grade=final_grade, review_accuracy=review_accuracy, venue_link=venue_link, grid=grid)
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)