Skip to content

Commit

Permalink
Merge pull request #125 from NIAEFEUP/fix/schedule-api-broken-date
Browse files Browse the repository at this point in the history
fix: schedule api broken date
  • Loading branch information
tomaspalma authored Jan 8, 2025
2 parents 47b6911 + a0db2b0 commit c046582
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 14 deletions.
12 changes: 6 additions & 6 deletions django/university/controllers/SigarraController.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ def get_student_photo_url(self, nmec) -> str:
def semester_weeks(self):
currdate = date.today()
year = str(currdate.year)
first_semester = currdate.month >= 9 and currdate.month <= 12
first_semester = currdate.month >= 10 or currdate.month <= 1
if first_semester:
semana_ini = "1001"
semana_fim = "1231"
semana_ini = "20241001"
semana_fim = "20250131"
else:
semana_ini = "0210"
semana_fim = "0601"
semana_ini = year + "0210"
semana_fim = year + "0601"

return (year + semana_ini, year + semana_fim)
return (semana_ini, semana_fim)

def student_schedule_url(self, nmec, semana_ini, semana_fim) -> str:
return f"https://sigarra.up.pt/feup/pt/mob_hor_geral.estudante?pv_codigo={nmec}&pv_semana_ini={semana_ini}&pv_semana_fim={semana_fim}"
Expand Down
3 changes: 0 additions & 3 deletions django/university/exchange/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,11 @@ def create_marketplace_exchange_on_db(exchanges, curr_student):


def build_marketplace_submission_schedule(schedule, submission, auth_student):
print("Current auth student: ", auth_student)
for exchange in submission:
course_unit = exchange["courseUnitId"]
class_auth_student_goes_to = exchange["classNameRequesterGoesTo"]
class_auth_student_goes_from = exchange["classNameRequesterGoesFrom"]

print("schedule is: ", schedule[auth_student])

auth_user_valid = (class_auth_student_goes_from, course_unit) in schedule[auth_student]
if not(auth_user_valid):
return (ExchangeStatus.STUDENTS_NOT_ENROLLED, None)
Expand Down
1 change: 0 additions & 1 deletion django/university/routes/MarketplaceExchangeView.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ def submit_marketplace_exchange_request(self, request):
exchanges = request.POST.getlist('exchangeChoices[]')
exchanges = list(map(lambda exchange : json.loads(exchange), exchanges))

print("Marketplace exchange: ", exchanges)
curr_student = request.user.username
sigarra_res = SigarraController().get_student_schedule(curr_student)

Expand Down
1 change: 0 additions & 1 deletion django/university/routes/auth/InfoView.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ def get(self, request):
request.user.username
)


eligible_exchange = bool(eligible_course_units)

return JsonResponse({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ def build_pagination_payload(self, request, exchanges):
paginator = Paginator(exchanges, 10)
page_obj = paginator.get_page(page_number if page_number != None else 1)

for exchange in page_obj:
print(type(exchange) == MarketplaceExchange)

return {
"page": {
"current": page_obj.number,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def get(self, request):
return HttpResponse(status=sigarra_res.status_code)

schedule_data = sigarra_res.data

old_schedule = hashlib.sha256(json.dumps(schedule_data, sort_keys=True).encode()).hexdigest()

update_schedule_accepted_exchanges(request.user.username, schedule_data)
Expand Down

0 comments on commit c046582

Please sign in to comment.