schedutron / home-server

A media home server to stream video from your laptop to any device on the same Wi-Fi!
MIT License
20 stars 47 forks source link

Likes #61

Open cnpapado opened 5 years ago

cnpapado commented 5 years ago

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

schedutron commented 5 years ago

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 commented 5 years ago

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?