本文整理汇总了Python中util.get_list函数的典型用法代码示例。如果您正苦于以下问题:Python get_list函数的具体用法?Python get_list怎么用?Python get_list使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_list函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: submit
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)
开发者ID:erikaeriga,项目名称:crowdranker,代码行数:60,代码来源:submission.py
示例2: review
def review():
"""Enters the review, and comparisons, for a particular task.
This function is only used to enter NEW reviews."""
# Here is where the comparisons are entered.
t = db.task(request.args(0)) or redirect(URL('default', 'index'))
if t.user != auth.user.email:
session.flash = T('Invalid request.')
redirect(URL('default', 'index'))
# Check that the venue rating deadline is currently open, or that the ranker
# is a manager or observer.
venue = db.venue(t.venue_id)
if ((auth.user.email not in util.get_list(venue.managers)) and
(auth.user.email not in util.get_list(venue.observers)) and
(datetime.utcnow() < venue.rate_open_date or datetime.utcnow() > venue.rate_close_date)):
session.flash = T('The review deadline for this venue is closed.')
redirect(URL('venues', 'view_venue', args=[venue.id]))
# Ok, the task belongs to the user.
# Gets the last reviewing task done for the same venue.
last_comparison = db((db.comparison.user == auth.user.email)
& (db.comparison.venue_id == t.venue_id)).select(orderby=~db.comparison.date).first()
if last_comparison == None:
last_ordering = []
subm_id_to_nickname = {}
else:
last_ordering = util.get_list(last_comparison.ordering)
try:
subm_id_to_nickname = simplejson.loads(last_comparison.submission_nicknames)
except Exception, e:
logger.warning("Failed to decode submission_nicknames: " +
str(last_comparison.submission_nicknames))
subm_id_to_nickname = {}
开发者ID:tilgovi,项目名称:crowdranker,代码行数:34,代码来源:rating.py
示例3: observed_index
def observed_index():
props = db(db.user_properties.user == auth.user.email).select().first()
if props == None:
l = []
else:
l = util.id_list(util.get_list(props.venues_can_observe))
l1 = util.id_list(util.get_list(props.venues_can_manage))
for el in l1:
if el not in l:
l.append(el)
if len(l) > 0:
q = db.venue.id.belongs(l) & (db.venue.is_approved == True)
else:
q = db.venue.id == -1
db.venue.number_of_submissions_per_reviewer.readable = True
db.venue.grading_instructions.readable = True
db.venue.is_approved.readable = True
grid = SQLFORM.grid(
q,
field_id=db.venue.id,
fields=[db.venue.name, db.venue.close_date, db.venue.rate_close_date],
csv=False,
details=True,
create=False,
editable=False,
deletable=False,
)
return dict(grid=grid)
开发者ID:pombredanne,项目名称:crowdranker,代码行数:28,代码来源:venues.py
示例4: edit_ordering
def edit_ordering():
""" Edit last ordering."""
# Gets the information on the venue and comparison.
venue = db.venue(request.args[0]) or redirect(URL('default', 'index'))
last_comparison = db.comparison(request.args[1]) or redirect(URL('default', 'index'))
if last_comparison.author != auth.user_id:
session.flash = T('Invalid request.')
redirect(URL('default', 'index'))
# Check that the venue rating deadline is currently open, or that the ranker
# is a manager or observer.
if ((auth.user.email not in util.get_list(venue.managers)) and
(auth.user.email not in util.get_list(venue.observers)) and
(datetime.utcnow() < venue.rate_open_date or datetime.utcnow() > venue.rate_close_date)):
session.flash = T('The review deadline for this venue is closed.')
redirect(URL('venues', 'view_venue', args=[venue.id]))
# Ok, the task belongs to the user.
# Gets the last reviewing task done for the same venue.
if last_comparison == None:
last_ordering = []
else:
last_ordering = util.get_list(last_comparison.ordering)
# Finds the grades that were given for the submissions previously reviewed.
if last_comparison == None or last_comparison.grades == None:
str_grades = {}
else:
try:
str_grades = simplejson.loads(last_comparison.grades)
except Exception, e:
str_grades = {}
logger.warning("Grades cannot be read: " + str(last_comparison.grades))
开发者ID:mdipierro,项目名称:crowdranker,代码行数:33,代码来源:rating.py
示例5: download_viewer
def download_viewer():
"""This method allows the download of a submission by someone who has access to
all the submissions of the venue. We need to do all access control here."""
subm = db.submission(request.args(0)) or redirect(URL('default', 'index'))
c = db.venue(subm.venue_id) or redirect(URL('default', 'index'))
# Does the user have access to the venue submissions?
# TODO(luca): factor this in a permission module.
props = db(db.user_properties.email == auth.user.email).select().first()
can_manage = c.id in util.get_list(props.venues_can_manage)
can_observe = c.id in util.get_list(props.venues_can_observe)
can_view_ratings = can_manage or c.rating_available_to_all or can_observe
if not can_view_ratings:
session.flash(T('Not authorized.'))
redirect(URL('default', 'index'))
# Creates an appropriate file name for the submission.
original_ext = subm.original_filename.split('.')[-1]
filename = subm.email or 'anonymous'
if subm.title != None and len(subm.title) > 0:
filename += '_' + subm.title
else:
filename += '_' + subm.identifier
filename += '.' + original_ext
# Allows the download.
# TODO(luca): The next line should be useless.
request.args = request.args[1:]
return my_download(request, db, filename)
开发者ID:erikaeriga,项目名称:crowdranker,代码行数:26,代码来源:submission.py
示例6: can_observe
def can_observe(venue, props):
if current.is_user_admin():
return True
if props is None:
return False
can_manage = venue.is_active and venue.id in util.get_list(props.venues_can_manage)
can_observe = venue.is_approved and venue.is_active and venue.id in util.get_list(props.venues_can_observe)
return can_manage or can_observe
开发者ID:lawrancej,项目名称:crowdranker,代码行数:8,代码来源:access.py
示例7: write_to_db_for_rep_sys
def write_to_db_for_rep_sys(db, venue_id, rankobj_result, subm_l, user_l,
ordering_d, accuracy_d, rep_d, perc_final_d,
final_grade_d, subm_d, ranking_algo_description):
# Gets the users that participate in the class.
c = db.venue(venue_id)
ul = []
r = db.user_list(c.submit_constraint)
if r is not None:
ul = util.get_list(r.user_list)
if not c.raters_equal_submitters:
ulr = []
r = db.user_list(c.rate_constraint)
if r is not None:
ulr = util.get_list(r.user_list)
ul = util.union_list(ul, ulr)
if len(ul) == 0:
# Nothing to write.
db(db.grades.venue_id == venue_id).delete()
db.commit()
return
# Writes the grades for each user.
for u in ul:
# Write to the submission.
subm_id = subm_d.get(u)
if subm_id is not None:
perc, avrg, stdev = rankobj_result[subm_id]
db(db.submission.id == subm_id).update(quality=avrg, error=stdev, percentile=perc)
submission_percentile = perc
else:
submission_percentile = None
# Write the grade.
if ordering_d.has_key(u):
n_ratings = len(ordering_d[u])
else:
n_ratings = 0
db.grades.update_or_insert((db.grades.venue_id == venue_id) &
(db.grades.user == u),
venue_id = venue_id,
user = u,
submission_percentile = submission_percentile,
accuracy = accuracy_d.get(u),
reputation = rep_d.get(u),
n_ratings = n_ratings,
percentile = perc_final_d.get(u),)
# Saving evaluation date.
t = datetime.utcnow()
db(db.venue.id == venue_id).update(latest_grades_date = t,
ranking_algo_description = ranking_algo_description)
db.commit()
开发者ID:pombredanne,项目名称:crowdranker,代码行数:54,代码来源:ranker.py
示例8: can_view_submissions
def can_view_submissions(venue, props):
can_manage = venue.id in util.get_list(props.venues_can_manage)
can_observe = venue.id in util.get_list(props.venues_can_observe)
if can_manage or can_observe:
return True
if venue.submissions_visible_to_all:
if venue.submissions_visible_immediately:
return True
else:
return venue.close_date > datetime.utcnow()
else:
return False
开发者ID:erikaeriga,项目名称:crowdranker,代码行数:12,代码来源:access.py
示例9: can_view_feedback
def can_view_feedback(venue, props):
can_manage = venue.id in util.get_list(props.venues_can_manage)
can_observe = venue.id in util.get_list(props.venues_can_observe)
if can_manage or can_observe:
return True
if venue.feedback_available_to_all:
if venue.feedback_accessible_immediately:
return True
else:
return venue.rate_close_date > datetime.utcnow()
else:
return False
开发者ID:erikaeriga,项目名称:crowdranker,代码行数:12,代码来源:access.py
示例10: rerun_processing_comparisons
def rerun_processing_comparisons(db, venue_id, alpha_annealing=0.5, run_twice=False):
# We reset the ranking to the initial values.
# Gets a ranker object to do the ranking, initialized with all the submissions with
# their default stdev and avg.
sub = db(db.submission.venue_id == venue_id).select(db.submission.id)
items = []
qdistr_param = []
for x in sub:
items.append(x.id)
qdistr_param.append(AVRG)
qdistr_param.append(STDEV)
rankobj = Rank.from_qdistr_param(items, qdistr_param, alpha=alpha_annealing)
# Processes the list of comparisons.
result = None
comparison_list = db(db.comparison.venue_id == venue_id).select(orderby=db.comparison.date)
for comp in comparison_list:
# Processes the comparison, if valid.
if comp.is_valid is None or comp.is_valid == True:
# Reverses the list.
sorted_items = util.get_list(comp.ordering)[::-1]
if len(sorted_items) < 2:
continue
result = rankobj.update(sorted_items, new_item=comp.new_item)
if run_twice:
comparison_list = db(db.comparison.venue_id == venue_id).select(orderby=~db.comparison.date)
for comp in comparison_list:
# Processes the comparison, if valid.
if comp.is_valid is None or comp.is_valid == True:
# Reverses the list.
sorted_items = util.get_list(comp.ordering)[::-1]
if len(sorted_items) < 2:
continue
result = rankobj.update(sorted_items, new_item=comp.new_item)
# Writes the updated statistics to the db. Note that result contains the result for
# all the ids, due to how the rankobj has been initialized.
if result is None:
return
for x in items:
perc, avrg, stdev = result[x]
db((db.submission.id == x) &
(db.submission.venue_id == venue_id)).update(quality=avrg, error=stdev, percentile=perc)
# Saving the latest rank update date.
description = "Ranking without reputation system. All comparisons are used in chronological order"
db(db.venue.id == venue_id).update(latest_rank_update_date = datetime.utcnow(),
ranking_algo_description = description)
开发者ID:tilgovi,项目名称:crowdranker,代码行数:48,代码来源:ranker.py
示例11: read_db_for_rep_sys
def read_db_for_rep_sys(db, venue_id):
# Containers to fill.
# Lists have l suffix, dictionaries user -> val have d suffix.
user_l = [] # This list contains submitters and reviewers.
subm_l = []
subm_d = {}
ordering_l = []
ordering_d = {}
# Reading submission table.
rows = db(db.submission.venue_id == venue_id).select()
for r in rows:
subm_l.append(r.id)
subm_d[r.user] = r.id
user_l.append(r.user)
# Reading comparisons table.
rows = db((db.comparison.venue_id == venue_id) & (db.comparison.is_valid == True)).select()
for r in rows:
# Reverses the ordering.
sorted_items = util.get_list(r.ordering)[::-1]
if len(sorted_items) < 2:
continue
ordering_d[r.user] = sorted_items
# Initializing reviewers reputation and accuracy.
ordering_l.append((sorted_items, r.user))
# Adding reviewers to user_l.
for user in ordering_d.iterkeys():
if user not in user_l:
user_l.append(user)
return user_l, subm_l, ordering_l, subm_d, ordering_d
开发者ID:pombredanne,项目名称:crowdranker,代码行数:30,代码来源:ranker.py
示例12: reviewed_index
def reviewed_index():
props = db(db.user_properties.user == auth.user.email).select(db.user_properties.venues_has_rated).first()
if props == None:
l = []
else:
l = util.id_list(util.get_list(props.venues_has_rated))
if len(l) > 0:
q = db.venue.id.belongs(l) & (db.venue.is_approved == True)
else:
q = db.venue.id == -1
db.venue.rate_close_date.readable = True
db.venue.close_date.readable = True
db.venue.name.label = T("Venue")
grid = SQLFORM.grid(
q,
field_id=db.venue.id,
fields=[db.venue.name, db.venue.close_date, db.venue.rate_close_date],
csv=False,
details=False,
create=False,
editable=False,
deletable=False,
links=[
dict(
header="Review feedback",
body=lambda r: A(
T("Read feedback"), _class="btn", _href=URL("feedback", "view_feedback", args=["v", r.id])
),
)
],
)
return dict(grid=grid)
开发者ID:pombredanne,项目名称:crowdranker,代码行数:32,代码来源:venues.py
示例13: submitted_index
def submitted_index():
props = db(db.user_properties.email == auth.user.email).select(db.user_properties.venues_has_submitted).first()
if props == None:
l = []
else:
l = util.id_list(util.get_list(props.venues_has_submitted))
if len(l) > 0:
q = (db.venue.id.belongs(l))
else:
q = (db.venue.id == -1)
db.venue.feedback_accessible_immediately.readable = False
db.venue.rate_open_date.readable = False
db.venue.rate_close_date.readable = False
db.venue.name.readable = False
grid = SQLFORM.grid(q,
field_id=db.venue.id,
fields=[db.venue.name, db.venue.rate_open_date, db.venue.rate_close_date, db.venue.feedback_accessible_immediately],
csv=False, details=False, create=False, editable=False, deletable=False,
links=[
dict(header=T('Venue'),
body = lambda r: A(r.name, _href=URL('view_venue', args=[r.id]))),
dict(header='Feedback', body = lambda r: link_feedback(r)),
dict(header='My submissions', body = lambda r:
A(T('My submissions'),
_class='btn',
_href=URL('submission', 'my_submissions_index', args=[r.id]))),
],
)
return dict(grid=grid)
开发者ID:erikaeriga,项目名称:crowdranker,代码行数:29,代码来源:venues.py
示例14: can_manage
def can_manage(venue, props):
if current.is_user_admin():
return True
if props is None:
return False
can_manage = venue.id in util.get_list(props.venues_can_manage)
return can_manage
开发者ID:lawrancej,项目名称:crowdranker,代码行数:7,代码来源:access.py
示例15: preprocess_for_publish
def preprocess_for_publish(self, obj):
"""Preprocess an object before trying to publish it.
By default this tries to massage person tags so that the tag's
"url" points to the person's profile on this service (as opposed
to a person's homepage).
The object is modified in place.
Args:
obj: ActivityStreams activity or object dict
"""
for tag in obj.get('tags', []):
if tag.get('objectType') == 'person':
silo_url = None
for url in microformats2.object_urls(tag):
silo_url = url and self.infer_profile_url(url)
if silo_url:
break
if silo_url:
tag['url'] = silo_url
# recurse on contained object(s)
for obj in util.get_list(obj, 'object'):
self.preprocess_for_publish(obj)
开发者ID:chrisaldrich,项目名称:bridgy,代码行数:25,代码来源:models.py
示例16: review
def review():
"""Enters the review, and comparisons, for a particular task.
This also allows to decline a review.
This can be used both for old, and new, reviews.
The function is accessed by task id."""
t = db.task(request.args(0)) or redirect(URL('default', 'index'))
if t.user != get_user_email():
session.flash = T('Invalid request.')
redirect(URL('default', 'index'))
props = db(db.user_properties.user == get_user_email()).select().first()
# Check that the venue rating deadline is currently open, or that the ranker
# is a manager or observer.
venue = db.venue(t.venue_id)
if ((not access.can_observe(venue, props)) and
(datetime.utcnow() < venue.rate_open_date or datetime.utcnow() > venue.rate_close_date)):
session.flash = T('Reviewing for this venue is closed.')
redirect(URL('venues', 'view_venue', args=[venue.id]))
# Ok, the task belongs to the user.
# Gets the valid comparison for the venue, so we can read the grades.
last_comparison = db((db.comparison.user == get_user_email())
& (db.comparison.venue_id == t.venue_id) & (db.comparison.is_valid == True)).select().first()
if last_comparison == None:
last_ordering = []
subm_id_to_nickname = {}
else:
last_ordering = util.get_list(last_comparison.ordering)
try:
subm_id_to_nickname = simplejson.loads(last_comparison.submission_nicknames)
except Exception, e:
logger.warning("Failed to decode submission_nicknames: " +
str(last_comparison.submission_nicknames))
subm_id_to_nickname = {}
开发者ID:lawrancej,项目名称:crowdranker,代码行数:35,代码来源:rating.py
示例17: review_index
def review_index():
def get_venue_review_link(r):
tt = datetime.utcnow()
if tt >= r.rate_open_date and tt <= r.rate_close_date:
return A(T('View/edit your reviews'), _class='btn',
_href=URL('rating', 'edit_reviews', args=[r.id], user_signature=True))
else:
return A(T('View reviews and feedback'), _class='btn',
_href=URL('feedback', 'view_my_reviews', args=[r.id]))
props = db(db.user_properties.user == get_user_email()).select().first()
if props is None:
q = (db.venue.id == -1)
else:
venue_list = util.get_list(props.venues_has_rated)
q = (db.venue.id.belongs(venue_list))
db.venue.name.label = T('Assignment')
db.venue.rate_open_date.readable = db.venue.rate_close_date.readable = False
grid = SQLFORM.grid(q,
field_id = db.venue.id,
fields = [db.venue.name, db.venue.rate_open_date, db.venue.rate_close_date],
create=False, details=False,
csv=False, editable=False, deletable=False,
links=[dict(header=T(''), body = lambda r: get_venue_review_link(r)),
],
)
return dict(grid=grid)
开发者ID:lawrancej,项目名称:crowdranker,代码行数:27,代码来源:rating.py
示例18: submitted_index
def submitted_index():
props = db(db.user_properties.user == auth.user.email).select(db.user_properties.venues_has_submitted).first()
if props == None:
l = []
else:
l = util.id_list(util.get_list(props.venues_has_submitted))
if len(l) > 0:
q = db.venue.id.belongs(l) & (db.venue.is_approved == True)
else:
q = db.venue.id == -1
db.venue.rate_close_date.readable = True
db.venue.close_date.readable = True
db.venue.allow_multiple_submissions.readable = False
db.venue.name.label = T("Venue")
grid = SQLFORM.grid(
q,
field_id=db.venue.id,
fields=[db.venue.name, db.venue.close_date, db.venue.rate_close_date, db.venue.allow_multiple_submissions],
csv=False,
details=False,
create=False,
editable=False,
deletable=False,
links=[dict(header="Actions", body=submission_feedback_link)],
)
return dict(grid=grid)
开发者ID:pombredanne,项目名称:crowdranker,代码行数:26,代码来源:venues.py
示例19: reviewing_duties
def reviewing_duties():
"""This function lists venues where users have reviews to accept, so that users
can be redirected to a page where to perform such reviews."""
# Produces a list of venues that are open for rating.
props = db(db.user_properties.user == get_user_email()).select(db.user_properties.venues_can_rate).first()
if props == None:
l = []
else:
l = util.get_list(props.venues_can_rate)
t = datetime.utcnow()
if len(l) == 0:
q = (db.venue.id == -1)
else:
q = ((db.venue.rate_open_date < t) & (db.venue.rate_close_date > t)
& (db.venue.is_active == True) & (db.venue.id.belongs(l)))
db.venue.rate_close_date.label = T('Review deadline')
db.venue.number_of_submissions_per_reviewer.label = T('Total n. of reviews')
grid = SQLFORM.grid(q,
field_id=db.venue.id,
fields=[db.venue.name, db.venue.rate_open_date, db.venue.rate_close_date,
db.venue.number_of_submissions_per_reviewer],
csv=False, details=False, create=False, editable=False, deletable=False,
links=[
dict(header=T('N. reviews still to do'), body = lambda r: get_num_reviews_todo(r)),
dict(header='Accept', body = lambda r: review_link(r)),
],
maxtextlength=24,
)
return dict(grid=grid)
开发者ID:lawrancej,项目名称:crowdranker,代码行数:29,代码来源:venues.py
示例20: rateopen_index
def rateopen_index():
# TODO(luca): see if I can put an inline form for accepting review tasks.
props = db(db.user_properties.user == auth.user.email).select().first()
if props == None:
l = []
else:
l = util.get_list(props.venues_can_rate)
t = datetime.utcnow()
if len(l) == 0:
q = db.venue.id == -1
else:
q = (
(db.venue.rate_open_date < t)
& (db.venue.rate_close_date > t)
& (db.venue.is_active == True)
& (db.venue.is_approved == True)
& (db.venue.id.belongs(l))
)
db.venue.rate_close_date.label = T("Review deadline")
grid = SQLFORM.grid(
q,
field_id=db.venue.id,
fields=[db.venue.name, db.venue.rate_open_date, db.venue.rate_close_date],
csv=False,
details=False,
create=False,
editable=False,
deletable=False,
links=[dict(header=T("Review"), body=lambda r: review_link(r))],
)
return dict(grid=grid)
开发者ID:pombredanne,项目名称:crowdranker,代码行数:31,代码来源:venues.py
注:本文中的util.get_list函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论