Ejemplo n.º 1
0
def create_comparison_nicks():
    if auth.user.email != '*****@*****.**':
        session.flash = T('Not authorized')
        redirect(URL('default', 'index'))
    comps = db().select(db.comparison.ALL)
    for comp in comps:
        nicks = {}
        for subm_id in comp.ordering:
            s = db.submission(subm_id)
            if s is not None:
                nicks[subm_id] = util.produce_submission_nickname(s)
        comp.update_record(submission_nicknames=simplejson.dumps(nicks))
    db.commit()
    session.flash = T('done')
Ejemplo n.º 2
0
def create_comparison_nicks():
    if not is_user_admin():
        session.flash = T('Not authorized')
        redirect(URL('default', 'index'))
    comps = db().select(db.comparison.ALL)
    for comp in comps:
	nicks = {}
	for subm_id in comp.ordering:
	    s = db.submission(subm_id)
	    if s is not None:
		nicks[subm_id] = util.produce_submission_nickname(s)
	comp.update_record(submission_nicknames = simplejson.dumps(nicks))
    db.commit()
    session.flash = T('done')
    redirect(URL('default', 'index'))
Ejemplo n.º 3
0
    # highlight (because its the current/new record).
    new_comparison_item = t.submission_id

    form = SQLFORM.factory(
        Field('comments', 'text'),
        hidden=dict(order='', grades='')
        )

    if form.process(onvalidation=verify_rating_form(t.submission_id)).accepted:
        # Creates a new comparison in the db.
	ordering = form.vars.order
	grades = form.vars.grades

	# Updates the submission id to nicknames mapping.
	subm = db.submission(t.submission_id)
	subm_id_to_nickname[subm.id] = util.produce_submission_nickname(subm)
	for subm_id in ordering:
	    if subm_id not in subm_id_to_nickname:
		# We need the author of the submission.
		subm_id_to_nickname[subm_id] = util.produce_submission_nickname(db.submission(subm_id))
	subm_id_to_nickname_str = simplejson.dumps(subm_id_to_nickname)
        comparison_id = db.comparison.insert(
	    venue_id=t.venue_id, ordering=ordering, grades=grades, new_item=new_comparison_item,
	    submission_nicknames=subm_id_to_nickname_str) 
        # Marks the task as done.
        t.update_record(completed_date=datetime.utcnow(), is_completed=True, comments=form.vars.comments)
	# Increments the number of reviews this submission has received.
	if subm != None and subm.n_completed_reviews != None:
	    n = subm.n_completed_reviews
	    subm.n_completed_reviews = n + 1
	    subm.update_record()
Ejemplo n.º 4
0
def anonimize_all_venues():
    name_dict = {}
    def get_new_name(n):
	if n == '*****@*****.**' or n == '*****@*****.**':
	    return n
	if n in name_dict:
	    return name_dict[n]
	else:
	    while True:
		m = util.get_random_id(n_sections=1) + '@example.com'
		if m not in name_dict:
		    break
	    name_dict[n] = m
	    return m

    if not is_user_admin():
        session.flash = T('Not authorized')
        redirect(URL('default', 'index'))
    form = FORM.confirm(T('This will anonymize all venues; the original data WILL BE LOST.'))
    if form.accepted:
	# Builds a dictionary for anonymization.
	new_names = {}
	# Convert user lists.
	rows = db().select(db.user_list.ALL)
	for ul in rows:
	    ul.update_record(managers = [get_new_name(x) for x in ul.managers],
			     user_list = [get_new_name(x) for x in ul.user_list])
	# Convert venues.
	rows = db().select(db.venue.ALL)
	for r in rows:
	    r.update_record(created_by = get_new_name(r.created_by),
			    managers = [get_new_name(x) for x in r.managers],
			    observers = [get_new_name(x) for x in r.observers])
	# Convert submissions.
	rows = db().select(db.submission.ALL)
	for r in rows:
	    r.update_record(user = get_new_name(r.user),
			    title = util.get_random_id(n_sections=1),
			    )
	db.commit()
	# Convert comparisons.
	rows = db().select(db.comparison.ALL)
	for r in rows:
	    # Creates a new nickname dictionary.
	    nicks = {}
	    for subm_id in r.ordering:
		s = db.submission(subm_id)
		if s is not None:
		    nicks[subm_id] = util.produce_submission_nickname(s)
	    r.update_record(user = get_new_name(r.user),
			    submission_nicknames = simplejson.dumps(nicks))
	# Converts tasks.
	rows = db().select(db.task.ALL)
	for r in rows:
	    r.update_record(user = get_new_name(r.user))
	# Converts final grades.
	rows = db().select(db.grades.ALL)
	for r in rows:
	    r.update_record(user = get_new_name(r.user))
	db.commit()

	# Now for the hard part: the system tables.
	rows = db().select(db.auth_user.ALL)
	for r in rows:
	    u = get_new_name(r.email)
	    r.update_record(first_name = u,
			    last_name = u,
			    email = u,
		            password = db.auth_user.password.requires[0]('hello')[0])
	db.commit()
	
	session.flash = T('done')
	redirect(URL('default', 'index'))
    return dict(form=form)
Ejemplo n.º 5
0
    form = SQLFORM.factory(
        Field('unable_to_evaluate', 'boolean', default=False, 
              comment=T('Check this box if you are unable to evaluate fairly this submission.'
                        'If the submission is incomplete or incorrect, please do not '
                        'check this box: rather, enter an evaluation.')),
        Field('comments', 'text', requires=IS_LENGTH(minsize=16, maxsize=MAX_TEXT_LENGTH), comment=T('Please enter a review for the submission, or explain why you are unable to review it (at least 16 characters).')),
        hidden=dict(order='', grades='')
        )
    form.vars.comments = sub_info[t.submission_id]['comm']
    form.vars.unable_to_evaluate = t.rejected

    if form.process(onvalidation=verify_rating_form(t.submission_id)).accepted:
        # Updates the submission id to nicknames mapping.
        subm = db.submission(t.submission_id)
        subm_id_to_nickname[str(subm.id)] = util.produce_submission_nickname(subm)
        for subm_id in form.vars.order:
            if str(subm_id) not in subm_id_to_nickname:
                # We need the author of the submission.
                subm_id_to_nickname[str(subm_id)] = util.produce_submission_nickname(db.submission(subm_id))
        subm_id_to_nickname_str = simplejson.dumps(subm_id_to_nickname)
        
        # Stores a new comparison, erasing any previous one.
        db.comparison.update_or_insert(
            ((db.comparison.venue_id == t.venue_id) & (db.comparison.user == get_user_email())),
            venue_id = t.venue_id, user = get_user_email(), 
            ordering = form.vars.order, grades = form.vars.grades,
            submission_nicknames = subm_id_to_nickname_str)
        
        # Stores a historical record of the comparison.
        db.comparison_history.insert(
Ejemplo n.º 6
0
def anonimize_all_venues():
    name_dict = {}
    def get_new_name(n):
        if n == '*****@*****.**' or n == '*****@*****.**':
            return n
        if n in name_dict:
            return name_dict[n]
        else:
            while True:
                m = util.get_random_id(n_sections=1) + '@example.com'
                if m not in name_dict:
                    break
            name_dict[n] = m
            return m

    if not is_user_admin():
        session.flash = T('Not authorized')
        redirect(URL('default', 'index'))
    form = FORM.confirm(T('This will anonymize all venues; the original data WILL BE LOST.'))
    if form.accepted:
        # Builds a dictionary for anonymization.
        new_names = {}
        # Convert user lists.
        rows = db().select(db.user_list.ALL)
        for ul in rows:
            ul.update_record(managers = [get_new_name(x) for x in ul.managers],
                             user_list = [get_new_name(x) for x in ul.user_list])
        # Convert venues.
        rows = db().select(db.venue.ALL)
        for r in rows:
            r.update_record(created_by = get_new_name(r.created_by),
                            managers = [get_new_name(x) for x in r.managers],
                            observers = [get_new_name(x) for x in r.observers])
        # Convert submissions.
        rows = db().select(db.submission.ALL)
        for r in rows:
            r.update_record(user = get_new_name(r.user),
                            title = util.get_random_id(n_sections=1),
                            )
        db.commit()
        # Convert comparisons.
        rows = db().select(db.comparison.ALL)
        for r in rows:
            # Creates a new nickname dictionary.
            nicks = {}
            for subm_id in r.ordering:
                s = db.submission(subm_id)
                if s is not None:
                    nicks[subm_id] = util.produce_submission_nickname(s)
            r.update_record(user = get_new_name(r.user),
                            submission_nicknames = simplejson.dumps(nicks))
        # Converts tasks.
        rows = db().select(db.task.ALL)
        for r in rows:
            r.update_record(user = get_new_name(r.user))
        # Converts final grades.
        rows = db().select(db.grades.ALL)
        for r in rows:
            r.update_record(user = get_new_name(r.user))
        db.commit()

        # Now for the hard part: the system tables.
        rows = db().select(db.auth_user.ALL)
        for r in rows:
            u = get_new_name(r.email)
            r.update_record(first_name = u,
                            last_name = u,
                            email = u,
                            password = db.auth_user.password.requires[0]('hello')[0])
        db.commit()
        
        session.flash = T('done')
        redirect(URL('default', 'index'))
    return dict(form=form)