def studio_scheduling_mode(request):
"""Sets the system to "in schedule" mode or "normal" mode. When the system
is "in schedule" mode (Studio.is_scheduling == True) it is not allowed to
schedule the system again until the previous one is finishes.
"""
logged_in_user = get_logged_in_user(request)
# get the studio
studio = Studio.query.first()
mode = request.params.get('mode')
logger.debug('schedule mode: %s' % mode)
if not studio:
transaction.abort()
return Response("There is no Studio instance\n"
"Please create a studio first", 500)
if mode: # set the mode
mode = bool(int(mode))
studio.is_scheduling = mode
studio.is_scheduling_by = logged_in_user
studio.scheduling_started_at = local_to_utc(datetime.datetime.now())
return Response(
"Successfully, set the scheduling mode to: %s" % mode
)
评论列表
文章目录