Skip to content

lost-theory/moviepicker

Repository files navigation

Movie picker Flask application

This code is used to demonstrate how to build a Flask application.

Here are the commits / branches that represent different periods of development:

Commit ID
or branch
Compare to
previous version
Description
5e984ac n/a The original movie picker command line code.
solved5 Compare Basic Flask application that builds on top of the existing command line program. No database or persistence, just read-only data pulled on the fly from Wikipedia (movie categories), OMDbAPI.com (movie data), and IMDb (poster images). Uses a Bootstrap theme.
solved6 Compare Adds a sqlite database, models (categories, users, and lists of movies per user), login & registration, secure handling of passwords with passlib, and AJAX calls.
flask_sqlalchemy Compare Adds the Flask-SQLAlchemy extension, replacing the hand-rolled sqlite code. Application code was pretty much unchanged (just renaming methods). Templates only required one line of changes
comments Compare Adds a username to the User model. Replaces the one-to-many User -> Movies relation with a many-to-many relation, removing the need for duplicate Movie rows. Now that each Movie has a unique movie_id, add a Comment model that lets users leave comments on each movie via the movie details page.
class_view_and_blueprint Compare Adds Flask-Admin, a login_required view decorator, before_request and context_processor functions, a class based view for implement some API endpoints for converting models to JSON, and a blueprint for containing that API functionality.
moderation Compare Adds a "moderation" view to the admin area where comments must be approved before appearing on the site. Also introduce a role column on the User model to give moderator vs. full admin access.
migrations Compare Adds Flask-Migrate for Alembic migrations of the SQLAlchemy models. There is one migration for an is_deleted column on comments, so moderators now have the ability to delete comments instead of just approving them.
tests Compare Adds a simple unit test suite, test runner, and a mocked test.
deploy Compare Deploy script for Ubuntu 15 (e.g. to run on DigitalOcean/AWS), configurations for Heroku, and a few small changes to logging & configs for production deploys.
more_tests Compare More test coverage! Refactored some repeated test setup code into two decorators.
wtforms Compare Replace hand-rolled login and registration forms with Flask-WTF. Now the definition of the form and the validation logic live in one spot, forms.py. Removed form validation logic from the model layer.