diff --git a/project/controllers/loan.py b/project/controllers/loan.py index 6015d7a678b48b80dd26cc2d2f2fe6d7f336ebdc..1cc2648dc30b359571689dd21f1456feaf69a745 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 9af30f6fbfd61dd79a2573a60ddcc94175153470..060b5ddeebc30886c6f7832b7b0e789719a7c9d6 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 07ee137a9f896e12b16023e882b9ad589b55bf31..296ffd6147762acff9f3414b2b193e6fd8cd66db 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 13e9b44c14e39f32cf9849adecb09c02e747994c..81e072216ec8ec1ffe614788e35122627fc4358b 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 306f754f380383fe8bbf8faf91bde798523f478b..86cf5340e36fee22e2a76967f01db2634d49a41e 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 1f359bcc1e291e2baafe45a69f917c2a4f59ea1d..a5c3617e60fb9e57568cf6eecb59e06db7ed5a57 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">