# Path: lingobarter/core/json.py
# def render_json(message, status, **kwargs):
#     ret = {
#         'message': message,
#         'status': status,
#     }
#     if kwargs is not None and len(kwargs.keys()) != 0:
#         ret['response'] = kwargs
#     return ret


from flask_restful import Resource
from lingobarter.core.json import render_json
from lingobarter.modules.accounts.models import Language
# coding: utf-8



class LanguageResource(Resource):
    def get(self):
        languages = {}

        for lang in Language.objects:
            languages[lang.name] = {
                'id': str(lang.id),
                "name": lang.name,
                "u_name": lang.u_name,
                "abbrev": lang.abbrev
            }


# Path: lingobarter/core/json.py
# def render_json(message, status, **kwargs):
#     ret = {
#         'message': message,
#         'status': status,
#     }
#     if kwargs is not None and len(kwargs.keys()) != 0:
#         ret['response'] = kwargs
#     return ret


# Path: lingobarter/core/resources.py
from flask_restful import Resource
from lingobarter.core.json import render_json
from lingobarter.modules.accounts.models import Language

# coding: utf-8



class LanguageResource(Resource):
    def get(self):
        languages = {}

        for lang in Language.objects:
            languages[lang.name] = {
                'id': str(lang.id),
                "name": lang.name,
                "u_name": lang.u_name,
                "abbrev": lang.abbrev
            }


        return render_json(message="Successfully fetch all languages", status=200, **languages)