-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Likes #61
base: master
Are you sure you want to change the base?
Likes #61
Conversation
but these circular imports create two instances of 'media_server' (one as '__main__' and one as 'media_server' which eventually mesh with the db. Therefore we activate this script via the flask commands/.flaskenv and not directly (Unstaged and untracked files will be added in the next commit for clarity)
…ith videos' filenames. This should be useful for implementing the comments because these can be stored also in the db and just like the two models (video and comment). Like/dislike buttons are sending an asynchronous request (via jquery/ajax) in flask/media_server.py with a corresponding string indicating like or dislike. Flask receives them and updates the database num of likes (row) for the current video (column). The video object stored in the database is stored in models.py. Other objects to be stored in the db could be added there too (don't forget to apply db migrations when making changes in the models). Because the both media_server.py and models.py need a reference to the db -which is initialized within media_server.py- we create it in globalimports.py which we later import everwhere else to avoid circularity of SQLAlchemy's imports. New dependencies where needed (flask-sqlalchemy, flask-migrate) which are listed in requirements.py. Further improvments: -limit even more the requests to the db by not commiting on every like incement/decrement -add an likes counter inside the video page -style buttons
Hey, thanks for the PR, I'll review it soon! In the meantime, is it possible that you can provide a deployed version of your PR on something like Netlify? If not, no problem, I'll clone and try it out soon. |
I'm afraid I'm not familiar with netlify so I'll leave that up to you. |
This should be useful for implementing the comments because these can be stored also in the db and just like the two models (video and comment).
Like/dislike buttons are sending an asynchronous request (via jquery/ajax) in flask/media_server.py with a corresponding string indicating like or dislike. Flask receives them and updates the database num of likes (row) for the current video (column).
The video object stored in the database is stored in models.py. Other objects to be stored in the db could be added there too (don't forget to apply db migrations when making changes in the models).
Because the both media_server.py and models.py need a reference to the db -which is initialized within media_server.py- we create it in globalimports.py which we later import everywhere else to avoid circularity of SQLAlchemy's imports.
New dependencies where needed (flask-sqlalchemy, flask-migrate) which are listed in requirements.py.
Further improvements:
-limit even more the requests to the db by not committing on every like increment/decrement
-add an likes counter inside the video page
-style buttons