Skip to content

Commit

Permalink
latest version, added document check, cleaned login, new home page
Browse files Browse the repository at this point in the history
  • Loading branch information
PPNG06 committed Mar 25, 2022
1 parent e37c645 commit 8c9aa27
Show file tree
Hide file tree
Showing 33 changed files with 106 additions and 15 deletions.
Binary file modified db.sqlite3
Binary file not shown.
Binary file modified file_app/__pycache__/__init__.cpython-39.pyc
Binary file not shown.
Binary file modified file_app/__pycache__/admin.cpython-39.pyc
Binary file not shown.
Binary file modified file_app/__pycache__/apps.cpython-39.pyc
Binary file not shown.
Binary file modified file_app/__pycache__/forms.cpython-39.pyc
Binary file not shown.
Binary file modified file_app/__pycache__/models.cpython-39.pyc
Binary file not shown.
Binary file modified file_app/__pycache__/views.cpython-39.pyc
Binary file not shown.
Binary file modified file_app/migrations/__pycache__/0001_initial.cpython-39.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified file_app/migrations/__pycache__/0004_student.cpython-39.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified file_app/migrations/__pycache__/__init__.cpython-39.pyc
Binary file not shown.
19 changes: 15 additions & 4 deletions file_app/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def institution_sign_up(request):

registered = True

return reverse('institution_login')
return HttpResponseRedirect(reverse('institution_login'))
else:
return render(request,'institution_sign_up.html',{'user_form':user_form,'institution_form':institution_form})
else:
Expand Down Expand Up @@ -106,8 +106,19 @@ def student_login(request):
return render(request,'student_login.html',)

def certificate_check(request):
# maybe insert sth here
return render(request,'certificate_check.html')
if request.method == "POST":
issuer_wallet_id = request.POST['issuerId']
doc_link = request.POST['link']
print(issuer_wallet_id)
institution = Institution.objects.filter(wallet_id = "0x"+issuer_wallet_id).first()
if institution != None:
#successful
return render(request,'search_success.html',{'institution':institution,'document_link':doc_link,})
else:
#not found
return render(request,'certificate_check.html',{'err_message':'There is no verified institution that issued this certificate.'})
else:
return render(request,'certificate_check.html')

@login_required(login_url="/institution/login")
def institution_logout(request):
Expand All @@ -128,7 +139,7 @@ def upload_view(request):
# check whether it's valid:
if form.is_valid() and Student.objects.filter(student_id=request.POST['student_id']).first()!= None:
student = Student.objects.get(student_id=request.POST['student_id'])
Document.objects.get_or_create(institution = Institution.objects.get(user=request.user), document_name = form.cleaned_data['document_name'],student=student, document_link=request.POST['cid'])
Document.objects.get_or_create(institution = Institution.objects.get(user=request.user), document_hash_value = request.POST['hash_value'], document_name = form.cleaned_data['document_name'],student=student, document_link=request.POST['cid'])
return render(request,'success.html',{'document':Document.objects.get(institution = Institution.objects.get(user=request.user), document_name = form.cleaned_data['document_name'],student=student, document_link=request.POST['cid']),'student':student})
else:
return render(request,'upload.html', {'form': form,'institution':Institution.objects.get(user=request.user),'err_message':'Invalid receipt id'})
Expand Down
2 changes: 1 addition & 1 deletion static/most.js

Large diffs are not rendered by default.

Binary file modified switch_project/__pycache__/__init__.cpython-39.pyc
Binary file not shown.
Binary file modified switch_project/__pycache__/settings.cpython-39.pyc
Binary file not shown.
Binary file modified switch_project/__pycache__/urls.cpython-39.pyc
Binary file not shown.
Binary file modified switch_project/__pycache__/wsgi.cpython-39.pyc
Binary file not shown.
8 changes: 6 additions & 2 deletions templates/certificate_check.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ <h1 style="color:white;padding:1%" class="brand">Switch Learning</h1>
<ul class="navbar-nav mr-auto">
</ul>
<form class="form-inline my-2 my-lg-0">
<a href="{%url 'institution_logout'%}"><button type="button" class="btn btn-danger" name="button">Logout</button></a>
<a href="{%url 'home'%}"><button type="button" class="btn btn-primary" name="button">Home</button></a>
</form>
</div>
</nav>
Expand All @@ -33,7 +33,10 @@ <h1 style="color:white;padding:1%" class="brand">Switch Learning</h1>
<br>
<br>
<div class="jumbotron">
<h5>Zertifikat checken:</h5>
<h3>Check certificate:</h3>
<h5 style="color:red;">{{err_message}}</h5>
<br>

<div class="check">
<p>Provide the hash of a certificate to check whether it is verified and who was the original issuer.</p>
<div class="input-group">
Expand All @@ -44,6 +47,7 @@ <h5>Zertifikat checken:</h5>
</div>

</div>
{%csrf_token%}
<script type="module" crossorigin src="{%static 'most.js'%}"></script>
</body>
</html>
8 changes: 6 additions & 2 deletions templates/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,17 @@ <h1 style="font-family: 'Patua One', cursive;color:white;padding:1%" class="bran
<h1 style="text-align:center;font-family: 'Patua One', cursive; margin-top:5%; font-size:5em;">I am</h1>
<br>
<br>
<hr>
<br>
<div class="row">
<div class="col-sm" style="display:flex;justify-content:center;">
<a class="margin:auto;" href="{%url 'institution_login'%}"><button type="button" class="btn btn-block btn-lg btn-outline-primary" name="button">an Institution</button></a>
<a class="margin:auto;" href="{%url 'institution_login'%}"><button type="button" class="btn btn-block btn-lg btn-outline-primary" name="button">An Institution</button></a>
</div>
<div class="col-sm" style="display:flex;justify-content:center;">
<a class="margin:auto;" href="{%url 'certificate_check'%}"><button type="button" class="btn btn-block btn-lg btn-outline-primary" name="button">A Verifier</button></a>
</div>
<div class="col" style="display:flex;justify-content:center;">
<a href="{%url 'student_login'%}"><button type="button" class="btn btn-block btn-lg btn-outline-primary" name="button">a Student</button></a>
<a href="{%url 'student_login'%}"><button type="button" class="btn btn-block btn-lg btn-outline-primary" name="button">A Student</button></a>
</div>
</div>
</div>
Expand Down
3 changes: 3 additions & 0 deletions templates/institution_login.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ <h1 style="color:white;padding:1%" class="brand">Switch Learning</h1>
<a style="font-size:0.6em;" class="nav-link" href="{%url 'presentation'%}">What is Switch Learning?</a>
</li>
</ul>
<form style="margin-right:1%;" class="form-inline my-2 my-lg-0">
<a href="{%url 'home'%}"><button type="button" class="btn btn-primary" name="button">Home</button></a>
</form>
<form class="form-inline my-2 my-lg-0">
<a href="{%url 'institution_sign_up'%}"><button type="button" class="btn btn-primary" name="button">Sign up</button></a>
</form>
Expand Down
5 changes: 4 additions & 1 deletion templates/institution_sign_up.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ <h1 style="color:white;padding:1%" class="brand">Switch Learning</h1>
<a style="font-size:0.6em;" class="nav-link" href="{%url 'presentation'%}">What is Switch Learning?</a>
</li>
</ul>
<form style="margin-right:1%;" class="form-inline my-2 my-lg-0">
<a href="{%url 'home'%}"><button type="button" class="btn btn-primary" name="button">Home</button></a>
</form>
<form class="form-inline my-2 my-lg-0">
<a href="{%url 'institution_login'%}"><button type="button" class="btn btn-primary" name="button">Login</button></a>
</form>
Expand All @@ -34,7 +37,7 @@ <h1 style="color:white;padding:1%" class="brand">Switch Learning</h1>
<h1>Sign up as an institution</h1>
<h6 style="color:red;">{{err_message}}</h6>
<form enctype="multipart/form-data" method="post">
{%csrf_token%}
{% csrf_token %}
<div class="form-group">
<label for="id_username">Username (or school name):</label>
<input required class="form-control" type="text" name="username" placeholder="Your Institute's username" maxlength="150" required="" id="id_username">
Expand Down
6 changes: 3 additions & 3 deletions templates/presentation.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ <h1 style="font-family: 'Patua One', cursive;color:white;padding:1%" class="bran

<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav ml-auto">
<li class="nav-item">
<a style="font-size:0.6em;" class="nav-link" href="{%url 'home'%}">Home</a>
</li>
</ul>
<form style="margin-right:1%;" class="form-inline my-2 my-lg-0">
<a href="{%url 'home'%}"><button type="button" class="btn btn-primary" name="button">Home</button></a>
</form>
</div>
</nav>

Expand Down
50 changes: 50 additions & 0 deletions templates/search_success.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{%load static%}
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title></title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-zCbKRCUGaJDkqS1kPbPd7TveP5iyJE0EjAuZQTgFLD2ylzuqKfdKlfG/eSrtxUkn" crossorigin="anonymous">
<link rel="stylesheet" href="{%static 'style.css'%}">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Patua+One&display=swap" rel="stylesheet">
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark" style="font-family: 'Patua One', cursive; background-color:purple;font-size:2.5em;">
<h1 style="font-family: 'Patua One', cursive;color:white;padding:1%" class="brand">Switch Learning</h1>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>

<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav ml-auto">
<li class="nav-item">
<a style="font-size:0.6em;" class="nav-link" href="{%url 'presentation'%}">What is Switch Learning?</a>
</li>
</ul>
<form style="margin-right:1%;" class="form-inline my-2 my-lg-0">
<a href="{%url 'home'%}"><button type="button" class="btn btn-primary" name="button">Home</button></a>
</form>
</div>
</nav>
<div class="container">
<br>
<br>
<div class="jumbotron">
<div class="image" style="display:flex;justify-content:center;">
<img style="width:30%;" src="http:https://assets.stickpng.com/images/5aa78e207603fc558cffbf19.png" alt="">
</div>
<br>
<h3 style="color:green;">This hash exists and corresponds to a certificate issued by a verified institute!</h3>
<br>
<hr>
<br>
<h4>More information on the document:</h4>
<br>
<h5 style="color:black;">Institution name: {{institution}}</h5>
<h5 style="color:black;">Document view: <a href="{{document_link}}">Click here</a></h5>
</div>
</div>
</body>
</html>
5 changes: 4 additions & 1 deletion templates/student_login.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ <h1 style="color:white;padding:1%" class="brand">Switch Learning</h1>
<a style="font-size:0.6em;" class="nav-link" href="{%url 'presentation'%}">What is Switch Learning?</a>
</li>
</ul>
<form style="margin-right:1%;" class="form-inline my-2 my-lg-0">
<a href="{%url 'home'%}"><button type="button" class="btn btn-primary" name="button">Home</button></a>
</form>
<form class="form-inline my-2 my-lg-0">
<a href="{%url 'student_sign_up'%}"><button type="button" class="btn btn-primary" name="button">Sign up</button></a>
</form>
Expand All @@ -35,7 +38,7 @@ <h1>Student Login</h1>
<h6 style="color:red;">{{err_message}}</h6>
<br>
<form class="" action="{%url 'student_login'%}" method="post">
{%csrf_token%}
{% csrf_token %}
<div class="form-group">
<label for="username">Username: </label>
<input class="form-control" type="text" name="username" placeholder="Username" value="">
Expand Down
6 changes: 5 additions & 1 deletion templates/student_profile.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,12 @@ <h5>My records:</h5>
<div class="jumbotron second">
<div class="jumbotron">
<br>
{%for doc in student.document_set.all%}
<h5>{{doc}} ({{doc.institution}})</h5>
{%empty%}
<h5>No records yet</h5>
{%endfor%}
<div id="table">

</div>
</div>
</div>
Expand Down
3 changes: 3 additions & 0 deletions templates/student_sign_up.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ <h1 style="color:white;padding:1%" class="brand">Switch Learning</h1>
<a style="font-size:0.6em;" class="nav-link" href="{%url 'presentation'%}">What is Switch Learning?</a>
</li>
</ul>
<form style="margin-right:1%;" class="form-inline my-2 my-lg-0">
<a href="{%url 'home'%}"><button type="button" class="btn btn-primary" name="button">Home</button></a>
</form>
<form class="form-inline my-2 my-lg-0">
<a href="{%url 'student_login'%}"><button type="button" class="btn btn-primary" name="button">Login</button></a>
</form>
Expand Down
3 changes: 3 additions & 0 deletions templates/success.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ <h1 style="color:white;padding:1%" class="brand">Switch Learning</h1>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
</ul>
<form style="margin-right:1%;" class="form-inline my-2 my-lg-0">
<a href="{%url 'home'%}"><button type="button" class="btn btn-primary" name="button">Home</button></a>
</form>
<form class="form-inline my-2 my-lg-0">
<a href="{%url 'institution_logout'%}"><button type="button" class="btn btn-danger" name="button">Logout</button></a>
</form>
Expand Down
3 changes: 3 additions & 0 deletions templates/upload.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ <h1 style="color:white;padding:1%" class="brand">Switch Learning</h1>
<a class="nav-link" style="font-size:0.7em;" href="{%url 'institution_profile'%}">Institution</a>
</li>
</ul>
<form style="margin-right:1%;" class="form-inline my-2 my-lg-0">
<a href="{%url 'home'%}"><button type="button" class="btn btn-primary" name="button">Home</button></a>
</form>
<form class="form-inline my-2 my-lg-0">
<a href="{%url 'institution_logout'%}"><button type="button" class="btn btn-danger" name="button">Logout</button></a>
</form>
Expand Down

0 comments on commit 8c9aa27

Please sign in to comment.