本文整理汇总了Python中models.Submission.ava_clone方法的典型用法代码示例。如果您正苦于以下问题:Python Submission.ava_clone方法的具体用法?Python Submission.ava_clone怎么用?Python Submission.ava_clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Submission
的用法示例。
在下文中一共展示了Submission.ava_clone方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post_queue_copytoava
# 需要导入模块: from models import Submission [as 别名]
# 或者: from models.Submission import ava_clone [as 别名]
def post_queue_copytoava():
if (not request.json) or (not 'queueId' in request.json):
abort(400)
if (not 'avaQueueId' in request.json):
abort(400)
q_id = int(request.json['queueId'])
aq_id = int(request.json['avaQueueId'])
# Get the queue information
queue = Queue.query.filter(Queue.id == q_id).first()
ava_queue = Queue.query.filter(Queue.id == aq_id).first()
if not queue:
abort(404)
if not ava_queue:
abort(404)
# Check if queue is a scheduled queue
if queue.qType != 2:
abort(403)
if ava_queue.qType != 1:
abort(403)
# Submit to queue using normal submission function
subs = queue.submissions
subs_to_remove = ava_queue.submissions
for sub in subs_to_remove:
db.session.delete(sub)
db.session.commit()
ava_subs = []
for sub in subs:
ava_sub = Submission()
ava_sub.ava_clone(sub, ava_queue)
db.session.add(ava_sub)
ava_subs.append(ava_sub)
db.session.commit()
# Create match to be scheduled
for p, q in itertools.combinations(ava_subs,2):
match = schedule_match(ava_queue, p, q, test=False)
return jsonify({'done': True}), 201