Example #1
0
 def build_args(self, parent_id):
     """Build a dictionary from the parsed request arguments
     representing the new resource to be created.
     """
     args = self.parser.parse_args()
     args['creator_id'] = auth.current_user_id()
     args[self.parent_id_name] = parent_id
     return args
Example #2
0
 def build_args(self, parent_id):
     """Build a dictionary from the parsed request arguments
     representing the new resource to be created.
     """
     args = self.parser.parse_args()
     args['creator_id'] = auth.current_user_id()
     args[self.parent_id_name] = parent_id
     return args
Example #3
0
    def post(self):
        """Create a new resource and link it to its creator."""
        args = self.parser.parse_args()
        args['creator_id'] = auth.current_user_id()
        new_resource = self.resource_type(**args)  #pylint: disable=E1102

        backend.db.session.add(new_resource)
        backend.db.session.commit()

        return self.as_dict(new_resource)
Example #4
0
    def post(self):
        """Create a new resource and link it to its creator."""
        args = self.parser.parse_args()
        args['creator_id'] = auth.current_user_id()
        new_resource = self.resource_type(**args) #pylint: disable=E1102

        backend.db.session.add(new_resource)
        backend.db.session.commit()

        return self.as_dict(new_resource)