diff --git a/server/api/app.py b/server/api/app.py index 03ff1f8..4b834d8 100755 --- a/server/api/app.py +++ b/server/api/app.py @@ -13,6 +13,7 @@ app.register_blueprint(app_views) HOST = "0.0.0.0" PORT = 5000 +SECRET_KEY = os.getenv('SECRET_KEY') @app.route('/volumes') diff --git a/server/api/views/index.py b/server/api/views/index.py index 80c13d4..cbecf9b 100755 --- a/server/api/views/index.py +++ b/server/api/views/index.py @@ -13,11 +13,11 @@ def status(): def stats(): """Return the count of all classes""" from models.user import User - from models.mood import Mood - from models.recommendation import Recommendation + from models.movie import Movie + from models.user_movie import User_Movie from models import storage return {"Users": storage.count(User), - "Moods": storage.count(Mood), - "Recommendations": storage.count(Recommendation) + "Movies": storage.count(Movie), + "User_Movies": storage.count(User_Movie) } diff --git a/server/models/engine/db_storage.py b/server/models/engine/db_storage.py index d40d358..c35f482 100755 --- a/server/models/engine/db_storage.py +++ b/server/models/engine/db_storage.py @@ -4,14 +4,14 @@ """ from models.base_model import BaseModel, Base -from models.mood import Mood -from models.recommendation import Recommendation +from models.movie import Movie +from models.user_movie import User_Movie from models.user import User from os import getenv from sqlalchemy import create_engine from sqlalchemy.orm import scoped_session, sessionmaker -classes = {"Mood": Mood, "Recommendation": Recommendation, "User": User} +classes = {"Movie": Movie, "User_Movie": User_Movie, "User": User} class DBStorage: diff --git a/server/models/mood.py b/server/models/mood.py deleted file mode 100755 index db72302..0000000 --- a/server/models/mood.py +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env python3 -"""Holds class Mood""" -from models.base_model import BaseModel, Base -from sqlalchemy import Column, String -from sqlalchemy.orm import relationship - - -class Mood(BaseModel, Base): - """Representation of a user """ - __tablename__ = 'moods' - mood = Column(String(24), nullable=False) - recommendations = relationship("Recommendation", - back_populates="mood", - cascade="all, delete-orphan") - - def __init__(self, *args, **kwargs): - """Initializes user""" - super().__init__(*args, **kwargs) diff --git a/server/models/movie.py b/server/models/movie.py new file mode 100755 index 0000000..5520e0d --- /dev/null +++ b/server/models/movie.py @@ -0,0 +1,18 @@ +#!/usr/bin/env python3 +"""Holds class Movie""" +from models.base_model import BaseModel, Base +from sqlalchemy import Column, String +from sqlalchemy.orm import relationship + + +class Movie(BaseModel, Base): + """Representation of a user """ + __tablename__ = 'movies' + movie = Column(String(60), nullable=False) + user_movies = relationship("User_Movie", + back_populates="movie", + cascade="all, delete-orphan") + + def __init__(self, *args, **kwargs): + """Initializes user""" + super().__init__(*args, **kwargs) diff --git a/server/models/recommendation.py b/server/models/recommendation.py deleted file mode 100755 index af9ea85..0000000 --- a/server/models/recommendation.py +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env python3 -"""Holds class Recommendation""" -from models.base_model import BaseModel, Base -from sqlalchemy import Column, String, Boolean, ForeignKey -from sqlalchemy.orm import relationship - - -class Recommendation(BaseModel, Base): - """Representation of a vault """ - __tablename__ = 'Recommendation' - user_id = Column(String(128), - ForeignKey('users.id', ondelete='CASCADE'), - nullable=False) - mood_id = Column(String(128), - ForeignKey('moods.id', ondelete='CASCADE'), - nullable=False) - weather = Column(String(128), nullable=False) - recommendaton = Column(String(128), nullable=True) - seen = Column(Boolean, nullable=False) - like = Column(Boolean, nullable=False) - mood = relationship("Mood", back_populates="recommendations") - user = relationship("User", back_populates="recommendations",) - - def __init__(self, *args, **kwargs): - """initializes vault""" - super().__init__(*args, **kwargs) diff --git a/server/models/user.py b/server/models/user.py index 54708ae..55d7525 100755 --- a/server/models/user.py +++ b/server/models/user.py @@ -13,10 +13,10 @@ class User(BaseModel, Base): password = Column(String(128), nullable=False) first_name = Column(String(128), nullable=False) last_name = Column(String(128), nullable=False) - recent_mood = Column(String(24), nullable=False) - recommendations = relationship("Recommendation", - back_populates="user", - cascade="all, delete-orphan") + avatar = Column(String(256), nullable=True) + user_movies = relationship("User_Movie", + back_populates="user", + cascade="all, delete-orphan") def __init__(self, *args, **kwargs): """Initializes user""" diff --git a/server/models/user_movie.py b/server/models/user_movie.py new file mode 100755 index 0000000..bc81e99 --- /dev/null +++ b/server/models/user_movie.py @@ -0,0 +1,24 @@ +#!/usr/bin/env python3 +"""Holds class User_Movie""" +from models.base_model import BaseModel, Base +from sqlalchemy import Column, String, Boolean, ForeignKey +from sqlalchemy.orm import relationship + + +class User_Movie(BaseModel, Base): + """Representation of a vault """ + __tablename__ = 'user_movies' + user_id = Column(String(128), + ForeignKey('users.id', ondelete='CASCADE'), + nullable=False) + movie_id = Column(String(128), + ForeignKey('movies.id', ondelete='CASCADE'), + nullable=False) + seen = Column(Boolean, nullable=True) + like = Column(Boolean, nullable=True) + movie = relationship("Movie", back_populates="user_movies") + user = relationship("User", back_populates="user_movies",) + + def __init__(self, *args, **kwargs): + """initializes vault""" + super().__init__(*args, **kwargs)