✏️ Hackathon registration server
📝 Hackathon registration server. Originally HackUPC/backend. With collaboration from HackCU. Medium article. User Guide
Demo: http://registration.gerard.space (updated from master automatically. Running on Heroku free dyno)
Needs: Python 3.X, virtualenv
git clone https://github.com/hackassistant/registration && cd registration
virtualenv env --python=python3
source ./env/bin/activate
pip install -r requirements.txt
python manage.py migrate
python manage.py createsuperuser
(creates super user to manage all the app)Coming soon
os.urandom(24)
true
.client_id@client_secret
(See "Set up MyMLH" below)python manage.py runserver
You can deploy this project into heroku for free. You will need to verify your account to use the scheduler for automatic application expirations emails. See "Use in your hackathon" for more details on using in your hackathon.
python manage.py createsuperuser
once the heroku app is deployedpython manage.py expire_applications && python manage.py expire_reimbursements
Inspired on this tutorial to understand and set it up as in our server.
cp server.sh.template server.sh
chmod +x server.sh
cp restart.sh.template restart.sh
chmod +x restart.sh
restart.sh
. This will update the database, dependecies and static files.Needs: Systemd.
/etc/systemd/system/backend.service
[Unit]
Description=backend daemon
After=network.target
[Service]
User=user
Group=www-data
WorkingDirectory=/home/user/project_folder
ExecStart=/home/user/project_folder/server.sh >>/home/user/project_folder/out.log 2>>/home/user/project_folder/error.log
[Install]
WantedBy=multi-user.target
user
for your linux user.project_folder
by the name of the folder where the project is locatedsudo systemctl start backend && sudo systemctl enable backend
Needs: PostgreSQL installed
sudo -u postgres psql
CREATE DATABASE backend;
CREATE USER backenduser WITH PASSWORD 'password';
(make sure to include a strong password)ALTER ROLE backenduser SET client_encoding TO 'utf8';
ALTER ROLE backenduser SET default_transaction_isolation TO 'read committed';
ALTER ROLE backenduser SET timezone TO 'UTC';
GRANT ALL PRIVILEGES ON DATABASE myproject TO myprojectuser;
\q
Other SQL engines may be used, we recommend PostgreSQL for it's robustness. To use other please check this documentation for more information on SQL engines in Django.
Hackers data is really important. To ensure that you don't lose any data we encourage you to set up automatic backups. One option that is free and reliable is using the PostgresSQLDropboxBackup script.
Find the script and usage instructions here
This will need to be used for Heroku or some Docker deployments. File uploads sometimes don't work properly on containerized systems.
MyMLH is a centralized login system used by MLH. It makes it easier for hackers to sign up for more events without re-entering their data every time around.
This integration allows hackers to have part of their application completed using their information from MLH.
As of the moment, MyMLH can only be used to sign up. This decision is due to the fact that MyMLH can have accounts with emails not verified. This can be a security concern as someone could create an account with someone else's email and it would totally invalidate our verification email system. In that direction the approach taken is to extract fields and use them for the application during the sign up process.
https://DOMAIN//user/callback/mlh/
as a Redirect URI. Replace DOMAIN
for the domain used to deploy your system. Ex: http://registration.gerard.space/user/callback/mlh/
.Application ID
and Secret
fields, concatenated with a @
. Ex: application_id@secret
.Note that to test locally you will need to add a line where DOMAIN
is localhost:8000
.
Needs: Nginx
sudo vim /etc/nginx/sites-available/default
server {
listen 80;
listen [::]:80;
server_name my.hackupc.com;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
alias /home/user/project_folder/staticfiles/;
}
location /files/ {
alias /home/user/project_folder/files/;
}
location / {
include proxy_params;
proxy_pass http://unix:/home/user/project_folder/backend.sock;
}
}
git pull
./restart.sh
sudo service backend restart
cp management.sh.template management.sh
chmod +x management.sh
crontab -e
*/5 * * * * cd /home/user/project_folder/ && ./management.sh > /home/user/project_folder/management.log 2> /home/user/project_folder/management_err.log
Here are several queries that may be useful during the hackathon application process.
source ./env/bin/activate
python manage.py dbshell
Emails from users that have registered but have not completed the application.
SELECT u.email
FROM user_user u
WHERE NOT is_director AND NOT is_volunteer AND NOT is_organizer
AND u.id NOT IN
(SELECT a.user_id FROM applications_application a);
You can use this for your own hackathon. How?
You can update emails related to
Check all available variables at app/hackathon_variables.py.template. You can set the ones that you prefer at app/hackathon_variables.py
You can change the form, titles, texts in applications/forms.py
If you need extra labels for your hackathon, you can change the model and add your own fields.
python manage.py makemigrations
python manage.py migrate
Read these guidelines carefully.
By making a contribution, in any form (including, but not limited to, Issues and Pull Requests), you agree to abide by the Code of Conduct. Report any incidents to [email protected] and appropriate action will be taken against the offender after investigation.
MIT © Hackers@UPC