Python rest_framework.decorators.permission_classes() Examples
The following are 1
code examples of rest_framework.decorators.permission_classes().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
rest_framework.decorators
, or try the search function
.
Example #1
Source File: views.py From openag-device-software with GNU General Public License v3.0 | 4 votes |
def create(self, request: Request) -> Response: """Creates a recipe.""" self.logger.debug("Creating recipe") # Initialize permission classes permission_classes = [IsAuthenticated, IsAdminUser] # Get recipe json try: request_dict = request.data.dict() recipe_json = request_dict["json"] except KeyError as e: message = "Unable to create recipe, {} is required".format(e) return Response({"message": message}, 400) # Get recipe manager app_config = apps.get_app_config(APP_NAME) recipe_manager = app_config.coordinator.recipe # Create recipe message, status = recipe_manager.create_recipe(recipe_json) # Build response response = {"message": message} # Return response self.logger.debug("Returning response: {}".format(response)) return Response(response, status)