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_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'))
    can_view_feedback = access.can_view_feedback(c, props)
    if (not can_view_feedback) and subm.author != auth.user_id:
        session.flash = T('Not authorized.')
        redirect(URL('default', 'index'))
    if (not 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 subm.author == auth.user_id:
        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]))
    if can_view_feedback:
	back_link = P(A(T('Back to submission list'),
			_href=URL('ranking', 'view_venue', args=[c.id])))
    else:
	back_link = P(A(T('Back to submission list'),
			_href=URL('feedback', 'index', args=[c.id])))
    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.quality.readable = True
    db.submission.identifier.readable = True
    db.submission.error.readable = True
    db.submission.percentile.readable = True
    db.submission.comment.readable = True
    db.submission.feedback.readable = True

    # 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
    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,
		venue_link=venue_link, grid=grid, back_link=back_link)
Ejemplo n.º 4
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.º 5
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.º 6
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.º 7
0
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)
Ejemplo n.º 8
0
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)
Ejemplo n.º 9
0
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)
Ejemplo n.º 10
0
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)
Ejemplo n.º 11
0
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)