Skip to content
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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Likes #61

wants to merge 6 commits into from

Conversation

cnpapado
Copy link

@cnpapado cnpapado commented Oct 2, 2019

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

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
@schedutron
Copy link
Owner

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.

@cnpapado
Copy link
Author

cnpapado commented Oct 8, 2019

I'm afraid I'm not familiar with netlify so I'll leave that up to you.
What about the travis' tests? Seems that every recent pr fails due to not executing correctly tests.py and regardless of the pr itself. Am I right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants