def get(self, user_id):
        user_api = BoruvkaUserApi(self.dao)

        viewer_id = self.session['user_id']

        user = user_api.get_user(id=user_id)

        setting_query = BoruvkaSettingQuery(self.dao)

        user_settings = setting_query.get_user_settings(user_id)
        allowed_settings = setting_query.get_settings()

        viewer_settings = setting_query.get_user_settings(viewer_id)
        translation = viewer_settings['language']
        view = BoruvkaUserEditView(
            translation=translation,
        )

        view._full = not self.request.is_xhr
        view._user = user
        view._settings = allowed_settings
        view._user_settings = user_settings

        response = Response()
        response.body = view.render()
        return response
    def get(self, user_id):
        api = BoruvkaUserApi(self.dao)

        user = api.get_user(id=user_id)

        # TODO: move translations handling to BaseController
        translation = list(self.request.accept_language)[0]
        view = BoruvkaUserShowView(translation=translation)

        view._full = not self.request.is_xhr
        view._user = user

        response = Response()
        response.body = view.render()
        return response
Exemplo n.º 3
0
    def get(self):
        user_id = self.session["user_id"]
        user_api = BoruvkaUserApi(self.dao)
        user = user_api.get_user(id=user_id)

        setting_query = BoruvkaSettingQuery(self.dao)
        user_settings = setting_query.get_user_settings(user_id)
        translation = user_settings["language"]
        view = BoruvkaHomeView(translation)

        view.user = user
        view._color = user_settings["color"]

        response = Response()
        response.body = view.render()
        return response
    def get(self):
        api = BoruvkaUserApi(self.dao)
        users = api.list_users()

        users_list = []
        for user in users:
            user_dict = {}
            for key, value in vars(user).items():
                if key.startswith("_") or key == 'password':
                    continue
                user_dict[key] = value
            users_list.append(user_dict)
        response = Response(
            body=dumps(users_list),
            content_type="application/json",
        )
        return response
    def post(self, user_id):
        user_api = BoruvkaUserApi(self.dao)
        viewer_id = self.session['user_id']
        params = self.request.params

        message = None
        error = None

        response_dict = {}
        for key, value in params.items():
            response_dict[key] = value

        try:
            user_api.update_user(
                user_id=user_id,
                payload=response_dict,
            )
        except BoruvkaApiException, e:
            error = e
    def get(self):
        api = BoruvkaUserApi(self.dao)
        users = api.list_users()

        setting_query = BoruvkaSettingQuery(self.dao)
        users_settings = {}
        for user in users:
            users_settings[user.id] = setting_query.get_user_settings(user.id)


        # TODO: move translations handling to BaseController
        translation = list(self.request.accept_language)[0]
        view = BoruvkaUserListView(
            translation=translation,
        )

        view._full = not self.request.is_xhr
        view._users = users
        view._users_settings = users_settings

        response = Response()
        response.body = view.render()
        return response