From 884b57c93df24b38d81ea27c91ffc75fabbfb278 Mon Sep 17 00:00:00 2001 From: Brian Wood <legion.the.unforgiven@gmail.com> Date: Wed, 23 Apr 2014 20:50:48 -0600 Subject: [PATCH] Some quick fixes for putting the site live --- project/controllers/loan.py | 9 +++++++-- project/controllers/login.py | 2 +- project/model/Library.py | 3 +-- project/templates/library/library.html | 4 ++-- project/templates/library/libraryItem.html | 4 ++-- project/templates/library/reminder_modal.html | 2 +- 6 files changed, 14 insertions(+), 10 deletions(-) diff --git a/project/controllers/loan.py b/project/controllers/loan.py index 6015d7a..1cc2648 100644 --- a/project/controllers/loan.py +++ b/project/controllers/loan.py @@ -6,8 +6,13 @@ from flask.ext.wtf import Form, TextField, validators @app.route('/loaned') @security('user') def loaned(user=None): - return render_template('loan/master.html', user=user) - + from project.model.Movie import Movie + from project.model.Library import Library + library = Library.objects(user=user,name="Borrowed",unit='Movie').first() + if not library: + return render_template('404.html',message='Unable to find given Library',user=user),404 + return render_template('library/library.html',library=library,user=user) + @app.route('/send-reminder', methods=['POST']) @security('user') def reminderEmail(user=None): diff --git a/project/controllers/login.py b/project/controllers/login.py index 9af30f6..060b5dd 100644 --- a/project/controllers/login.py +++ b/project/controllers/login.py @@ -37,7 +37,7 @@ def signup(): user.addRole('user').save() session['user'] = user.toJSON() Library(user=user, unit='Movie', name='Master').save() - Library(user=user, unit='Movie', name='Borrowed').save() + Library(user=user, unit='Movie', name='Loaned').save() return jsonify(response='success',type='redirect',path=url_for(endpoint='libraries',_external=True)) @app.route('/logout', methods=['GET', 'POST']) diff --git a/project/model/Library.py b/project/model/Library.py index 07ee137..296ffd6 100644 --- a/project/model/Library.py +++ b/project/model/Library.py @@ -7,8 +7,7 @@ class Library(db.Document): name = db.StringField(max_length=100, unique_with=['user','unit']) #name of the Library lookup_attribute = db.StringField(default='id') collection = db.ListField(db.StringField()) - summary = db.StringField() - + def addUnit(self,unit): if self.unit == type(unit).__name__: value = str(unit[self.lookup_attribute]) diff --git a/project/templates/library/library.html b/project/templates/library/library.html index 13e9b44..81e0722 100644 --- a/project/templates/library/library.html +++ b/project/templates/library/library.html @@ -39,7 +39,7 @@ <button type="button" class="btn btn-default btn-small return-movie" data-toggle="modal" data-target="#return-form" data-id='{{ movie.id }}'>Return</button> <button type="button" class="btn btn-default btn-small reminder" data-toggle="modal" data-target="#reminder-form" data-id='{{ movie.id }}'>Reminder</button> {% endif %} - {% if library.name != "Master" or loan == None %} + {% if (library.name != "Master" and library.name != "Borrowed") or loan == None %} <button type="button" class="btn btn-default btn-small remove-movie" data-id='{{ loop.index }}'>Remove</button> {% endif %} </div> @@ -70,7 +70,7 @@ <button type="button" class="btn btn-default btn-small return-movie" data-toggle="modal" data-target="#return-form" data-id='{{ movie.id }}'>Return</button> <button type="button" class="btn btn-default btn-small reminder" data-toggle="modal" data-target="#reminder-form" data-id='{{ movie.id }}'>Reminder</button> {% endif %} - {% if library.name != "Master" or loan == None %} + {% if (library.name != "Master" and library.name != "Borrowed") or loan == None %} <button type="button" class="btn btn-default btn-small remove-movie" data-id='{{ loop.index }}'>Remove</button> {% endif %} diff --git a/project/templates/library/libraryItem.html b/project/templates/library/libraryItem.html index 306f754..86cf534 100644 --- a/project/templates/library/libraryItem.html +++ b/project/templates/library/libraryItem.html @@ -3,7 +3,7 @@ {% set loan = item.getLoan(user) %} <div class="col-sm-12"> <div class="row"> - <div class="col-xs-12 col-sm-3 col-md-2"> + <div class="col-xs-12 col-sm-3 col-md-3" style="margin-bottom:20px"> <img src="{{ item.poster }}" style="max-width: 180px;" alt="{{ item.title }}"> <h3>{{ item.title }}</h3> {% if loan != None %} @@ -53,7 +53,7 @@ </dl> </div> - <div class="col-xs-12 col-sm-5 col-md-5"> + <div class="col-xs-12 col-sm-5 col-md-4"> <h2>Summary</h2> <p>{{ item.summary }}</p> </div> diff --git a/project/templates/library/reminder_modal.html b/project/templates/library/reminder_modal.html index 1f359bc..a5c3617 100644 --- a/project/templates/library/reminder_modal.html +++ b/project/templates/library/reminder_modal.html @@ -18,7 +18,7 @@ <div class="form-group message-area"> <label for="message" class="col-sm-3 control-label">Message</label> <div class="col-xs-9 col-md-6"> - <textarea class="form-control" id="message" name="message" placeholder="Password"></textarea> + <textarea class="form-control" id="message" name="message" placeholder="Message"></textarea> </div> </div> <div class="form-group"> -- GitLab