Beispiel #1
0
    def post(self):
        result = {"error": None, "data": {}}

        parser = reqparse.RequestParser()
        parser.add_argument("service",
                            type=str,
                            required=True,
                            choices=choices)
        parser.add_argument("slug", type=str, required=True)
        parser.add_argument("params", type=dict, default={})
        args = parser.parse_args()

        descriptor = DescriptorService.get_by_slug(args["service"],
                                                   args["slug"])
        if descriptor is None:
            return abort(args["service"], "not-found")

        keys = ["name", "slug", "description"]
        update = utils.filter_dict(args["params"], keys)
        update_document(descriptor, update)

        try:
            descriptor.save()
        except Exception:
            return abort("general", "empty-required")

        result["data"] = descriptor.dict()
        return result
Beispiel #2
0
 def update(cls, user: User, **kwargs):
     user = update_document(user, kwargs)
     user.save()
Beispiel #3
0
 def update(cls, team: Team, **kwargs):
     team = update_document(team, kwargs)
     team.save()