generated from ieeeuoft/hackathon-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from ieeeuoft/qr-code-scanner
Add Qr code scanner code
- Loading branch information
Showing
13 changed files
with
1,258 additions
and
19 deletions.
There are no files selected for viewing
128 changes: 128 additions & 0 deletions
128
hackathon_site/event/jinja2/event/admin_qr_scanner.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
{% extends "event/base.html" %} | ||
|
||
{% block nav_links %} | ||
<li><a href="{{ url("event:dashboard") }}" class="active">Dashboard</a></li> | ||
<li><a href="{{ url("event:change_password") }}">Change Password</a></li> | ||
{% endblock %} | ||
|
||
{% block body %} | ||
<div class="ombreBackgroundDark3"> | ||
<div class="container"> | ||
<div class="section"> | ||
<div class="borderTopDiv z-depth-3"> | ||
|
||
{% if get_messages(request) %} | ||
{% for message in get_messages(request) %} | ||
<p id="submitMessage" class="banner banner{{ message.tags }}"> {{ message }} </p> | ||
{% endfor %} | ||
{% endif %} | ||
|
||
<h1 class="formH1">QR Scanner for Sign-In</h1> | ||
{% if get_curr_sign_in_time(true) %} | ||
<p class="banner bannerinfo"> Current sign in event: <b>{{ get_curr_sign_in_time(true) }}</b> </p> | ||
{% else %} | ||
<p class="banner bannerwarning"> There is currently no event to sign in </p> | ||
{% endif %} | ||
|
||
<video id="scanner" style="width: 100%; max-height: 250px; margin: 10px auto"></video> | ||
|
||
<br/> | ||
|
||
{% if not sign_in_form %} | ||
<h4 class="errorText" style="text-align: center"> {{ hackathon_name }} is not happening now </h4> | ||
{% else %} | ||
<div id="studentInfo"> | ||
<h2 class="formH1">Student Information</h2> | ||
<form method="post"> | ||
<table> | ||
<tr> | ||
<td>Name</td> | ||
<td id="studentName"></td> | ||
</tr> | ||
<tr> | ||
<td>Email</td> | ||
<td> | ||
{{ csrf_input }} | ||
<div class="input-field"> | ||
{{ sign_in_form.email }} | ||
|
||
{% if sign_in_form.email.errors %} | ||
<span class="formFieldError"> | ||
{% for error in sign_in_form.email.errors %} | ||
{{ error }} | ||
<br /> | ||
{% endfor %} | ||
</span> | ||
{% endif %} | ||
</div> | ||
</td> | ||
</tr> | ||
</table> | ||
{% if get_curr_sign_in_time() %} | ||
<button | ||
class="btn-large waves-effect waves-light colorBtn" style="margin-top: 15px" | ||
type="submit" id="signInButton"> | ||
Sign-In | ||
</button> | ||
{% endif %} | ||
</form> | ||
</div> | ||
{% endif %} | ||
|
||
<br/> | ||
|
||
<table> | ||
<tr> | ||
<th>Event</th> | ||
<th>Time</th> | ||
<th>Sign In Interval</th> | ||
<th>Scanned</th> | ||
</tr> | ||
{% for event in sign_in_times %} | ||
<tr class="{{'bannerinfo' if get_curr_sign_in_time() == event.name }}"> | ||
<td> {{ event.description }} </td> | ||
<td> {{ event.time.strftime("%H:%M, %b %d") }} </td> | ||
<td> {{ get_sign_in_interval(event.time) }} </td> | ||
<td> {{ sign_in_counts[event.name] }} </td> | ||
</tr> | ||
{% endfor %} | ||
</table> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
{% endblock %} | ||
|
||
{% block scripts %} | ||
<script src="{{ static('event/js/qr-scanner.umd.min.js') }}"></script> | ||
<script type="text/javascript"> | ||
const videoElem = document.getElementById("scanner"); | ||
let oldData = ''; | ||
|
||
const qrScanner = new QrScanner( | ||
videoElem, | ||
(result) => { | ||
if (result) { | ||
if (result.data !== oldData) { | ||
data = result.data.split(";"); | ||
$("#studentName").text(`${data[0]} ${data[1]}`); | ||
$("#id_email").val(data[2]); | ||
$("#studentInfo").show(); | ||
$("#submitMessage").text('') | ||
oldData = result.data; | ||
} | ||
} else { | ||
oldData = ''; | ||
$("#studentInfo").hide(); | ||
} | ||
}, | ||
{ | ||
onDecodeError: (error) => {}, | ||
highlightScanRegion: true, | ||
highlightCodeOutline: true, | ||
}, | ||
); | ||
qrScanner.setInversionMode('both'); | ||
qrScanner.start(); | ||
</script> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
{% extends "event/base.html" %} | ||
|
||
{% block nav_links %} | ||
<li><a href="{{ url("event:dashboard") }}" class="active">Dashboard</a></li> | ||
<li><a href="{{ url("event:change_password") }}">Change Password</a></li> | ||
{% endblock %} | ||
|
||
{% block body %} | ||
<div class="ombreBackgroundDark3"> | ||
<div class="container"> | ||
<div class="section"> | ||
<div class="borderTopDiv z-depth-3"> | ||
<h1 class="formH1">Admin Dashboard</h1> | ||
|
||
<h2 class="formH2">Administrative Actions</h2> | ||
<div class="btn-group-sm"> | ||
<a href="{{ url("event:qr-scanner") }}" class="btn-sm btn-small waves-effect waves-light colorBtn"> | ||
Scan QR Code | ||
</a> | ||
<a href="" class="btn-sm btn-small waves-effect waves-light colorBtn"> | ||
Review Applications | ||
</a> | ||
<a href="" class="btn-sm btn-small waves-effect waves-light colorBtn"> | ||
View Applications | ||
</a> | ||
</div> | ||
|
||
<br/> | ||
|
||
<h2 class="formH2">Export Data to Google Sheets</h2> | ||
<p>Clicking any of the below buttons will export the respective data to google sheets in this folder. Files will not be replaced, a new file will be created any time new data is exported.</p> | ||
<p>(Work In Progress)</p> | ||
<br/> | ||
<div class="btn-group-sm"> | ||
<button disabled class="btn-sm btn-small waves-effect waves-light colorBtn" | ||
type="submit">User Data</button> | ||
<button disabled class="btn-sm btn-small waves-effect waves-light colorBtn" | ||
type="submit">Application Data</button> | ||
<button disabled class="btn-sm btn-small waves-effect waves-light colorBtn" | ||
type="submit">Review Data</button> | ||
<button disabled class="btn-sm btn-small waves-effect waves-light colorBtn" | ||
type="submit">Sign-In Data</button> | ||
</div> | ||
</div> | ||
|
||
<div class="borderTopDiv z-depth-3"> | ||
<h1 class="formH1">Analytics</h1> | ||
<table> | ||
<tr> | ||
<td>Total number of sign-ups:</td> | ||
<td>345</td> | ||
</tr> | ||
<tr> | ||
<td>Total number of completed applications:</td> | ||
<td>215</td> | ||
</tr> | ||
<tr> | ||
<td>Total number of completed reviews:</td> | ||
<td>0</td> | ||
</tr> | ||
</table> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Generated by Django 3.2.15 on 2024-10-24 02:16 | ||
|
||
from django.conf import settings | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
("event", "0008_team_project_description"), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name="UserActivity", | ||
fields=[ | ||
( | ||
"id", | ||
models.AutoField( | ||
auto_created=True, | ||
primary_key=True, | ||
serialize=False, | ||
verbose_name="ID", | ||
), | ||
), | ||
("sign_in", models.DateTimeField(blank=True, null=True)), | ||
("lunch1", models.DateTimeField(blank=True, null=True)), | ||
("dinner1", models.DateTimeField(blank=True, null=True)), | ||
("breakfast2", models.DateTimeField(blank=True, null=True)), | ||
("lunch2", models.DateTimeField(blank=True, null=True)), | ||
( | ||
"user", | ||
models.OneToOneField( | ||
on_delete=django.db.models.deletion.CASCADE, | ||
to=settings.AUTH_USER_MODEL, | ||
), | ||
), | ||
], | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.