本文整理匯總了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