From 3df0581b3accdf1516673949a01470ec22bfba39 Mon Sep 17 00:00:00 2001 From: Pengwius Date: Mon, 21 Dec 2020 22:11:18 +0100 Subject: [PATCH] Optimizing homework display --- mypage/Wulkanowy/API/homework.py | 2 +- mypage/Wulkanowy/templatetags/custom_filters_tags.py | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/mypage/Wulkanowy/API/homework.py b/mypage/Wulkanowy/API/homework.py index a0deace..626782a 100644 --- a/mypage/Wulkanowy/API/homework.py +++ b/mypage/Wulkanowy/API/homework.py @@ -42,7 +42,7 @@ def get_homework(register_id, register_r, oun, s, school_year): year4 = str(now4.year) date4 = year4+'-'+month4+'-'+day4 - homework1 = s.post(oun+'/Homework.mvc/Get', headers={"User-Agent": "Wulkanowy-web :)"}, cookies=cookies, json={'schoolYear': school_year, 'date': date1, 'statusFilter': '-1'}) #'2020-09-28' + homework1 = s.post(oun+'/Homework.mvc/Get', headers={"User-Agent": "Wulkanowy-web :)"}, cookies=cookies, json={'schoolYear': school_year, 'date': date1, 'statusFilter': '-1'}) homework2 = s.post(oun+'/Homework.mvc/Get', headers={"User-Agent": "Wulkanowy-web :)"}, cookies=cookies, json={'schoolYear': school_year, 'date': date2, 'statusFilter': '-1'}) homework3 = s.post(oun+'/Homework.mvc/Get', headers={"User-Agent": "Wulkanowy-web :)"}, cookies=cookies, json={'schoolYear': school_year, 'date': date3, 'statusFilter': '-1'}) homework4 = s.post(oun+'/Homework.mvc/Get', headers={"User-Agent": "Wulkanowy-web :)"}, cookies=cookies, json={'schoolYear': school_year, 'date': date4, 'statusFilter': '-1'}) diff --git a/mypage/Wulkanowy/templatetags/custom_filters_tags.py b/mypage/Wulkanowy/templatetags/custom_filters_tags.py index a2b7a7a..faf5a89 100644 --- a/mypage/Wulkanowy/templatetags/custom_filters_tags.py +++ b/mypage/Wulkanowy/templatetags/custom_filters_tags.py @@ -51,15 +51,17 @@ def simple_data(exam): else: return mark_safe('Brak Sprawdzianów') +homework_all = None + @register.filter def week_homework(no): + global homework_all cookie = get_cookies() - homework_all = prepare_homework_for_display(cookie[0], cookie[1], cookie[2], cookie[3], cookie[5]) + if homework_all == None: + homework_all = prepare_homework_for_display(cookie[0], cookie[1], cookie[2], cookie[3], cookie[5]) homework = [] for i in range(4): homework.append(homework_all[i][no]) - - print(homework) - + return homework \ No newline at end of file