Skip to content

Commit f41798d

Browse files
committed
Merge branch 'dev'
2 parents d16c4f7 + 49496ec commit f41798d

24 files changed

Lines changed: 1409 additions & 5 deletions

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,7 @@ webapp/public/js/register.js
3636
#
3737

3838
**/.env
39+
services/gorush/config.yml
40+
services/gorush/*.pem
41+
services/gorush/*.p12
42+
.vscode/

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"python.pythonPath": "/usr/local/bin/python3.6"
2+
"python.pythonPath": "/Users/andrew/.virtualenvs/HackFSU/bin/python"
33
}

api/api/urls.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@
6262

6363
url(r'events$', views.scan.ScanEventsView.as_view(), name='scan-events'),
6464
url(r'events/scan$', views.scan.ScanUploadView.as_view(), name='scan-upload'),
65+
66+
url(r'push/new$', views.push.CreatePushView.as_view(), name='push-new'),
6567
]
6668

6769

api/api/views/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@
99
from . import attendee
1010
from . import preview
1111
from . import scan
12+
from . import push

api/api/views/push/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from .create import CreatePushView

api/api/views/push/create.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
"""
2+
Proxy a new push notification to the push service
3+
and then gorush. Maybe save as update.
4+
"""
5+
6+
from django import forms
7+
from django.conf import settings
8+
from django.contrib.auth.models import User
9+
from django.utils import timezone
10+
from hackfsu_com.views.generic import ApiView
11+
from hackfsu_com.util.forms import JsonField
12+
from hackfsu_com.util import acl
13+
from api.models import HackathonUpdate, Hackathon
14+
15+
import requests
16+
17+
class CreatePushView(ApiView):
18+
class RequestForm(forms.Form):
19+
title = forms.CharField()
20+
body = forms.CharField()
21+
isUpdate = forms.IntegerField()
22+
23+
http_method_names = ['post']
24+
request_form_class = RequestForm
25+
access_manager = acl.AccessManager(acl_accept=[acl.group_organizer])
26+
27+
def work(self, request, req, res):
28+
url = "{}/push/new".format(settings.PUSH_HOST)
29+
payload = {
30+
'title': req['title'],
31+
'message': req['body']
32+
}
33+
resp = requests.post(url, json=payload)
34+
35+
36+
# Optional save as HackathonUpdate
37+
if req['isUpdate'] is 1:
38+
update = HackathonUpdate(
39+
hackathon=Hackathon.objects.current(),
40+
title=req['title'],
41+
content=req['body']
42+
)
43+
update.save()

api/api/views/scan/events.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from hackfsu_com.views.generic import ApiView
99
from hackfsu_com.util.forms import JsonField
1010
from hackfsu_com.util import acl
11-
from api.models import Hackathon, ScanEvent, ScanRecord, UserInfo
11+
from api.models import Hackathon, ScanEvent, ScanRecord, UserInfo, HackerInfo
1212
from api.models.attendee_status import AttendeeStatusManager
1313

1414
class ScanEventsView(ApiView):
@@ -76,6 +76,18 @@ def work(self, request, req, res):
7676
current_hackathon = Hackathon.objects.current()
7777
attendee_info = AttendeeStatusManager.get_or_create(user, current_hackathon)
7878

79+
# If hacker, make sure they are approved
80+
try:
81+
hacker_info = HackerInfo.objects.get(hackathon=current_hackathon, user=user)
82+
if not hacker_info.approved:
83+
res['name'] = name
84+
res['message'] = "{} was not accepted.".format(name)
85+
res['status'] = 401
86+
return
87+
except:
88+
pass
89+
90+
7991
attendee_info.checked_in_at = timezone.now()
8092
attendee_info.save()
8193

api/api/views/user/get/profile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def work(self, request, req, res):
5151
code, qr = user_info.hexcode, user_info.qr_url
5252

5353
if not code or not qr:
54-
url = "http://{}/hacker/{}".format(settings.QR_HOST, request.user.email)
54+
url = "{}/hacker/{}".format(settings.QR_HOST, request.user.email)
5555
resp = requests.get(url)
5656

5757
if resp.status_code in (200, 201):

api/entrypoint.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22

33
python manage.py collectstatic --noinput
44
service nginx start
5+
service nginx status
56
python manage.py runserver 0.0.0.0:8000

api/hackfsu_com/keys.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
MANDRILL_SMTP_PASSWORD = str()
2525
ADMIN_EMAIL = str()
2626
QR_HOST = str()
27+
PUSH_HOST = str()
2728
HTTP_HOSTNAME = str()
2829

2930

@@ -43,6 +44,7 @@ def load_secret_keys():
4344
global MANDRILL_SMTP_PASSWORD
4445
global ADMIN_EMAIL
4546
global QR_HOST
47+
global PUSH_HOST
4648
global HTTP_HOSTNAME
4749

4850
def load_key(key):
@@ -67,6 +69,7 @@ def load_key(key):
6769
MANDRILL_SMTP_PASSWORD = load_key('MANDRILL_SMTP_PASSWORD')
6870
ADMIN_EMAIL = load_key('ADMIN_EMAIL')
6971
QR_HOST = load_key('QR_HOST')
72+
PUSH_HOST = load_key('PUSH_HOST')
7073
HTTP_HOSTNAME = load_key('HTTP_HOSTNAME')
7174

7275
load_secret_keys()

0 commit comments

Comments
 (0)