Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copy scanner code and changes from template repo #31

Merged
merged 4 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 82 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: CI/CD

on:
pull_request_target:
branches:
- '**'

jobs:
backend-checks:
runs-on: ubuntu-latest
defaults:
run:
working-directory: hackathon_site

steps:
- uses: actions/checkout@v2
with:
ref: ${{github.event.pull_request.head.ref}}
repository: ${{github.event.pull_request.head.repo.full_name}}
- name: Set up Python 3.8
uses: actions/setup-python@v1
with:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Check formatting with Black
run: |
# Stop the build if there are any formatting issues picked up by Black
black --check .
- name: Tests
env:
SECRET_KEY: ${{ secrets.DJANGO_SECRET_KEY }}
DEBUG: 0
run: python manage.py test --settings=hackathon_site.settings.ci

template-checks:
runs-on: ubuntu-latest
defaults:
run:
working-directory: hackathon_site

steps:
- uses: actions/checkout@v2
with:
ref: ${{github.event.pull_request.head.ref}}
repository: ${{github.event.pull_request.head.repo.full_name}}
- name: Use Node.js 12.x
uses: actions/setup-node@v1
with:
node-version: '12.x'
- name: Install dependencies
run: yarn install
- name: Formatting check
run: yarn run prettier-check

dashboard-checks:
runs-on: ubuntu-latest
defaults:
run:
working-directory: hackathon_site/dashboard/frontend

steps:
- uses: actions/checkout@v2
with:
ref: ${{github.event.pull_request.head.ref}}
repository: ${{github.event.pull_request.head.repo.full_name}}
- name: Use Node.js 12.x
uses: actions/setup-node@v1
with:
node-version: '12.x'
- name: Install dependencies
run: yarn install
- name: Formatting check
run: yarn prettier --check 'src/**/*.(js|ts|tsx|scss)'
- name: Typescript check
run: yarn run tsc
- name: Tests
run: yarn test --watchAll=false
- name: Build frontend
run: yarn run build
2 changes: 1 addition & 1 deletion deployment/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ then
else
echo "Failed to connect to database"
exit 1
fi
fi
1 change: 0 additions & 1 deletion hackathon_site/dashboard/frontend/src/api/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ export const teamOrderListSerialization = (
id: order.id,
hardwareInOrder: returnedHardware,
});

const hardwareInTableRow = Object.values(hardwareItems);
if (hardwareInTableRow.length > 0)
(order.status === "Submitted" || order.status === "Ready for Pickup"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
mockReturnedOrdersInTable,
} from "testing/mockData";
import { ReturnOrderInTable } from "api/types";
import { getAllByText } from "@testing-library/react";
import { getAllByText, queryAllByText } from "@testing-library/react";

describe("<PendingTables />", () => {
it("Shows pending items and status chip", () => {
Expand Down
25 changes: 24 additions & 1 deletion hackathon_site/event/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from import_export import resources
from import_export.admin import ExportMixin

from event.models import Profile, Team as EventTeam, User
from event.models import Profile, Team as EventTeam, User, UserActivity
from hardware.admin import OrderInline

admin.site.unregister(User)
Expand Down Expand Up @@ -96,5 +96,28 @@ def get_members_count(self, obj):
return obj.members_count


@admin.register(UserActivity)
class UserActivityAdmin(ExportMixin, admin.ModelAdmin):
list_display = (
"get_user_name",
"sign_in",
"lunch1",
"dinner1",
"breakfast2",
"lunch2",
)

def get_user_name(self, obj):
return f"{obj.user.first_name} {obj.user.last_name}"

get_user_name.short_description = "Name"

def get_queryset(self, request):
return super().get_queryset(request).select_related("user")

def get_export_queryset(self, request):
return super().get_queryset(request).select_related("user")


# Register your models here.
admin.site.register(Profile)
128 changes: 128 additions & 0 deletions hackathon_site/event/jinja2/event/admin_qr_scanner.html
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 %}
3 changes: 2 additions & 1 deletion hackathon_site/event/jinja2/event/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<link rel="icon" type="image/png" sizes="32x32" href="{{ static('event/images/favicon/favicon-32x32.png') }}">
<link rel="icon" type="image/png" sizes="16x16" href="{{ static('event/images/favicon/favicon-16x16.png') }}">
<meta name="theme-color" content="#ffffff">
<link href="https://fonts.googleapis.com/css?family=Roboto:400,400i,500,700,900|Nunito:400,500,700,900&display=swap" rel="stylesheet">

<title>{% block title %}{{ hackathon_name }} {{ localtime(event_start_date).strftime("%Y") }}{% endblock %}</title>
<link rel="stylesheet" type="text/css" href="{{ static('event/styles/css/styles.css') }}" />
Expand Down Expand Up @@ -72,4 +73,4 @@
<script src="{{ static('event/js/main.js') }}"></script>
{% block scripts %}{% endblock %}
</body>
</html>
</html>
2 changes: 1 addition & 1 deletion hackathon_site/event/jinja2/event/change_password.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@
<div class="col s12 center">
Something wrong? <a href="mailto:{{ contact_email }}" class="primaryText hoverLink">Contact us</a>.
</div>
{% endblock %}
{% endblock %}
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ <h1 class="formH1">Success</h1>
</div>
</div>
</div>
{% endblock %}
{% endblock %}
66 changes: 66 additions & 0 deletions hackathon_site/event/jinja2/event/dashboard_admin.html
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 %}
Loading
Loading