Skip to content

Commit

Permalink
[PUT] change name with title and add language with attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
Badr-Annabi committed Sep 16, 2024
1 parent b550e03 commit 2e46ab7
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions server/api/views/movies.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
Routes:
- GET /movies: Retrieve all movies.
- POST /movies: Create a new movie.
- GET /movies/<movie_id>: Retrieve a specific movie
Exceptions:
- Invalid token: Raised when the JWT token is invalid.
Expand Down Expand Up @@ -45,14 +44,15 @@ def post_movies():
POST
- Header: Authorization Bearer Token (required)
Input:
- name: String (required)
- title: String (required)
- tmdb_id: Integer (required)
- description: String
- Poster: String
- adult: Boolean
- popularity: Float
- year: Integer
- rating: Float
- language: String
"""
try:
verify_jwt_in_request()
Expand All @@ -65,16 +65,16 @@ def post_movies():
except Exception as e:
return jsonify({'error': 'Invalid Request'}), 400

name = movie_data.get('name')
if not name:
title = movie_data.get('title')
if not title:
return jsonify({'error': 'Movie name is required'}), 400

existing_movie = storage.get_specific(Movie, 'name', name)
existing_movie = storage.get_specific(Movie, 'title', title)
if existing_movie:
return jsonify({'error': 'Movie name already exists'}), 409

valid_attributes = ['name', 'description', 'poster', 'adult',
'year', 'rating', 'popularity', 'tmdb_id']
valid_attributes = ['title', 'description', 'poster', 'adult',
'year', 'rating', 'popularity', 'tmdb_id', 'language']
movie_parsed = {}
for k, v in movie_data.items():
if k in valid_attributes:
Expand Down

0 comments on commit 2e46ab7

Please sign in to comment.