|
|
|
@ -89,70 +89,6 @@ def login_user(username, password):
|
|
|
|
|
cnx.close()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# def get_database_connection():
|
|
|
|
|
# return connection
|
|
|
|
|
#
|
|
|
|
|
#
|
|
|
|
|
# def get_dishes(page, per_page):
|
|
|
|
|
# connection = get_database_connection()
|
|
|
|
|
# offset = (page - 1) * per_page
|
|
|
|
|
#
|
|
|
|
|
# with connection.cursor() as cursor:
|
|
|
|
|
# cursor.execute(
|
|
|
|
|
# f"SELECT DishName, WebLink, LikeNumber, CollectNumber FROM MainDishList LIMIT {per_page} OFFSET {offset}")
|
|
|
|
|
# rows = cursor.fetchall()
|
|
|
|
|
#
|
|
|
|
|
# dishes = []
|
|
|
|
|
# for row in rows:
|
|
|
|
|
# dish = {
|
|
|
|
|
# 'DishName': row[0],
|
|
|
|
|
# 'WebLink': row[1],
|
|
|
|
|
# 'LikeNumber': row[2],
|
|
|
|
|
# 'CollectNumber': row[3]
|
|
|
|
|
# }
|
|
|
|
|
# dishes.append(dish)
|
|
|
|
|
#
|
|
|
|
|
# return dishes
|
|
|
|
|
#
|
|
|
|
|
#
|
|
|
|
|
# def mainpage(request):
|
|
|
|
|
# page = int(request.GET.get('page', 1))
|
|
|
|
|
# per_page = 10
|
|
|
|
|
#
|
|
|
|
|
# dishes = get_dishes(page, per_page)
|
|
|
|
|
#
|
|
|
|
|
# return render(request, 'mainpage.html', {'dishes': dishes})
|
|
|
|
|
#
|
|
|
|
|
#
|
|
|
|
|
# def load_more_dishes(request):
|
|
|
|
|
# page = int(request.GET.get('page', 1))
|
|
|
|
|
# per_page = 10
|
|
|
|
|
#
|
|
|
|
|
# dishes = get_dishes(page, per_page)
|
|
|
|
|
#
|
|
|
|
|
# return JsonResponse({'dishes': dishes})
|
|
|
|
|
#
|
|
|
|
|
#
|
|
|
|
|
# def like_dish(request):
|
|
|
|
|
# connection = get_database_connection()
|
|
|
|
|
# if request.method == 'POST':
|
|
|
|
|
# dish_name = request.POST.get('dish')
|
|
|
|
|
# with connection.cursor() as cursor:
|
|
|
|
|
# cursor.execute("UPDATE MainDishList SET LikeNumber = LikeNumber + 1 WHERE DishName = %s", [dish_name])
|
|
|
|
|
# cursor.execute("SELECT LikeNumber FROM MainDishList WHERE DishName = %s", [dish_name])
|
|
|
|
|
# updated_like_number = cursor.fetchone()[0]
|
|
|
|
|
# return JsonResponse({'likeNumber': updated_like_number})
|
|
|
|
|
#
|
|
|
|
|
#
|
|
|
|
|
# def collect_dish(request):
|
|
|
|
|
# connection = get_database_connection()
|
|
|
|
|
# if request.method == 'POST':
|
|
|
|
|
# dish_name = request.POST.get('dish')
|
|
|
|
|
# with connection.cursor() as cursor:
|
|
|
|
|
# cursor.execute("UPDATE MainDishList SET CollectNumber = CollectNumber + 1 WHERE DishName = %s", [dish_name])
|
|
|
|
|
# cursor.execute("SELECT CollectNumber FROM MainDishList WHERE DishName = %s", [dish_name])
|
|
|
|
|
# updated_collect_number = cursor.fetchone()[0]
|
|
|
|
|
# return JsonResponse({'collectNumber': updated_collect_number})
|
|
|
|
|
def main_page(request):
|
|
|
|
|
dishes = MainDishList.objects.all()
|
|
|
|
|
return render(request, 'mainpage.html', {'dishes': dishes})
|
|
|
|
|