コード例 #1
0
def view_submission():
    """Allows viewing a submission by someone who has the task to review it.
    This function is accessed by task id, not submission id, to check access
    and anonymize the submission.
    The parameters are: 
    * 'v', or 'e': according to whether one wants to view only, or also edit,
      the review;
    * task_id.
    """
    ok, v = access.validate_task(db, request.args(1), get_user_email())
    if not ok:
        session.flash = T(v)
        redirect(URL('default', 'index'))
    (t, subm, c) = v

    # Attachment submission.
    attachment_link = None
    if c.allow_file_upload:
        if subm.content is not None and subm.content != '':
            attachment_link = P(
                A(T('Download attachment'),
                  _class='btn',
                  _href=URL('download_reviewer', args=[t.id, subm.content])))
        else:
            attachment_link = P(T('None'))

    # Link submission.
    if c.allow_link_submission and subm.link is not None:
        subm_link = P(A(subm.link, _href=subm.link))
    else:
        subm_link = P(T('None'))

    # Content; this is always present.
    if subm.comment is not None:
        subm_content = MARKMIN(keystore_read(subm.comment))
    else:
        subm_content = P(T('None'))

    review_link = None
    if request.args(0) == 'e':
        review_link = A(T('Enter/edit review'),
                        _class='btn',
                        _href=URL('rating', 'review', args=[t.id]))
    submission_name = keystore_read(t.submission_name, default='submission')
    return dict(task=t,
                submission_name=submission_name,
                subm=subm,
                subm_content=subm_content,
                subm_link=subm_link,
                review_link=review_link,
                attachment_link=attachment_link)
コード例 #2
0
ファイル: submission.py プロジェクト: erikaeriga/crowdranker
def view_submission():
    """Allows viewing a submission by someone who has the task to review it.
    This function is accessed by task id, not submission id, to check access
    and anonymize the submission."""
    v = access.validate_task(db, request.args(0), auth.user_id)
    if v == None:
        session.flash(T('Not authorized.'))
        redirect(URL('default', 'index'))
    (t, subm, cont) = v
    download_link = A(T('Download'),
		      _class='btn',
	              _href=URL('download_reviewer', args=[t.id, subm.content]))
    venue_link = A(cont.name, _href=URL('venues', 'view_venue', args=[cont.id]))
    subm_link = None
    if cont.allow_link_submission:
	subm_link = A(subm.link, _href=subm.link)
    return dict(title=t.submission_name, download_link=download_link,
		venue_link=venue_link, subm_link=subm_link)
コード例 #3
0
ファイル: submission.py プロジェクト: lawrancej/crowdranker
def view_submission():
    """Allows viewing a submission by someone who has the task to review it.
    This function is accessed by task id, not submission id, to check access
    and anonymize the submission.
    The parameters are: 
    * 'v', or 'e': according to whether one wants to view only, or also edit,
      the review;
    * task_id.
    """
    ok, v = access.validate_task(db, request.args(1), get_user_email())
    if not ok:
        session.flash = T(v)
        redirect(URL('default', 'index'))
    (t, subm, c) = v

    # Attachment submission.
    attachment_link = None
    if c.allow_file_upload:
        if subm.content is not None and subm.content != '':
            attachment_link = P(A(T('Download attachment'), _class='btn',
                                _href=URL('download_reviewer', args=[t.id, subm.content])))
        else:
            attachment_link = P(T('None'))
            
    # Link submission.
    if c.allow_link_submission and subm.link is not None:
        subm_link = P(A(subm.link, _href=subm.link))
    else:
        subm_link = P(T('None'))
        
    # Content; this is always present.
    if subm.comment is not None:
        subm_content = MARKMIN(keystore_read(subm.comment))
    else:
        subm_content = P(T('None'))
        
    review_link = None
    if request.args(0) == 'e':
        review_link = A(T('Enter/edit review'), _class='btn', _href=URL('rating', 'review', args=[t.id]))
    submission_name = keystore_read(t.submission_name, default='submission')
    return dict(task=t,
                submission_name=submission_name, subm=subm,
                subm_content=subm_content, subm_link=subm_link,
                review_link=review_link, attachment_link=attachment_link)
コード例 #4
0
def download_reviewer():
    # Checks that the reviewer has access.
    ok, v = access.validate_task(db, request.args(0), get_user_email())
    if not ok:
        session.flash = T(v)
        redirect(URL('default', 'index'))
    (t, s, c) = v
    # Builds the download name for the file.
    if c.submissions_are_anonymized:
        # Get the extension of the original file
        original_ext = util.get_original_extension(s.original_filename)
        if t is None:
            subm_name = 'submission'
        else:
            subm_name = keystore_read(t.submission_name, default='submission')
        file_alias = subm_name + '.' + original_ext
    else:
        file_alias = s.original_filename
    return my_download(file_alias, subm_content=s.content)
コード例 #5
0
ファイル: submission.py プロジェクト: lawrancej/crowdranker
def download_reviewer():
    # Checks that the reviewer has access.
    ok, v = access.validate_task(db, request.args(0), get_user_email())
    if not ok:
        session.flash = T(v)
        redirect(URL('default', 'index'))
    (t, s, c) = v
    # Builds the download name for the file.
    if c.submissions_are_anonymized:
        # Get the extension of the original file
        original_ext = util.get_original_extension(s.original_filename)
        if t is None:
            subm_name = 'submission'
        else:
            subm_name = keystore_read(t.submission_name, default='submission')
        file_alias = subm_name + '.' + original_ext
    else:
        file_alias = s.original_filename
    return my_download(file_alias, subm_content=s.content)
コード例 #6
0
ファイル: submission.py プロジェクト: pombredanne/crowdranker
def download_reviewer():
    # Checks that the reviewer has access.
    ok, v = access.validate_task(db, request.args(0), auth.user.email)
    if not ok:
        session.flash = T(v)
        redirect(URL('default', 'index'))
    (t, s, c) = v
    # Builds the download name for the file.
    if c.submissions_are_anonymized:
	# Get the extension of the original file
	original_ext = util.get_original_extension(s.original_filename)
        file_alias = ( t.submission_name if t != None else 'submission' )  + '.' + original_ext
    else:
        # If title_is_file_name is set, then we use that as the alias,
        # otherwise we use the original filename.
        if c.submission_title_is_file_name:
            file_alias = s.title + '.' + original_ext
        else:
            file_alias = s.original_filename
    return my_download(file_alias, subm_content=s.content)
コード例 #7
0
def view_submission():
    """Allows viewing a submission by someone who has the task to review it.
    This function is accessed by task id, not submission id, to check access
    and anonymize the submission."""
    ok, v = access.validate_task(db, request.args(0), auth.user.email)
    if not ok:
        session.flash = T(v)
        redirect(URL('default', 'index'))
    (t, subm, cont) = v
    download_link = A(T('Download'),
                      _class='btn',
                      _href=URL('download_reviewer', args=[t.id]))
    venue_link = A(cont.name,
                   _href=URL('venues', 'view_venue', args=[cont.id]))
    subm_link = None
    if cont.allow_link_submission:
        subm_link = A(subm.link, _href=subm.link)
    return dict(title=t.submission_name,
                download_link=download_link,
                venue_link=venue_link,
                subm_link=subm_link)
コード例 #8
0
ファイル: submission.py プロジェクト: erikaeriga/crowdranker
def download_reviewer():
    # Checks that the reviewer has access.
    v = access.validate_task(db, request.args(0), auth.user_id)
    if v == None:
        session.flash = T('Not authorized.')
        redirect(URL('default', 'index'))
    (t, s, c) = v
    # Builds the download name for the file.
    if c.submissions_are_anonymized:
	# Get the extension of the original file
	original_ext = s.original_filename.split('.')[-1]
        file_alias = ( t.submission_name if t != None else 'submission' )  + '.' + original_ext
    else:
        # If title_is_file_name is set, then we use that as the alias,
        # otherwise we use the original filename.
        if c.submission_title_is_file_name:
            file_alias = s.title + '.' + original_ext
        else:
            file_alias = s.original_filename
    # TODO(luca): The next line should be useless.
    request.args = request.args[1:]
    return my_download(request, db, file_alias)
コード例 #9
0
def download_reviewer():
    # Checks that the reviewer has access.
    ok, v = access.validate_task(db, request.args(0), auth.user.email)
    if not ok:
        session.flash = T(v)
        redirect(URL('default', 'index'))
    (t, s, c) = v
    # Builds the download name for the file.
    if c.submissions_are_anonymized:
        # Get the extension of the original file
        original_ext = s.original_filename.split('.')[-1]
        file_alias = (t.submission_name
                      if t != None else 'submission') + '.' + original_ext
    else:
        # If title_is_file_name is set, then we use that as the alias,
        # otherwise we use the original filename.
        if c.submission_title_is_file_name:
            file_alias = s.title + '.' + original_ext
        else:
            file_alias = s.original_filename
    # TODO(luca): The next line should be useless.
    request.args = request.args[1:]
    return my_download(request, db, file_alias)
コード例 #10
0
ファイル: submission.py プロジェクト: pombredanne/crowdranker
def view_submission():
    """Allows viewing a submission by someone who has the task to review it.
    This function is accessed by task id, not submission id, to check access
    and anonymize the submission."""
    ok, v = access.validate_task(db, request.args(1), auth.user.email)
    if not ok:
        session.flash = T(v)
        redirect(URL('default', 'index'))
    (t, subm, c) = v
    link_list = []
    # Check whether link submission is allowed.
    db.submission.link.readable = db.submission.link.writable = c.allow_link_submission
    # Check whether attachment submission is allowed.
    if c.allow_file_upload:
	link_list.append(A(T('Download attachment'),
			   _href=URL('download_reviewer', args=[t.id, subm.content])))
    if c.allow_link_submission:
	subm_link = A(subm.link, _href=subm.link)
    else:
	subm_link = None
    if request.args(0) == 'e':
	link_list.append(A(T('Enter review'), _href=URL('rating', 'review', args=[t.id])))
	link_list.append(A(T('Decline review'), _href=URL('rating', 'decline', args=[t.id])))
    return dict(task=t, subm=subm, subm_link=subm_link, link_list=link_list)
コード例 #11
0
ファイル: rating.py プロジェクト: mdipierro/crowdranker
    for k, v in str_grades.iteritems():
	try:
	    grades[long(k)] = float(v)
	except Exception, e:
	    logger.warning("Grades cannot be converted: " + str(k) + ":" + str(v))

    # Now we need to find the names of the submissions (for the user) that were 
    # used in this last ordering.
    # We create a submission_id to line mapping, that will be passed in json to the view.
    submissions = {}
    for i in last_ordering:
	# Finds the task.
	st = db((db.task.submission_id == i) &
		(db.task.user_id == auth.user_id)).select().first()
	if st != None:
	    v = access.validate_task(db, st.id, auth.user_id)
	    if v != None:
		(_, subm, cont) = v
		line = SPAN(A(st.submission_name, _href=URL('submission', 'view_submission', args=[i])),
			    " (Comments: ", util.shorten(st.comments), ") ",
			    A(T('Download'), _class='btn',
			      _href=URL('submission', 'download_reviewer', args=[st.id, subm.content])))
		submissions[i] = line 
    # Adds also the last submission.
    v = access.validate_task(db, t.id, auth.user_id)
    if v == None:
	# Should not happen.
	session.flash('You cannot view this submission.')
	redirect(URL('default', 'index'))
    (_, subm, cont) = v
    line = SPAN(A(t.submission_name, _href=(URL('submission', 'view_submission', args=[t.id]))),
コード例 #12
0
ファイル: rating.py プロジェクト: tilgovi/crowdranker
    for k, v in str_grades.iteritems():
	try:
	    grades[long(k)] = float(v)
	except Exception, e:
	    logger.warning("Grades cannot be converted: " + str(k) + ":" + str(v))

    # Now we need to find the names of the submissions (for the user) that were 
    # used in this last ordering.
    # We create a submission_id to line mapping, that will be passed in json to the view.
    submissions = {}
    for i in last_ordering:
	# Finds the task.
	st = db((db.task.submission_id == i) &
		(db.task.user == auth.user.email)).select().first()
	if st != None:
	    ok, v = access.validate_task(db, st.id, auth.user.email)
	    if ok:
		(_, subm, cont) = v
		line = SPAN(A(st.submission_name, _href=URL('submission', 'view_submission', args=[i])),
			    " (Comments: ", util.shorten(st.comments), ") ",
			    A(T('Download'), _class='btn',
			      _href=URL('submission', 'download_reviewer', args=[st.id, subm.content])))
		submissions[i] = line 
    # Adds also the last submission.
    ok, v = access.validate_task(db, t.id, auth.user.email)
    if not ok:
	# Should not happen.
	session.flash = T(v)
	redirect(URL('default', 'index'))
    (_, subm, cont) = v
    line = SPAN(A(t.submission_name, _href=(URL('submission', 'view_submission', args=[t.id]))),
コード例 #13
0
ファイル: rating.py プロジェクト: gaybro8777/crowdranker
        try:
            grades[long(k)] = float(v)
        except Exception, e:
            logger.warning("Grades cannot be converted: " + str(k) + ":" +
                           str(v))

    # Now we need to find the names of the submissions (for the user) that were
    # used in this last ordering.
    # We create a submission_id to line mapping, that will be passed in json to the view.
    submissions = {}
    for i in last_ordering:
        # Finds the task.
        st = db((db.task.submission_id == i)
                & (db.task.user == auth.user.email)).select().first()
        if st != None:
            ok, v = access.validate_task(db, st.id, auth.user.email)
            if ok:
                (_, subm, cont) = v
                line = SPAN(
                    A(st.submission_name,
                      _href=URL('submission', 'view_submission', args=[i])),
                    " (Comments: ", util.shorten(st.comments), ") ",
                    A(T('Download'),
                      _class='btn',
                      _href=URL('submission',
                                'download_reviewer',
                                args=[st.id, subm.content])))
                submissions[i] = line
    # Adds also the last submission.
    ok, v = access.validate_task(db, t.id, auth.user.email)
    if not ok: