def delete(self, id): """Delete an existing collection and return it. :URL: ``DELETE /collections/id`` :param str id: the ``id`` value of the collection to be deleted. :returns: the deleted collection model. .. note:: Only administrators and a collection's enterer can delete it. """ collection = h.eagerload_collection(Session.query(Collection), eagerload_forms=True).get(id) if collection: if session['user'].role == u'administrator' or \ collection.enterer is session['user']: session['user'] = Session.merge(session['user']) collection.modifier = session['user'] collection_dict = collection.get_full_dict() backup_collection(collection_dict) update_collections_that_reference_this_collection(collection, self.query_builder, deleted=True) Session.delete(collection) Session.commit() return collection_dict else: response.status_int = 403 return h.unauthorized_msg else: response.status_int = 404 return {'error': 'There is no collection with id %s' % id}
def delete(self, id): """Delete an existing orthography and return it. :URL: ``DELETE /orthographies/id`` :param str id: the ``id`` value of the orthography to be deleted. :returns: the deleted orthography model. .. note:: Contributors can only delete orthographies that are not used in the active application settings. """ orthography = Session.query(Orthography).get(id) if orthography: app_set = h.get_application_settings() if session['user'].role == u'administrator' or orthography not in ( app_set.storage_orthography, app_set.input_orthography, app_set.output_orthography): Session.delete(orthography) Session.commit() return orthography else: response.status = 403 return {'error': u'Only administrators are permitted to delete orthographies that are used in the active application settings.'} else: response.status_int = 404 return {'error': 'There is no orthography with id %s' % id}
def delete(self, id): """Delete an existing speaker and return it. :URL: ``DELETE /speakers/id`` :param str id: the ``id`` value of the speaker to be deleted. :returns: the deleted speaker model. """ speaker = Session.query(Speaker).get(id) if speaker: Session.delete(speaker) Session.commit() return speaker else: response.status_int = 404 return {'error': 'There is no speaker with id %s' % id}
def delete(self, id): """Delete an existing source and return it. :URL: ``DELETE /sources/id`` :param str id: the ``id`` value of the source to be deleted. :returns: the deleted source model. """ source = Session.query(Source).get(id) if source: Session.delete(source) Session.commit() return source else: response.status_int = 404 return {'error': 'There is no source with id %s' % id}
def delete(self, id): """Delete an existing elicitation method and return it. :URL: ``DELETE /elicitationmethods/id`` :param str id: the ``id`` value of the elicitation method to be deleted. :returns: the deleted elicitation method model. """ elicitation_method = Session.query(ElicitationMethod).get(id) if elicitation_method: Session.delete(elicitation_method) Session.commit() return elicitation_method else: response.status_int = 404 return {'error': 'There is no elicitation method with id %s' % id}
def delete(self, id): """Delete an existing keyboard and return it. :URL: ``DELETE /keyboards/id`` :param str id: the ``id`` value of the keyboard to be deleted. :returns: the deleted keyboard model. """ keyboard = Session.query(Keyboard).get(id) if keyboard: Session.delete(keyboard) Session.commit() return keyboard else: response.status_int = 404 return {'error': 'There is no keyboard with id %s' % id}
def delete(self, id): """Delete an existing page and return it. :URL: ``DELETE /pages/id`` :param str id: the ``id`` value of the page to be deleted. :returns: the deleted page model. """ page = Session.query(Page).get(id) if page: Session.delete(page) Session.commit() return page else: response.status_int = 404 return {'error': 'There is no page with id %s' % id}
def delete(self, id): """Delete an existing form search and return it. :URL: ``DELETE /formsearches/id`` :param str id: the ``id`` value of the form search to be deleted. :returns: the deleted form search model. """ form_search = h.eagerload_form_search(Session.query(FormSearch)).get(id) if form_search: Session.delete(form_search) Session.commit() return form_search else: response.status_int = 404 return {'error': 'There is no form search with id %s' % id}
def delete(self, id): """Delete an existing syntactic category and return it. :URL: ``DELETE /syntacticcategorys/id`` :param str id: the ``id`` value of the syntactic category to be deleted. :returns: the deleted syntactic category model. """ syntactic_category = Session.query(SyntacticCategory).get(id) if syntactic_category: Session.delete(syntactic_category) Session.commit() update_forms_referencing_this_category(syntactic_category) return syntactic_category else: response.status_int = 404 return {"error": "There is no syntactic category with id %s" % id}
def delete(self, id): """Delete an existing user and return it. :URL: ``DELETE /users/id`` :param str id: the ``id`` value of the user to be deleted. :returns: the deleted user model. """ user = Session.query(User).get(id) if user: h.destroy_user_directory(user) Session.delete(user) Session.commit() return user.get_full_dict() else: response.status_int = 404 return {'error': 'There is no user with id %s' % id}
def delete(self, id): """Delete an existing syntactic category and return it. :URL: ``DELETE /syntacticcategorys/id`` :param str id: the ``id`` value of the syntactic category to be deleted. :returns: the deleted syntactic category model. """ syntactic_category = Session.query(SyntacticCategory).get(id) if syntactic_category: Session.delete(syntactic_category) Session.commit() update_forms_referencing_this_category(syntactic_category) return syntactic_category else: response.status_int = 404 return {'error': 'There is no syntactic category with id %s' % id}
def delete(self, id): """Delete an existing form search and return it. :URL: ``DELETE /formsearches/id`` :param str id: the ``id`` value of the form search to be deleted. :returns: the deleted form search model. """ form_search = h.eagerload_form_search( Session.query(FormSearch)).get(id) if form_search: Session.delete(form_search) Session.commit() return form_search else: response.status_int = 404 return {'error': 'There is no form search with id %s' % id}
def delete(self, id): """Delete an existing corpus and return it. :URL: ``DELETE /corpora/id`` :param str id: the ``id`` value of the corpus to be deleted. :returns: the deleted corpus model. """ corpus = h.eagerload_corpus(Session.query(Corpus)).get(id) if corpus: corpus_dict = corpus.get_dict() backup_corpus(corpus_dict) Session.delete(corpus) Session.commit() remove_corpus_directory(corpus) return corpus_dict else: response.status_int = 404 return {'error': 'There is no corpus with id %s' % id}
def delete(self, id): """Delete an existing morpheme language model and return it. :URL: ``DELETE /morphemelanguagemodels/id`` :param str id: the ``id`` value of the morpheme language model to be deleted. :returns: the deleted morpheme language model model. """ lm = h.eagerload_morpheme_language_model(Session.query(MorphemeLanguageModel)).get(id) if lm: lm_dict = lm.get_dict() backup_morpheme_language_model(lm_dict) Session.delete(lm) Session.commit() lm.remove_directory() return lm else: response.status_int = 404 return {'error': 'There is no morpheme language model with id %s' % id}
def delete(self, id): """Delete an existing phonology and return it. :URL: ``DELETE /phonologies/id`` :param str id: the ``id`` value of the phonology to be deleted. :returns: the deleted phonology model. """ phonology = h.eagerload_phonology(Session.query(Phonology)).get(id) if phonology: phonology_dict = phonology.get_dict() backup_phonology(phonology_dict) Session.delete(phonology) Session.commit() phonology.remove_directory() return phonology else: response.status_int = 404 return {'error': 'There is no phonology with id %s' % id}
def delete(self, id): """Delete an existing morphological parser and return it. :URL: ``DELETE /morphologicalparsers/id`` :param str id: the ``id`` value of the morphological parser to be deleted. :returns: the deleted morphological parser model. """ parser = h.eagerload_morphological_parser(Session.query(MorphologicalParser)).get(id) if parser: parser_dict = parser.get_dict() backup_morphological_parser(parser_dict) Session.delete(parser) Session.commit() parser.remove_directory() return parser else: response.status_int = 404 return {'error': 'There is no morphological parser with id %s' % id}
def delete_file(file): """Delete a file model. :param file: a file model object to delete. :returns: ``None``. This deletes the file model object from the database as well as any binary files associated with it that are stored on the filesystem. """ if getattr(file, 'filename', None): file_path = os.path.join(h.get_OLD_directory_path('files', config=config), file.filename) os.remove(file_path) if getattr(file, 'lossy_filename', None): file_path = os.path.join(h.get_OLD_directory_path('reduced_files', config=config), file.lossy_filename) os.remove(file_path) Session.delete(file) Session.commit()
def delete(self, id): """Delete an existing tag and return it. :URL: ``DELETE /tags/id`` :param str id: the ``id`` value of the tag to be deleted. :returns: the deleted tag model. """ tag = Session.query(Tag).get(id) if tag: if tag.name not in (u'restricted', u'foreign word'): Session.delete(tag) Session.commit() return tag else: response.status_int = 403 return {'error': 'The restricted and foreign word tags cannot be deleted.'} else: response.status_int = 404 return {'error': 'There is no tag with id %s' % id}
def delete(self, id): """Delete an existing application settings and return it. :URL: ``DELETE /applicationsettings/id`` :param str id: the ``id`` value of the application settings to be deleted. :returns: the deleted application settings model. """ application_settings = h.eagerload_application_settings( Session.query(ApplicationSettings)).get(id) if application_settings: active_application_settings_id = getattr(h.get_application_settings(), 'id', None) to_be_deleted_application_settings_id = application_settings.id Session.delete(application_settings) Session.commit() if active_application_settings_id == to_be_deleted_application_settings_id: app_globals.application_settings = h.ApplicationSettings() return application_settings else: response.status_int = 404 return {'error': 'There is no application settings with id %s' % id}
def delete(self, id): """Delete an existing morpheme language model and return it. :URL: ``DELETE /morphemelanguagemodels/id`` :param str id: the ``id`` value of the morpheme language model to be deleted. :returns: the deleted morpheme language model model. """ lm = h.eagerload_morpheme_language_model( Session.query(MorphemeLanguageModel)).get(id) if lm: lm_dict = lm.get_dict() backup_morpheme_language_model(lm_dict) Session.delete(lm) Session.commit() lm.remove_directory() return lm else: response.status_int = 404 return { 'error': 'There is no morpheme language model with id %s' % id }
def delete(self, id): """Delete an existing morphological parser and return it. :URL: ``DELETE /morphologicalparsers/id`` :param str id: the ``id`` value of the morphological parser to be deleted. :returns: the deleted morphological parser model. """ parser = h.eagerload_morphological_parser( Session.query(MorphologicalParser)).get(id) if parser: parser_dict = parser.get_dict() backup_morphological_parser(parser_dict) Session.delete(parser) Session.commit() parser.remove_directory() return parser else: response.status_int = 404 return { 'error': 'There is no morphological parser with id %s' % id }
def delete(self, id): """Delete an existing tag and return it. :URL: ``DELETE /tags/id`` :param str id: the ``id`` value of the tag to be deleted. :returns: the deleted tag model. """ tag = Session.query(Tag).get(id) if tag: if tag.name not in (u'restricted', u'foreign word'): Session.delete(tag) Session.commit() return tag else: response.status_int = 403 return { 'error': 'The restricted and foreign word tags cannot be deleted.' } else: response.status_int = 404 return {'error': 'There is no tag with id %s' % id}
def delete(self, id): """Delete an existing application settings and return it. :URL: ``DELETE /applicationsettings/id`` :param str id: the ``id`` value of the application settings to be deleted. :returns: the deleted application settings model. """ application_settings = h.eagerload_application_settings( Session.query(ApplicationSettings)).get(id) if application_settings: active_application_settings_id = getattr( h.get_application_settings(), 'id', None) to_be_deleted_application_settings_id = application_settings.id Session.delete(application_settings) Session.commit() if active_application_settings_id == to_be_deleted_application_settings_id: app_globals.application_settings = h.ApplicationSettings() return application_settings else: response.status_int = 404 return { 'error': 'There is no application settings with id %s' % id }