Example #1
0
def create_recording_feedback_entry(recording):
	data = MyForm(
		Field('comment', validators=[
			validators.is_string,
		]),
		Field('flags', validators=[
			validators.is_list,
			RecordingFlag.check_all_exists,
		]),
		Field('changeMethod', is_mandatory=True, validators=[
			AudioCheckingChangeMethod.is_valid,
		]),
	).get_data()

	change_method = AudioCheckingChangeMethod.from_name(data["changeMethod"])
	flags = RecordingFlag.get_list(*data.get('flags', []))

	entry = RecordingFeedbackEntry(
		recording=recording,
		user=session["current_user"],
		change_method=change_method,
		comment=data.get("comment"),
	)
	db.session.add(entry)
	db.session.flush()
	entry.add_flags(flags)
	db.session.commit()
	return jsonify(entry=RecordingFeedbackEntry.dump(entry))
Example #2
0
	def put(self, performance_meta_category):

		data = MyForm(
			Field('name', is_mandatory=True,
				validators=[
					performance_meta_category.check_other_name_unique,
			]),
			Field('extractor', is_mandatory=True,
				normalizer=PerformanceMetaCategory.normalize_extractor,
				validators=[
					performance_meta_category.recording_platform.check_extractor
				]
			),
			Field('validatorSpec', is_mandatory=True,
				validators=[
					PerformanceMetaCategory.check_validator
				]
			),
		).get_data()

		performance_meta_category.name = data["name"]
		performance_meta_category.extractor = data.get("extractor")
		performance_meta_category.validator_spec = data["validatorSpec"]
		db.session.flush()
		return {"metaCategory": PerformanceMetaCategory.dump(performance_meta_category)}
Example #3
0
	def post(self, recording_platform):

		data = MyForm(
			Field('name', is_mandatory=True,
				validators=[
					(PerformanceMetaCategory.check_name_unique, (recording_platform,)),
			]),
			Field('extractor', is_mandatory=True,
				normalizer=PerformanceMetaCategory.normalize_extractor,
				validators=[
					recording_platform.check_extractor,
				]
			),
			Field('validatorSpec', is_mandatory=True,
				validators=[
					PerformanceMetaCategory.check_validator,
				]
			),
		).get_data()

		performance_meta_category = PerformanceMetaCategory(
			recording_platform=recording_platform,
			name=data["name"],
			extractor=data.get("extractor"),
			validator_spec=data["validatorSpec"],
		)

		db.session.add(performance_meta_category)
		db.session.commit()
		return {"metaCategory": performance_meta_category.serialize()}
Example #4
0
def create_performance_feedback_entry(performance):
    data = MyForm(
        Field('comment', validators=[
            validators.is_string,
        ]),
        Field('flags',
              validators=[
                  validators.is_list,
                  PerformanceFlag.check_all_exists,
              ]),
        Field('changeMethod',
              is_mandatory=True,
              validators=[
                  AudioCheckingChangeMethod.is_valid,
              ]),
    ).get_data()

    entry = performance.add_feedback(session["current_user"],
                                     data["changeMethod"], data.get("comment"),
                                     data.get("flags", []))
    db.session.commit()

    return jsonify(entry=PerformanceFeedbackEntry.dump(entry))
Example #5
0
def update_corpus_code(corpus_code):

    data = MyForm(
        Field("code",
              is_mandatory=True,
              validators=[
                  corpus_code.check_updated_code_unique,
              ]),
        Field("regex"),
        Field("isScripted", is_mandatory=True,
              validators=[validators.is_bool]),
    ).get_data()

    corpus_code.code = data.get("code")
    corpus_code.regex = data["regex"]
    corpus_code.is_scripted = data["isScripted"]
    db.session.commit()

    return jsonify({"corpusCode": CorpusCode.dump(corpus_code)})
    def get(self, task):

        if not task.is_type(TaskType.TRANSCRIPTION, TaskType.AUDIO_CHECKING):
            raise InvalidUsage(
                "audio uploads are only available for audio tasks", 400)

        data = MyForm(
            Field("visibleOnly",
                  normalizer=normalizers.to_json,
                  validators=[
                      validators.is_bool,
                  ])).get_data(is_json=False, use_args=True)

        query = AudioUpload.query.filter_by(task=task)

        if data.get("visibleOnly"):
            query = query.filter_by(hidden=False)

        audio_uploads = query.all()
        return {"audioUploads": AudioUpload.dump(audio_uploads)}
    def post(self, recording_platform):

        data = MyForm(
            Field("code",
                  default="",
                  validators=[
                      CorpusCode.check_new_code_unique(recording_platform)
                  ]),
            Field("regex"),
            Field("isScripted",
                  is_mandatory=True,
                  validators=[validators.is_bool]),
        ).get_data()

        corpus_code = CorpusCode(
            recording_platform=recording_platform,
            code=data["code"],
            regex=data.get("regex"),
            is_scripted=data["isScripted"],
        )

        db.session.add(corpus_code)
        db.session.flush()
        return {"corpusCode": CorpusCode.dump(corpus_code)}