def available_languages(): """ :return: jason with language codes for the supported languages. e.g. ["en", "fr", "de", "it", "no", "ro"] """ available_language_codes = map((lambda x: x.id), Language.available_languages()) return json.dumps(available_language_codes)
def get_interesting_reading_languages(): """ 'Interesting languages' are defined as languages the user isn't subscribed to already and thus might subscribe to. :return: a json list with languages the user isn't reading yet. every language in this list is a dictionary with the following info: id = unique id of the language; language = <unicode string> """ all_languages = Language.available_languages() learned_languages = UserLanguage.all_reading_for_user(flask.g.user) interesting_languages = [] for lan in all_languages: if lan not in learned_languages: interesting_languages.append(lan.as_dictionary()) return json_result(interesting_languages)