diff --git a/project/__init__.py b/project/__init__.py index a24a67bd408c14871b7479e8d53101e23a5ac985..51173a7e7ab25ee39095449b535d86d326d46479 100644 --- a/project/__init__.py +++ b/project/__init__.py @@ -16,8 +16,8 @@ from tmdb3 import set_key app = Flask('project') app.config['SECRET_KEY'] = 'random' app.config['MONGODB_SETTINGS'] = {'DB': 'my_movie_library'} -app.config['SMTP_USER'] = "" -app.config['SMTP_PASSWORD'] = "" +app.config['SMTP_USER'] = "my.movie.library.reminder@gmail.com" +app.config['SMTP_PASSWORD'] = "1 LikemoVies&p0pCO7n" app.config['SMTP_SERVER'] = "smtp.gmail.com:587" app.config['TMDB_API_KEY'] = "542606a6ccff81a0337dc370a0cbfc37" set_key(app.config['TMDB_API_KEY']) diff --git a/project/controllers/library.py b/project/controllers/library.py index 1961a6da7393980487049ad88816c7a73a1683e9..770f2ae38dc5e6361066d90d44637b775906e405 100644 --- a/project/controllers/library.py +++ b/project/controllers/library.py @@ -54,7 +54,7 @@ def libraryItem(name, index,user=None): movie = library.hydrateUnit(index-1) if not movie: return render_template('404.html',message='Unable to find given Movie',user=user),404 - return render_template('library/libraryItem.html',item=movie,user=user) + return render_template('library/libraryItem.html',item=movie,user=user,library=library,index=index) @app.route('/libraries/<name>/remove', methods=['POST']) @security('user') diff --git a/project/model/Movie.py b/project/model/Movie.py index 905f024970affcefd25600930088921f04fa410c..08ab6b4bcf6271c8afb9c8d9e038e1e9f71987ac 100644 --- a/project/model/Movie.py +++ b/project/model/Movie.py @@ -7,6 +7,7 @@ class Movie(db.Document): summary = db.StringField(max_length=10000, required=True) tags = db.ListField(db.StringField(max_length=50)) cast = db.ListField(db.StringField()) + director = db.StringField() tmdb_id = db.IntField() runtime = db.IntField() poster = db.StringField() @@ -48,7 +49,7 @@ class Movie(db.Document): if len(sizes) > 0: medium = int(len(sizes)/2) result.poster = str(movie.poster.geturl(sizes[medium])) - result.popularity = float(movie.popularity) + result.popularity = float(movie.userrating) result.runtime = int(movie.runtime) tags = movie.keywords for tag in tags: @@ -58,6 +59,11 @@ class Movie(db.Document): result.addTag(str(genre.name.encode('utf-8'))) cast = movie.cast for actor in cast: - result.cast.append("%s as %s" % (actor.name,actor.character)) + result.cast.append("%s:%s" % (actor.name,actor.character)) + crew = movie.crew + for person in crew: + job = person.job.encode('utf-8') + if 'director' == job.lower(): + result.director = person.name.encode('utf-8') result.save() return result diff --git a/project/static/css/style.css b/project/static/css/style.css index c803093cfdb9ece5c9c2c0a0ab36899bdebedf59..3fe7d588861c793a7e70fa8278690a18153d7f31 100644 --- a/project/static/css/style.css +++ b/project/static/css/style.css @@ -48,4 +48,54 @@ html,body { #results { max-height: 500px; overflow-y: scroll; +} + +dl { + width:100%; + overflow:hidden; +} +dt { + float:left; + width:50%; /* adjust the width; make sure the total of both is 100% */ +} +dd { + float:left; + width:50%; /* adjust the width; make sure the total of both is 100% */ + +} + +.rating-text { + margin: 0 auto; + width: 20px; + color: gold; +} + +.rating { + unicode-bidi: bidi-override; + direction: rtl; + width: 20px; + margin: 0 auto; +} +.rating > span.rated:before, +.rating > span.rated ~ span:before { + content: "\2605"; + position: absolute; + color: gold; +} + +span.vert{ + font-size: 22px; +} + +@media (max-width: 480px) { + span.vert { + display: inline-block; + } + .rating { + width: 90%; + display: inline-block; + } + .rating-text{ + display: inline-block; + } } \ No newline at end of file diff --git a/project/templates/library/library.html b/project/templates/library/library.html index f8ccba06e3d93b9db262c66a04ca2efc7aa75a5c..8bc30903c24feabef4dea8b0c19c16befee9e87d 100644 --- a/project/templates/library/library.html +++ b/project/templates/library/library.html @@ -11,9 +11,9 @@ <thead> <tr> <td>Movie</td> - <td>Summary</td> <td>Rating</td> - <td>Options</td> + <td class="hidden-xs">Summary</td> + <td class="hidden-xs">Options</td> </tr> </thead> <tbody> @@ -27,14 +27,29 @@ <td> <img src="{{ movie.poster|default('') }}" style="max-width: 200px;" alt="{{ movie.title }}"> <p>{{ movie.title }}</p> + <div class="btn-group hidden-md hidden-lg"> + <button type="button" class="btn btn-default btn-small lend-movie" data-id='{{ loop.index }}'>Lend</button> + <button type="button" class="btn btn-default btn-small borrow-movie" data-id='{{ loop.index }}'>Edit</button> + <button type="button" class="btn btn-default btn-small remove-movie" data-id='{{ loop.index }}'>Remove</button> + </div> </td> <td> - {{ movie.summary }} + <div class='rating-text'style="">{{ movie.popularity }}</div> + <div class="rating"> + {% set rating = 10 - movie.popularity|int %} + {% for i in range(10) %} + {% if rating == i %} + <span class="vert rated">☆</span> + {% else %} + <span class="vert">☆</span> + {% endif %} + {% endfor %} + </div> </td> - <td> - {{ movie.rating }} + <td class="hidden-xs"> + {{ movie.summary }} </td> - <td> + <td class="hidden-xs"> <div class="btn-group-vertical"> <button type="button" class="btn btn-default btn-small lend-movie" data-id='{{ loop.index }}'>Lend</button> <button type="button" class="btn btn-default btn-small borrow-movie" data-id='{{ loop.index }}'>Edit</button> diff --git a/project/templates/library/libraryItem.html b/project/templates/library/libraryItem.html index 256b9569cec8e094608d254e5e507705565960ee..a2722d017f7ea0b59c351acd3ba00bb9166c8277 100644 --- a/project/templates/library/libraryItem.html +++ b/project/templates/library/libraryItem.html @@ -3,36 +3,86 @@ <div class="col-sm-12"> <div class="row"> <div class="col-xs-12 col-sm-3 col-md-2"> - <img data-src="holder.js/100%x200/sky" alt="movie title"> - <button type="button" class="btn btn-default btn-sm"> - <span class="glyphicon glyphicon-pencil"></span> Edit - </button> - <button type="button" class="btn btn-warning btn-sm"> + <img src="{{ item.poster }}" style="max-width: 180px;" alt="{{ item.title }}"> + <h3>{{ item.title }}</h3> + <button type="button" class="btn btn-warning btn-sm remove-movie" data-id='{{ index }}'> <span class="glyphicon glyphicon-remove"></span> Remove </button> </div> - - <div class="col-xs-12 col-sm-3 col-md-2"> - <ul class="list-unstyled"> - <li>Movie Title</li> - <li>Director(s)</li> - <li>Actors (truncated)</li> - <li>Producers</li> - <li>Composer</li> - </ul> + <div class="col-md-1 hidden-sm"> + <div class="rating-text">{{ item.popularity }}</div> + <div class="rating"> + {% set rating = 10 - item.popularity|int %} + {% for i in range(10) %} + {% if rating == i %} + <span class="vert rated">☆</span> + {% else %} + <span class="vert">☆</span> + {% endif %} + {% endfor %} + </div> + </div> + <div class="col-xs-12 col-sm-4 col-md-4"> + <dl> + <dt>Director</dt> + <dd>{{ item.director|default('No Director found')}}</dd> + <dt>Actors:</dt> + <dd> </dd> + {% for data in item.cast %} + {% set actor = data.split(':')[0]|default(' ') %} + {% set character = data.split(':')[1]|default(' ') %} + <dt>{{ actor }}</dt> + <dd>{{ character }}</dd> + {% endfor %} + + </dl> </div> - <div class="col-xs-12 col-sm-6 col-md-8"> + <div class="col-xs-12 col-sm-5 col-md-5"> <h2>Summary</h2> - <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse eget metus vitae mi interdum tristique. Integer malesuada quam tincidunt, gravida nisi vehicula, auctor mi. Morbi fermentum, neque quis adipiscing placerat, odio nunc consequat ligula, vel sagittis nisl orci id risus. Aliquam hendrerit, elit a molestie suscipit, eros tortor scelerisque odio, sit amet cursus ligula lorem et turpis. Pellentesque ante metus, suscipit id blandit eget, vehicula quis tortor. Aliquam a pharetra enim. Morbi in purus sit amet nulla egestas consectetur. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla diam nulla, iaculis lobortis varius at, auctor malesuada enim. Donec a nisl eget ligula rhoncus fermentum.</p> + <p>{{ item.summary }}</p> </div> </div> - <div class="row"> - <div class="col-xs-12 col-sm-6 col-md-12"> - <h3>Movie Reviews</h3> - <p>Coming Soon!</p> - </div> - </div> </div> +{% endblock %} +{% block javascript %} + <script> + $(function(){ + var removePath = '{{ url_for("removelibraryItem", name=library.name) }}'; + $('.remove-movie').on('click',function(event){ + var movie_id = $(this).data('id'); + {% if library.name == 'Master' %} + var message = "Removing a movie from your Master list will remove it from all other lists. Are you sure you want remove this movie? "; + {% else %} + var message = "Are you sure you want remove this movie? "; + {% endif %} + if(confirm(message)){ + event.stopPropagation(); + event.preventDefault(); + $.ajax({ + url: removePath, + data: {id:movie_id}, + method: 'POST', + success: function(data,status,jqXHR){ + if(data['response'] == 'success'){ + if(data['type'] == 'redirect'){ + window.document.location = data['path']; + } else if (data['type'] == 'reload') { + window.document.location.reload(); + } + } + }, + error: function(jqXHR, textStatus, errorThrown){ + response = jqXHR.responseJSON; + if('message' in response){ + alert(response['message']); + } + } + }); + + } + }); + }); + </script> {% endblock %} \ No newline at end of file