示例#1
0
def submit():
    # Gets the information on the venue.
    c = db.venue(request.args[0]) or redirect(URL('default', 'index'))
    # Gets information on the user.
    props = db(db.user_properties.email == auth.user.email).select().first()
    if props == None: 
        venue_ids = []
        venues_has_submitted = []
    else:
        venue_ids = util.get_list(props.venues_can_submit)
        venues_has_submitted = util.get_list(props.venues_has_submitted)
    # Is the venue open for submission?
    if not (c.submit_constraint == None or c.id in venue_ids):
	session.flash = T('You cannot submit to this venue.')
        redirect(URL('venues', 'view_venue', args=[c.id]))
    t = datetime.utcnow()
    if not (c.is_active and c.is_approved and c.open_date <= t and c.close_date >= t):
	session.flash = T('The submission deadline has passed; submissions are closed.')
        redirect(URL('venues', 'view_venue', args=[c.id]))
    # Ok, the user can submit.  Looks for previous submissions.
    sub = db((db.submission.author == auth.user_id) & (db.submission.venue_id == c.id)).select().first()
    if sub != None and not c.allow_multiple_submissions:
        session.flash = T('You have already submitted to this venue.')
        redirect(URL('my_submissions_index', args=[c.id]))
    # The author can access the title.
    db.submission.title.readable = db.submission.title.writable = True
    # Check whether link submission is allowed.
    db.submission.link.readable = db.submission.link.writable = c.allow_link_submission
    db.submission.n_completed_reviews.readable = False
    db.submission.n_rejected_reviews.readable = False
    db.submission.feedback.readable = db.submission.feedback.writable = False
    # Produces an identifier for the submission.
    db.submission.identifier.default = util.get_random_id()
    db.submission.email.default = auth.user.email
    # Assigns default quality to the submission.
    avg, stdev = ranker.get_init_average_stdev()
    db.submission.quality.default = avg
    db.submission.error.default = stdev
    # No percentile readable.
    db.submission.percentile.readable = False
    # TODO(luca): check that it is fine to do the download link without parameters.
    form = SQLFORM(db.submission, upload=URL('download_auhor', args=[None]))
    form.vars.venue_id = c.id
    if request.vars.content != None and request.vars.content != '':
        form.vars.original_filename = request.vars.content.filename
    if form.process().accepted:
        # Adds the venue to the list of venues where the user submitted.
        # TODO(luca): Enable users to delete submissions.  But this is complicated; we need to 
        # delete also their quality information etc.  For the moment, no deletion.
        submitted_ids = util.id_list(venues_has_submitted)
        submitted_ids = util.list_append_unique(submitted_ids, c.id)
        if props == None:
	    db.user_properties.insert(email = auth.user.email,
				      venues_has_submitted = submitted_ids)
        else:
            props.update_record(venues_has_submitted = submitted_ids)
        db.commit()
        session.flash = T('Your submission has been accepted.')
        redirect(URL('feedback', 'index', args=['all']))
    return dict(form=form, venue=c)
示例#2
0
def add_venue_to_user_rate(id, user_list):
    for m in user_list:
        u = db(db.user_properties.user == m).select(db.user_properties.venues_can_rate).first()
        if u == None:
            # We never heard of this user, but we still create the permission.
            db.user_properties.insert(user=m, venues_can_rate=[id])
        else:
            l = u.venues_can_rate
            l = util.list_append_unique(l, id)
            db(db.user_properties.user == m).update(venues_can_rate=l)
示例#3
0
def add_venue_to_user_rate(id, user_list):
    for m in user_list:
        u = db(db.user_properties.user == m).select(db.user_properties.venues_can_rate).first()
        if u == None:
            # We never heard of this user, but we still create the permission.
            db.user_properties.insert(user=m, venues_can_rate = [id])
        else:
            l = u.venues_can_rate
	    l = util.list_append_unique(l, id)
	    db(db.user_properties.user == m).update(venues_can_rate = l)
示例#4
0
def add_user_list_managers(id, managers):
    for m in managers:
        u = db(db.user_properties.user == m).select(db.user_properties.managed_user_lists).first()
        if u == None:
            # We never heard of this user, but we still create the permission.
            logger.debug("Creating user properties for user:"******"<")
            db.user_properties.insert(user=m, managed_user_lists=[id])
        else:
            l = util.get_list(u.managed_user_lists)
	    l = util.list_append_unique(l, id)
	    db(db.user_properties.user == m).update(managed_user_lists = l)
示例#5
0
def add_venue_to_user_rate(venue_id, users):
    """Add the given users to those that can rate venue_id."""
    for m in users:
        u = db(db.user_properties.user == m).select(db.user_properties.venues_can_rate).first()
        if u == None:
            # We never heard of this user, but we still create the permission.
            logger.debug("Creating user properties for user:"******"<")
            db.user_properties.insert(user=m, venues_can_rate = [venue_id])
        else:
            l = util.get_list(u.venues_can_rate)
	    l = util.list_append_unique(l, venue_id)
	    db(db.user_properties.user == m).update(venues_can_rate = l)
示例#6
0
def add_user_list_managers(id, managers):
    for m in managers:
        u = db(db.user_properties.user == m).select(
            db.user_properties.managed_user_lists).first()
        if u == None:
            # We never heard of this user, but we still create the permission.
            logger.debug("Creating user properties for user:"******"<")
            db.user_properties.insert(user=m, managed_user_lists=[id])
        else:
            l = util.get_list(u.managed_user_lists)
            l = util.list_append_unique(l, id)
            db(db.user_properties.user == m).update(managed_user_lists=l)
示例#7
0
def add_venue_to_user_rate(venue_id, users):
    """Add the given users to those that can rate venue_id."""
    for m in users:
        u = db(db.user_properties.user == m).select(
            db.user_properties.venues_can_rate).first()
        if u == None:
            # We never heard of this user, but we still create the permission.
            logger.debug("Creating user properties for user:"******"<")
            db.user_properties.insert(user=m, venues_can_rate=[venue_id])
        else:
            l = util.get_list(u.venues_can_rate)
            l = util.list_append_unique(l, venue_id)
            db(db.user_properties.user == m).update(venues_can_rate=l)
示例#8
0
def manager_submit():
    """This function is used by venue managers to do submissions on behalf of others.  It can be used
    even when the submission deadline is past."""
    # Gets the information on the venue.
    c = db.venue(request.args[0]) or redirect(URL('default', 'index'))
    # Checks that the user is a manager for the venue.
    manager_props = db(db.user_properties.email == auth.user.email).select().first()
    can_manage = c.id in util.get_list(manager_props.venues_can_manage)
    if not can_manage:
	session.flash = T('Not authorized!')
	redirect(URL('default', 'index'))
    # Prepares the submission.
    db.submission.email.writable = db.submission.email.readable = True
    db.submission.author.readable = db.submission.author.writable = False
    db.submission.feedback.readable = db.submission.feedback.writable = False
    db.submission.email.label = T('Author')
    # Assigns default quality to the submission.
    avg, stdev = ranker.get_init_average_stdev()
    db.submission.quality.default = avg
    db.submission.error.default = stdev
    # Produces an identifier for the submission.
    db.submission.identifier.default = util.get_random_id()
    form = SQLFORM(db.submission, upload=URL('download_manager', args=[None]))
    form.vars.venue_id = c.id
    if request.vars.content != None and request.vars.content != '':
        form.vars.original_filename = request.vars.content.filename
    if form.process(onvalidation=manager_submit_validation).accepted:
	# Fixes the author field of the submission.
	db(db.submission.id == form.vars.id).update(author=form.vars.author)
        # Adds the venue to the list of venues where the user submitted.
        # TODO(luca): Enable users to delete submissions.  But this is complicated; we need to 
        # delete also their quality information etc.  For the moment, no deletion.
	props = db(db.user_properties.email == form.vars.email).select().first()
	if props == None: 
	    venues_has_submitted = []
	else:
	    venues_has_submitted = util.get_list(props.venues_has_submitted)
        submitted_ids = util.id_list(venues_has_submitted)
        submitted_ids = util.list_append_unique(submitted_ids, c.id)
        if props == None:
            db(db.user_properties.email == form.vars.email).update(venues_has_submitted = submitted_ids)
        else:
            props.update_record(venues_has_submitted = submitted_ids)
        db.commit()
        session.flash = T('The submission has been accepted.')
        redirect(URL('ranking', 'view_venue', args=[c.id]))
    return dict(form=form, venue=c)
示例#9
0
def submit():
    # Gets the information on the venue.
    c = db.venue(request.args(0)) or redirect(URL('default', 'index'))
    # Gets information on the user.
    props = db(db.user_properties.user == get_user_email()).select().first()
    if props == None:
        venue_ids = []
        venues_has_submitted = []
    else:
        venue_ids = util.get_list(props.venues_can_submit)
        venues_has_submitted = util.get_list(props.venues_has_submitted)
    # Is the venue open for submission?
    if not access.can_submit(c, props):
        session.flash = T('Not authorized.')
        redirect(URL('default', 'index'))
    t = datetime.utcnow()
    if c.open_date > t:
        session.flash = T('Submissions are not open yet.')
        redirect(URL('venues', 'subopen_index'))
    if c.close_date < t:
        session.flash = T(
            'The submission deadline has passed; submissions are closed.')
        redirect(URL('venues', 'subopen_index'))

    # Ok, the user can submit.  Looks for previous submissions.
    sub = db((db.submission.venue_id == c.id)
             & (db.submission.user == get_user_email())).select().first()
    if sub != None and not c.allow_multiple_submissions:
        session.flash = T('Update your existing submission')
        redirect(URL('submission', 'view_own_submission', args=['v', sub.id]))
    # Check whether link submission is allowed.
    db.submission.link.readable = db.submission.link.writable = c.allow_link_submission
    # Check whether attachment submission is allowed.
    db.submission.content.readable = db.submission.content.writable = c.allow_file_upload
    db.submission.n_completed_reviews.readable = False
    db.submission.n_rejected_reviews.readable = False
    db.submission.feedback.readable = db.submission.feedback.writable = False
    db.submission.date_updated.readable = False
    db.submission.date_created.readable = False
    db.submission.user.default = get_user_email()
    # Assigns default quality to the submission.
    avg, stdev = ranker.get_init_average_stdev()
    db.submission.quality.default = avg
    db.submission.error.default = stdev
    # No percentile readable.
    db.submission.percentile.readable = False
    # TODO(luca): check that it is fine to do the download link without parameters.
    form = SQLFORM(db.submission, upload=URL('download_auhor', args=[None]))
    form.vars.venue_id = c.id
    form.vars.date_updated = datetime.utcnow()
    if request.vars.content != None and request.vars.content != '':
        form.vars.original_filename = request.vars.content.filename
    if form.process(onvalidation=write_comment_to_keystore).accepted:
        # Adds the venue to the list of venues where the user submitted.
        # TODO(luca): Enable users to delete submissions.  But this is complicated; we need to
        # delete also their quality information etc.  For the moment, no deletion.
        submitted_ids = util.id_list(venues_has_submitted)
        submitted_ids = util.list_append_unique(submitted_ids, c.id)
        if props == None:
            db.user_properties.insert(user=get_user_email(),
                                      venues_has_submitted=submitted_ids)
        else:
            props.update_record(venues_has_submitted=submitted_ids)
        db.commit()
        session.flash = T('Your submission has been accepted.')
        # We send the user to review their own submission, for completeness.
        redirect(
            URL('submission', 'view_own_submission', args=['v', form.vars.id]))
    instructions = keystore_read(c.submission_instructions, default='')
    if instructions == '':
        instructions = None
    else:
        instructions = MARKMIN(instructions)
    return dict(form=form, venue=c, instructions=instructions)
示例#10
0
def submit():
    # Gets the information on the venue.
    c = db.venue(request.args(0)) or redirect(URL('default', 'index'))
    # Gets information on the user.
    props = db(db.user_properties.user == auth.user.email).select().first()
    if props == None:
        venue_ids = []
        venues_has_submitted = []
    else:
        venue_ids = util.get_list(props.venues_can_submit)
        venues_has_submitted = util.get_list(props.venues_has_submitted)
    # Is the venue open for submission?
    if not (c.submit_constraint == None or c.id in venue_ids):
        session.flash = T('You cannot submit to this venue.')
        redirect(URL('venues', 'view_venue', args=[c.id]))
    t = datetime.utcnow()
    if not (c.is_active and c.is_approved and c.open_date <= t
            and c.close_date >= t):
        session.flash = T(
            'The submission deadline has passed; submissions are closed.')
        redirect(URL('venues', 'view_venue', args=[c.id]))
    # Ok, the user can submit.  Looks for previous submissions.
    sub = db((db.submission.user == auth.user.email)
             & (db.submission.venue_id == c.id)).select().first()
    if sub != None and not c.allow_multiple_submissions:
        session.flash = T('You have already submitted to this venue.')
        redirect(URL('venues', 'view_venue', args=[c.id]))
    # The author can access the title.
    db.submission.title.readable = db.submission.title.writable = True
    # Check whether link submission is allowed.
    db.submission.link.readable = db.submission.link.writable = c.allow_link_submission
    db.submission.n_completed_reviews.readable = False
    db.submission.n_rejected_reviews.readable = False
    db.submission.feedback.readable = db.submission.feedback.writable = False
    db.submission.date_updated.readable = False
    # Produces an identifier for the submission.
    db.submission.identifier.default = util.get_random_id()
    db.submission.user.default = auth.user.email
    # Assigns default quality to the submission.
    avg, stdev = ranker.get_init_average_stdev()
    db.submission.quality.default = avg
    db.submission.error.default = stdev
    # No percentile readable.
    db.submission.percentile.readable = False
    # TODO(luca): check that it is fine to do the download link without parameters.
    form = SQLFORM(db.submission, upload=URL('download_auhor', args=[None]))
    form.vars.venue_id = c.id
    if request.vars.content != None and request.vars.content != '':
        form.vars.original_filename = request.vars.content.filename
    if form.process().accepted:
        # Adds the venue to the list of venues where the user submitted.
        # TODO(luca): Enable users to delete submissions.  But this is complicated; we need to
        # delete also their quality information etc.  For the moment, no deletion.
        submitted_ids = util.id_list(venues_has_submitted)
        submitted_ids = util.list_append_unique(submitted_ids, c.id)
        if props == None:
            db.user_properties.insert(user=auth.user.email,
                                      venues_has_submitted=submitted_ids)
        else:
            props.update_record(venues_has_submitted=submitted_ids)
        db.commit()
        session.flash = T('Your submission has been accepted.')
        redirect(URL('feedback', 'index', args=['all']))
    return dict(form=form, venue=c)
示例#11
0
def manager_submit():
    """This function is used by venue managers to do submissions on behalf of others.  It can be used
    even when the submission deadline is past."""
    # Gets the information on the venue.
    c = db.venue(request.args(0)) or redirect(URL('default', 'index'))
    # Checks that the user is a manager for the venue.
    manager_props = db(db.user_properties.user == auth.user.email).select().first()
    can_manage = c.id in util.get_list(manager_props.venues_can_manage)
    if not can_manage:
	session.flash = T('Not authorized!')
	redirect(URL('default', 'index'))
    # Prepares the submission.
    db.submission.user.readable = db.submission.user.writable = True
    db.submission.user.default = ''
    db.submission.feedback.readable = db.submission.feedback.writable = False
    # Assigns default quality to the submission.
    avg, stdev = ranker.get_init_average_stdev()
    db.submission.quality.default = avg
    db.submission.error.default = stdev
    # Produces an identifier for the submission.
    db.submission.identifier.default = util.get_random_id()

    # Prepares the submission form.
    form = SQLFORM(db.submission, upload=URL('download_manager', args=[None]))
    form.vars.venue_id = c.id
    if request.vars.content != None and request.vars.content != '':
        form.vars.original_filename = request.vars.content.filename
    if form.process().accepted:
        # Adds the venue to the list of venues where the user submitted.
	props = db(db.user_properties.user == form.vars.email).select().first()
	if props == None: 
	    venues_has_submitted = []
	else:
	    venues_has_submitted = util.get_list(props.venues_has_submitted)
        submitted_ids = util.id_list(venues_has_submitted)
        submitted_ids = util.list_append_unique(submitted_ids, c.id)
        if props == None:
            db(db.user_properties.user == form.vars.user).update(venues_has_submitted = submitted_ids)
        else:
            props.update_record(venues_has_submitted = submitted_ids)

	# If there is a prior submission of the same author to this venue, replaces the content.
	is_there_another = False
	other_subms = db(db.submission.user == form.vars.user).select()
	for other_subm in other_subms:
	    if other_subm.id != form.vars.id:
		is_there_another = True
		other_subm.update_record(
		    date_updated = datetime.utcnow(),
		    title = form.vars.title,
		    original_filename = form.vars.original_filename,
		    content = new_content,
		    link = form.vars.link,
		    comment = form.vars.comment,
		    )
	# And deletes this submission.
	if is_there_another:
	    db(db.submission.id == form.vars.id).delete()
	    session.flash = T('The previous submission by the same author has been updated.')
	else:
	    session.flash = T('The submission has been added.')
        db.commit()
	redirect(URL('ranking', 'view_venue', args=[c.id]))
    return dict(form=form, venue=c)
示例#12
0
def manager_submit():
    """This function is used by venue managers to do submissions on behalf of others.  It can be used
    even when the submission deadline is past."""
    # Gets the information on the venue.
    c = db.venue(request.args(0)) or redirect(URL('default', 'index'))
    # Checks that the user is a manager for the venue.
    manager_props = db(db.user_properties.user == get_user_email()).select().first()
    if not access.can_manage(c, manager_props):
        session.flash = T('Not authorized!')
        redirect(URL('default', 'index'))
    # Prepares the submission.
    db.submission.user.readable = db.submission.user.writable = True
    db.submission.user.default = ''
    db.submission.feedback.readable = db.submission.feedback.writable = False
    # Assigns default quality to the submission.
    avg, stdev = ranker.get_init_average_stdev()
    db.submission.quality.default = avg
    db.submission.error.default = stdev
    db.submission.percentile.readable = False
    db.submission.n_assigned_reviews.readable = False
    db.submission.n_completed_reviews.readable = False
    db.submission.n_rejected_reviews.readable = False
    # Check whether link submission is allowed.
    db.submission.link.readable = db.submission.link.writable = c.allow_link_submission
    # Check whether attachment submission is allowed.
    db.submission.content.readable = db.submission.content.writable = c.allow_file_upload

    # Prepares the submission form.
    form = SQLFORM(db.submission, upload=URL('download_manager', args=[None]))
    form.vars.venue_id = c.id
    form.vars.date_updated = datetime.utcnow()
    if request.vars.content != None and request.vars.content != '':
        form.vars.original_filename = request.vars.content.filename
    if form.process(onvalidation=write_comment_to_keystore).accepted:
        # Adds the venue to the list of venues where the user submitted.
        props = db(db.user_properties.user == form.vars.email).select().first()
        if props == None: 
            venues_has_submitted = []
        else:
            venues_has_submitted = util.get_list(props.venues_has_submitted)
        submitted_ids = util.id_list(venues_has_submitted)
        submitted_ids = util.list_append_unique(submitted_ids, c.id)
        if props == None:
            db(db.user_properties.user == form.vars.user).update(venues_has_submitted=submitted_ids)
        else:
            props.update_record(venues_has_submitted=submitted_ids)

        # If there is a prior submission of the same author to this venue, replaces the content.
        is_there_another = False
        other_subms = db((db.submission.user == form.vars.user) & 
                         (db.submission.venue_id == c.id)).select()
        for other_subm in other_subms:
            if other_subm.id != form.vars.id:
                is_there_another = True
                keystore_delete(other_subm.comment)
                other_subm.update_record(
                    date_updated = datetime.utcnow(),
                    original_filename = form.vars.original_filename,
                    content = form.vars.content,
                    link = form.vars.link,
                    comment = form.vars.comment,
                    n_assigned_reviews = 0,
                    n_completed_reviews = 0,
                    n_rejected_reviews = 0,
                    )
        # And deletes this submission.
        if is_there_another:
            db(db.submission.id == form.vars.id).delete()
            session.flash = T('The previous submission by the same author has been updated.')
        else:
            session.flash = T('The submission has been added.')
        db.commit()
        redirect(URL('ranking', 'view_submissions', args=[c.id]))
    instructions = keystore_read(c.submission_instructions, default='')
    if instructions == '':
        instructions = None
    else:
        instructions = MARKMIN(instructions)
    return dict(form=form, venue=c, instructions=instructions)
示例#13
0
def submit():
    # Gets the information on the venue.
    c = db.venue(request.args(0)) or redirect(URL('default', 'index'))
    # Gets information on the user.
    props = db(db.user_properties.user == get_user_email()).select().first()
    if props == None: 
        venue_ids = []
        venues_has_submitted = []
    else:
        venue_ids = util.get_list(props.venues_can_submit)
        venues_has_submitted = util.get_list(props.venues_has_submitted)
    # Is the venue open for submission?
    if not access.can_submit(c, props):
        session.flash = T('Not authorized.')
        redirect(URL('default', 'index'))
    t = datetime.utcnow()
    if c.open_date > t:
        session.flash = T('Submissions are not open yet.')
        redirect(URL('venues', 'subopen_index'))
    if c.close_date < t:
        session.flash = T('The submission deadline has passed; submissions are closed.')
        redirect(URL('venues', 'subopen_index'))
        
    # Ok, the user can submit.  Looks for previous submissions.
    sub = db((db.submission.venue_id == c.id) & (db.submission.user == get_user_email())).select().first()
    if sub != None and not c.allow_multiple_submissions:
        session.flash = T('Update your existing submission')
        redirect(URL('submission', 'view_own_submission', args=['v', sub.id]))
    # Check whether link submission is allowed.
    db.submission.link.readable = db.submission.link.writable = c.allow_link_submission
    # Check whether attachment submission is allowed.
    db.submission.content.readable = db.submission.content.writable = c.allow_file_upload
    db.submission.n_completed_reviews.readable = False
    db.submission.n_rejected_reviews.readable = False
    db.submission.feedback.readable = db.submission.feedback.writable = False
    db.submission.date_updated.readable = False
    db.submission.date_created.readable = False
    db.submission.user.default = get_user_email()
    # Assigns default quality to the submission.
    avg, stdev = ranker.get_init_average_stdev()
    db.submission.quality.default = avg
    db.submission.error.default = stdev
    # No percentile readable.
    db.submission.percentile.readable = False
    # TODO(luca): check that it is fine to do the download link without parameters.
    form = SQLFORM(db.submission, upload=URL('download_auhor', args=[None]))
    form.vars.venue_id = c.id
    form.vars.date_updated = datetime.utcnow()
    if request.vars.content != None and request.vars.content != '':
        form.vars.original_filename = request.vars.content.filename
    if form.process(onvalidation=write_comment_to_keystore).accepted:
        # Adds the venue to the list of venues where the user submitted.
        # TODO(luca): Enable users to delete submissions.  But this is complicated; we need to 
        # delete also their quality information etc.  For the moment, no deletion.
        submitted_ids = util.id_list(venues_has_submitted)
        submitted_ids = util.list_append_unique(submitted_ids, c.id)
        if props == None:
            db.user_properties.insert(user=get_user_email(),
                                      venues_has_submitted=submitted_ids)
        else:
            props.update_record(venues_has_submitted=submitted_ids)
        db.commit()
        session.flash = T('Your submission has been accepted.')
        # We send the user to review their own submission, for completeness.
        redirect(URL('submission', 'view_own_submission', args=['v', form.vars.id]))
    instructions = keystore_read(c.submission_instructions, default='')
    if instructions == '':
        instructions = None
    else:
        instructions = MARKMIN(instructions)
    return dict(form=form, venue=c, instructions=instructions)
示例#14
0
                    if r.rejected:
                        n_rejected += 1
                    else:
                        n_completed += 1
            subm.n_completed_reviews = n_completed
            subm.n_rejected_reviews = n_rejected
            subm.update_record()
        
        # Marks that the user has reviewed for this venue.
        props = db(db.user_properties.user == get_user_email()).select(db.user_properties.id, db.user_properties.venues_has_rated).first()
        if props == None:
            db.user_properties.insert(user = get_user_email(),
                                      venues_has_rated = [venue.id])
        else:
            has_rated = util.get_list(props.venues_has_rated)
            has_rated = util.list_append_unique(has_rated, venue.id)
            props.update_record(venues_has_rated = has_rated)

        # Calling ranker.py directly.
        ranker.process_comparison(t.venue_id, get_user_email(),
                                  form.vars.order[::-1], t.submission_id)
        db.commit()
        session.flash = T('The review has been submitted.')
        redirect(URL('venues', 'reviewing_duties'))

    return dict(form=form, task=t, 
        submissions = submissions,
        grades = grades,
        sub_title = this_submission_name,
        general_instructions = general_instructions,
        venue = venue,
示例#15
0
def manager_submit():
    """This function is used by venue managers to do submissions on behalf of others.  It can be used
    even when the submission deadline is past."""
    # Gets the information on the venue.
    c = db.venue(request.args(0)) or redirect(URL('default', 'index'))
    # Checks that the user is a manager for the venue.
    manager_props = db(
        db.user_properties.user == get_user_email()).select().first()
    if not access.can_manage(c, manager_props):
        session.flash = T('Not authorized!')
        redirect(URL('default', 'index'))
    # Prepares the submission.
    db.submission.user.readable = db.submission.user.writable = True
    db.submission.user.default = ''
    db.submission.feedback.readable = db.submission.feedback.writable = False
    # Assigns default quality to the submission.
    avg, stdev = ranker.get_init_average_stdev()
    db.submission.quality.default = avg
    db.submission.error.default = stdev
    db.submission.percentile.readable = False
    db.submission.n_assigned_reviews.readable = False
    db.submission.n_completed_reviews.readable = False
    db.submission.n_rejected_reviews.readable = False
    # Check whether link submission is allowed.
    db.submission.link.readable = db.submission.link.writable = c.allow_link_submission
    # Check whether attachment submission is allowed.
    db.submission.content.readable = db.submission.content.writable = c.allow_file_upload

    # Prepares the submission form.
    form = SQLFORM(db.submission, upload=URL('download_manager', args=[None]))
    form.vars.venue_id = c.id
    form.vars.date_updated = datetime.utcnow()
    if request.vars.content != None and request.vars.content != '':
        form.vars.original_filename = request.vars.content.filename
    if form.process(onvalidation=write_comment_to_keystore).accepted:
        # Adds the venue to the list of venues where the user submitted.
        props = db(db.user_properties.user == form.vars.email).select().first()
        if props == None:
            venues_has_submitted = []
        else:
            venues_has_submitted = util.get_list(props.venues_has_submitted)
        submitted_ids = util.id_list(venues_has_submitted)
        submitted_ids = util.list_append_unique(submitted_ids, c.id)
        if props == None:
            db(db.user_properties.user == form.vars.user).update(
                venues_has_submitted=submitted_ids)
        else:
            props.update_record(venues_has_submitted=submitted_ids)

        # If there is a prior submission of the same author to this venue, replaces the content.
        is_there_another = False
        other_subms = db((db.submission.user == form.vars.user)
                         & (db.submission.venue_id == c.id)).select()
        for other_subm in other_subms:
            if other_subm.id != form.vars.id:
                is_there_another = True
                keystore_delete(other_subm.comment)
                other_subm.update_record(
                    date_updated=datetime.utcnow(),
                    original_filename=form.vars.original_filename,
                    content=form.vars.content,
                    link=form.vars.link,
                    comment=form.vars.comment,
                    n_assigned_reviews=0,
                    n_completed_reviews=0,
                    n_rejected_reviews=0,
                )
        # And deletes this submission.
        if is_there_another:
            db(db.submission.id == form.vars.id).delete()
            session.flash = T(
                'The previous submission by the same author has been updated.')
        else:
            session.flash = T('The submission has been added.')
        db.commit()
        redirect(URL('ranking', 'view_submissions', args=[c.id]))
    instructions = keystore_read(c.submission_instructions, default='')
    if instructions == '':
        instructions = None
    else:
        instructions = MARKMIN(instructions)
    return dict(form=form, venue=c, instructions=instructions)
示例#16
0
        t.update_record(completed_date=datetime.utcnow(), comments=form.vars.comments)
	# Increments the number of reviews this submission has received.
	subm = db.submission(t.submission_id)
	if subm != None and subm.n_completed_reviews != None:
	    n = subm.n_completed_reviews
	    subm.n_completed_reviews = n + 1
	    subm.update_record()
	
	# Marks that the user has reviewed for this venue.
	props = db(db.user_properties.email == auth.user.email).select(db.user_properties.id, db.user_properties.venues_has_rated).first()
        if props == None:
	    db.user_properties.insert(email = auth.user.email,
				      venues_has_rated = [venue.id])
        else:
	    has_rated = util.get_list(props.venues_has_rated)
	    has_rated = util.list_append_unique(has_rated, venue.id)
            props.update_record(venues_has_rated = has_rated)

        # TODO(luca): put it in a queue of things that need processing.
        # All updates done.
        # Calling ranker.py directly.
        ranker.process_comparison(db, t.venue_id, auth.user_id,
                                  ordering[::-1], t.submission_id)
        db.commit()
	session.flash = T('The review has been submitted.')
	redirect(URL('rating', 'task_index'))

    return dict(form=form, task=t, 
        submissions = submissions,
	grades = grades,
	sub_title = t.submission_name,
示例#17
0
def manager_submit():
    """This function is used by venue managers to do submissions on behalf of others.  It can be used
    even when the submission deadline is past."""
    # Gets the information on the venue.
    c = db.venue(request.args(0)) or redirect(URL('default', 'index'))
    # Checks that the user is a manager for the venue.
    manager_props = db(
        db.user_properties.user == auth.user.email).select().first()
    can_manage = c.id in util.get_list(manager_props.venues_can_manage)
    if not can_manage:
        session.flash = T('Not authorized!')
        redirect(URL('default', 'index'))
    # Prepares the submission.
    db.submission.user.readable = db.submission.user.writable = True
    db.submission.user.default = ''
    db.submission.feedback.readable = db.submission.feedback.writable = False
    # Assigns default quality to the submission.
    avg, stdev = ranker.get_init_average_stdev()
    db.submission.quality.default = avg
    db.submission.error.default = stdev
    # Produces an identifier for the submission.
    db.submission.identifier.default = util.get_random_id()

    # Prepares the submission form.
    form = SQLFORM(db.submission, upload=URL('download_manager', args=[None]))
    form.vars.venue_id = c.id
    if request.vars.content != None and request.vars.content != '':
        form.vars.original_filename = request.vars.content.filename
    if form.process().accepted:
        # Adds the venue to the list of venues where the user submitted.
        props = db(db.user_properties.user == form.vars.email).select().first()
        if props == None:
            venues_has_submitted = []
        else:
            venues_has_submitted = util.get_list(props.venues_has_submitted)
        submitted_ids = util.id_list(venues_has_submitted)
        submitted_ids = util.list_append_unique(submitted_ids, c.id)
        if props == None:
            db(db.user_properties.user == form.vars.user).update(
                venues_has_submitted=submitted_ids)
        else:
            props.update_record(venues_has_submitted=submitted_ids)

        # If there is a prior submission of the same author to this venue, replaces the content.
        is_there_another = False
        other_subms = db(db.submission.user == form.vars.user).select()
        for other_subm in other_subms:
            if other_subm.id != form.vars.id:
                is_there_another = True
                other_subm.update_record(
                    date_updated=datetime.utcnow(),
                    title=form.vars.title,
                    original_filename=form.vars.original_filename,
                    content=new_content,
                    link=form.vars.link,
                    comment=form.vars.comment,
                )
        # And deletes this submission.
        if is_there_another:
            db(db.submission.id == form.vars.id).delete()
            session.flash = T(
                'The previous submission by the same author has been updated.')
        else:
            session.flash = T('The submission has been added.')
        db.commit()
        redirect(URL('ranking', 'view_venue', args=[c.id]))
    return dict(form=form, venue=c)