def history(self, id): """Return a collection and its previous versions. :URL: ``GET /collections/history/id`` :param str id: a string matching the ``id`` or ``UUID`` value of the collection whose history is requested. :returns: a dictionary of the form:: {"collection": { ... }, "previous_versions": [ ... ]} where the value of the ``collection`` key is the collection whose history is requested and the value of the ``previous_versions`` key is a list of dictionaries representing previous versions of the collection. """ collection, previous_versions = h.get_model_and_previous_versions('Collection', id) if collection or previous_versions: unrestricted_users = h.get_unrestricted_users() user = session['user'] accessible = h.user_is_authorized_to_access_model unrestricted_previous_versions = [cb for cb in previous_versions if accessible(user, cb, unrestricted_users)] collection_is_restricted = collection and not accessible(user, collection, unrestricted_users) previous_versions_are_restricted = previous_versions and not unrestricted_previous_versions if collection_is_restricted or previous_versions_are_restricted : response.status_int = 403 return h.unauthorized_msg else : return {'collection': collection, 'previous_versions': unrestricted_previous_versions} else: response.status_int = 404 return {'error': 'No collections or collection backups match %s' % id}
def history(self, id): """Return the morphological parser with ``morphological_parser.id==id`` and its previous versions. :URL: ``GET /morphologicalparsers/history/id`` :param str id: a string matching the ``id`` or ``UUID`` value of the morphological parser whose history is requested. :returns: A dictionary of the form:: {"morphological_parser": { ... }, "previous_versions": [ ... ]} where the value of the ``morphological_parser`` key is the morphological parser whose history is requested and the value of the ``previous_versions`` key is a list of dictionaries representing previous versions of the morphological parser. """ morphological_parser, previous_versions = h.get_model_and_previous_versions( 'MorphologicalParser', id) if morphological_parser or previous_versions: return { 'morphological_parser': morphological_parser, 'previous_versions': previous_versions } else: response.status_int = 404 return { 'error': 'No morphological parsers or morphological parser backups match %s' % id }
def history(self, id): """Return the morpheme language model with ``morpheme_language_model.id==id`` and its previous versions. :URL: ``GET /morphemelanguagemodels/history/id`` :param str id: a string matching the ``id`` or ``UUID`` value of the morpheme language model whose history is requested. :returns: A dictionary of the form:: {"morpheme_language_model": { ... }, "previous_versions": [ ... ]} where the value of the ``morpheme_language_model`` key is the morpheme language model whose history is requested and the value of the ``previous_versions`` key is a list of dictionaries representing previous versions of the morpheme language model. """ lm, previous_versions = h.get_model_and_previous_versions( 'MorphemeLanguageModel', id) if lm or previous_versions: return { 'morpheme_language_model': lm, 'previous_versions': previous_versions } else: response.status_int = 404 return { 'error': 'No morpheme language models or morpheme language model backups match %s' % id }
def history(self, id): """Return a collection and its previous versions. :URL: ``GET /collections/history/id`` :param str id: a string matching the ``id`` or ``UUID`` value of the collection whose history is requested. :returns: a dictionary of the form:: {"collection": { ... }, "previous_versions": [ ... ]} where the value of the ``collection`` key is the collection whose history is requested and the value of the ``previous_versions`` key is a list of dictionaries representing previous versions of the collection. """ collection, previous_versions = h.get_model_and_previous_versions( 'Collection', id) if collection or previous_versions: unrestricted_users = h.get_unrestricted_users() user = session['user'] accessible = h.user_is_authorized_to_access_model unrestricted_previous_versions = [ cb for cb in previous_versions if accessible(user, cb, unrestricted_users) ] collection_is_restricted = collection and not accessible( user, collection, unrestricted_users) previous_versions_are_restricted = previous_versions and not unrestricted_previous_versions if collection_is_restricted or previous_versions_are_restricted: response.status_int = 403 return h.unauthorized_msg else: return { 'collection': collection, 'previous_versions': unrestricted_previous_versions } else: response.status_int = 404 return { 'error': 'No collections or collection backups match %s' % id }
def history(self, id): """Return the morpheme language model with ``morpheme_language_model.id==id`` and its previous versions. :URL: ``GET /morphemelanguagemodels/history/id`` :param str id: a string matching the ``id`` or ``UUID`` value of the morpheme language model whose history is requested. :returns: A dictionary of the form:: {"morpheme_language_model": { ... }, "previous_versions": [ ... ]} where the value of the ``morpheme_language_model`` key is the morpheme language model whose history is requested and the value of the ``previous_versions`` key is a list of dictionaries representing previous versions of the morpheme language model. """ lm, previous_versions = h.get_model_and_previous_versions('MorphemeLanguageModel', id) if lm or previous_versions: return {'morpheme_language_model': lm, 'previous_versions': previous_versions} else: response.status_int = 404 return {'error': 'No morpheme language models or morpheme language model backups match %s' % id}
def history(self, id): """Return the phonology with ``phonology.id==id`` and its previous versions. :URL: ``GET /phonologies/history/id`` :param str id: a string matching the ``id`` or ``UUID`` value of the phonology whose history is requested. :returns: A dictionary of the form:: {"phonology": { ... }, "previous_versions": [ ... ]} where the value of the ``phonology`` key is the phonology whose history is requested and the value of the ``previous_versions`` key is a list of dictionaries representing previous versions of the phonology. """ phonology, previous_versions = h.get_model_and_previous_versions('Phonology', id) if phonology or previous_versions: return {'phonology': phonology, 'previous_versions': previous_versions} else: response.status_int = 404 return {'error': 'No phonologies or phonology backups match %s' % id}
def history(self, id): """Return the morphological parser with ``morphological_parser.id==id`` and its previous versions. :URL: ``GET /morphologicalparsers/history/id`` :param str id: a string matching the ``id`` or ``UUID`` value of the morphological parser whose history is requested. :returns: A dictionary of the form:: {"morphological_parser": { ... }, "previous_versions": [ ... ]} where the value of the ``morphological_parser`` key is the morphological parser whose history is requested and the value of the ``previous_versions`` key is a list of dictionaries representing previous versions of the morphological parser. """ morphological_parser, previous_versions = h.get_model_and_previous_versions('MorphologicalParser', id) if morphological_parser or previous_versions: return {'morphological_parser': morphological_parser, 'previous_versions': previous_versions} else: response.status_int = 404 return {'error': 'No morphological parsers or morphological parser backups match %s' % id}
def history(self, id): """Return the corpus with ``corpus.id==id`` and its previous versions. :URL: ``GET /corpora/id/history`` :param str id: a string matching the ``id`` or ``UUID`` value of the corpus whose history is requested. :returns: A dictionary of the form:: {"corpus": { ... }, "previous_versions": [ ... ]} where the value of the ``corpus`` key is the corpus whose history is requested and the value of the ``previous_versions`` key is a list of dictionaries representing previous versions of the corpus. """ corpus, previous_versions = h.get_model_and_previous_versions('Corpus', id) if corpus or previous_versions: return {'corpus': corpus, 'previous_versions': previous_versions} else: response.status_int = 404 return {'error': 'No corpora or corpus backups match %s' % id}
def history(self, id): """Return the corpus with ``corpus.id==id`` and its previous versions. :URL: ``GET /corpora/id/history`` :param str id: a string matching the ``id`` or ``UUID`` value of the corpus whose history is requested. :returns: A dictionary of the form:: {"corpus": { ... }, "previous_versions": [ ... ]} where the value of the ``corpus`` key is the corpus whose history is requested and the value of the ``previous_versions`` key is a list of dictionaries representing previous versions of the corpus. """ corpus, previous_versions = h.get_model_and_previous_versions( 'Corpus', id) if corpus or previous_versions: return {'corpus': corpus, 'previous_versions': previous_versions} else: response.status_int = 404 return {'error': 'No corpora or corpus backups match %s' % id}