Exemple #1
0
def task_update_api():
	"""

	"""
	spec_list = [
		{'task_id': {
			'kind' : int,
			'permission': 'task'				
			}
		},
		{'task_ids': {
			'kind': list,
			'permission': 'task',
			'required': False
		}
		},
		{'mode': {
			'kind' : str,
			'valid_values_list': ['toggle_deferred']
			}
		},
		{'status': {
			'kind': str,
			'valid_values_list': ['archived']
		}
		}
	]

	log, input, untrusted_input = regular_input.master(request=request,
													   spec_list=spec_list)
	if len(log["error"].keys()) >= 1:
		return jsonify(log=log), 400

	with sessionMaker.session_scope() as session:
		task_list = []
		if input['task_id']:
			task = Task.get_by_id(session = session,
								 task_id = input['task_id'])
			task_list.append(task)
		else:
			task_list = Task.list(
				session=session,
				task_ids=input['task_ids']
			)
		for task in task_list:
			Permission_Task.by_task_id_core(task.id)
			task_update = Task_Update(
							session = session,
							task = task,
							mode = input['mode'],
							status= input['status'])

			task_update.main()

		if len(task_update.log["error"].keys()) >= 1:
			return jsonify( log = task_update.log), 400

		return jsonify( log = task_update.log), 200
def valid_review_task_for_user(session,
							   task,
							   user):

	parent = Task.get_by_id(session, task.parent_id)
	# task.parent not working for some reason

	if parent:
		if user == parent.assignee_user:
			return False
	
	return True
Exemple #3
0
def task_by_id_core(session,
					task_id,
					input):

	task = Task.get_by_id(session = session,
							 task_id = task_id)

	if input['builder_or_trainer_mode'] == "builder":
		task_serialized = task.serialize_builder_view_by_id(session)

	if input['builder_or_trainer_mode'] == "trainer":
		# TODO
		task_serialized = task.serialize_trainer_annotate(session)

	return task_serialized
Exemple #4
0
 def __generate_payload_for_task(self, session, start_time=None):
     tasks = []
     task = Task.get_by_id(session=session,
                           task_id=self.notification_relation.task_id)
     if task:
         tasks.append(task)
     time_column = Task.time_created
     if self.type == 'task_completed':
         time_column = Task.time_completed
     if start_time:
         tasks = session.query(Task).filter(
             Task.project_id == self.notification_relation.task.project_id,
             time_column <= datetime.datetime.utcnow(),
             time_column >= start_time).all()
     payload = [
         task.serialize_builder_view_by_id(session=session)
         for task in tasks
     ]
     return payload
Exemple #5
0
def get_video_image_list(project_string_id, task_id, video_parent_file_id):

    spec_list = [{"frame_list": {'kind': list, 'required': True}}]

    log, input, untrusted_input = regular_input.master(request=request,
                                                       spec_list=spec_list)
    if len(log["error"].keys()) >= 1:
        return jsonify(log=log), 400

    with sessionMaker.session_scope() as session:

        # A little security measure
        if len(input['frame_list']) > 100:
            return jsonify("Max 100 frames at a time"), 400

        if task_id != -1:
            task = Task.get_by_id(session=session, task_id=task_id)

            if task.file is None:
                return jsonify("Task has no video file associated."), 400
            else:
                video_file = task.file

        else:
            project = Project.get(session, project_string_id)

            video_file = File.get_by_id_and_project(
                session=session,
                project_id=project.id,
                file_id=video_parent_file_id,
                directory_id=project.directory_default_id  # migration
            )

            if video_file is None:
                return jsonify("bad video_parent_file_id id"), 400

        return get_url_for_frame_list_response(session=session,
                                               video_file=video_file,
                                               frame_list=input['frame_list'])