コード例 #1
0
ファイル: user.py プロジェクト: tekulvw/modularsecurity
    def get(self, oauth_id=None):
        """
        Gets current user information.
        :param oauth_id:
        :return: models/user/User plus owned_systems, secondary_systems
        """
        if oauth_id is None:
            oauth_id = current_user.oauth_id

        if current_user.oauth_id != oauth_id:
            # TODO: Check for admin status here.
            abort(403)

        data = current_user.to_json()
        owned = OwnerModel.from_user(current_user)
        try:
            owned_data = owned.system_key.get().to_json()
        except AttributeError:
            data['owned_systems'] = []
        else:
            data['owned_systems'] = [owned_data, ]

        secondary = Secondary.from_user(current_user)
        secondary_data = [s.system_key.get().to_json() for s in secondary]
        data['secondary_systems'] = secondary_data

        return jsonify(data)
コード例 #2
0
def test_from_user(random_secondary):
    random_user = random_secondary.user_key.get()

    users = Secondary.from_user(random_user)

    assert len(users) > 0
    assert all(sec.user_key == random_user.key for sec in users)