Skip to content

Commit

Permalink
integrated with library logs through req
Browse files Browse the repository at this point in the history
  • Loading branch information
Pancham1603 committed Dec 2, 2023
1 parent fad4a9c commit bfb43a4
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions apps/validation/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from django.contrib.auth.decorators import login_required
import json
from datetime import datetime
import requests

# Create your views here.

Expand Down Expand Up @@ -93,6 +94,21 @@ def fetch_user_status(request):
'message':'Invalid!'
}
return HttpResponse(json.dumps(data))


def req_library_logs(registration_number):
req = requests.session()
url = "https://library.thapar.edu/inout/login_verify.php"
data = {
"name": "user",
"pass": "$#**123",
"loc": "TESTLIB",
"submit": "Login"
}
response = req.post(url, data=data, verify=False)
req.get(f"https://library.thapar.edu/inout/user.php?id={registration_number}")
req.close()


@csrf_exempt
@login_required
Expand All @@ -112,6 +128,8 @@ def check_out(request):
if type(admin_campus_resource) == Hostel:
return checkout_from_hostel(user_pass)
elif type(admin_campus_resource) == CampusResource:
if admin_campus_resource.name == 'Library':
req_library_logs(user.registration_number)
return checkout_from_location(user_pass)
except Student.DoesNotExist:
data = {
Expand Down Expand Up @@ -169,6 +187,8 @@ def check_in(request):
'message':'Pass does not exist!'
}
return HttpResponse(json.dumps(data))
if admin_campus_resource.name == 'Library':
req_library_logs(user.registration_number)
return checkin_to_location(user_pass)
except Student.DoesNotExist:
data = {
Expand Down

0 comments on commit bfb43a4

Please sign in to comment.