app factory now outside tests dir, other minor changes
This commit is contained in:
@@ -20,13 +20,16 @@ class User(db.Model):
|
||||
def __repr__(self):
|
||||
return f'{self.username}'
|
||||
|
||||
# Get all dogs currently set
|
||||
def get_dogs(self):
|
||||
return [dog for dog in self.dogs]
|
||||
|
||||
# Retrieve all booked visits
|
||||
def get_bookings(self):
|
||||
def get_visits(self):
|
||||
return [visit for visit in self.visits]
|
||||
|
||||
# Retrieve past booked visits
|
||||
def get_bookings_history(self):
|
||||
from datetime import datetime
|
||||
def get_visit_history(self):
|
||||
current_time = datetime.now()
|
||||
|
||||
return [visit for visit in self.visits if visit.date_time < current_time]
|
||||
|
||||
@@ -18,12 +18,7 @@ def user_dashboard(username):
|
||||
# Retrieve user data
|
||||
user = db.session.execute(db.select(User).filter_by(username=username)).scalar_one()
|
||||
|
||||
# Gather names of dogs for this client
|
||||
dogs = list()
|
||||
for dog in user.dogs:
|
||||
dogs.append(dog.name)
|
||||
|
||||
return render_template('users/dashboard/base.html', user=user, user_dogs=dogs, user_book_history=user.get_bookings())
|
||||
return render_template('users/dashboard/base.html', user=user, user_pets=user.get_dogs(), user_book_history=user.get_visits())
|
||||
|
||||
@accounts.route('/users/<username>', methods=['POST'])
|
||||
def user(username):
|
||||
|
||||
Reference in New Issue
Block a user