Skip to content

Commit

Permalink
Merge pull request #150 from hackupc/checkin_lopd
Browse files Browse the repository at this point in the history
Add button to say wether or not the hacker has signed the LOPD paper
  • Loading branch information
casassg authored Oct 12, 2017
2 parents 22049f5 + cb3370b commit 239fa43
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 1 deletion.
20 changes: 20 additions & 0 deletions checkin/migrations/0003_checkin_signed_lopd.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.4 on 2017-10-12 15:48
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('checkin', '0002_checkin'),
]

operations = [
migrations.AddField(
model_name='checkin',
name='signed_lopd',
field=models.BooleanField(default=False),
),
]
1 change: 1 addition & 0 deletions checkin/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class CheckIn(models.Model):
application = models.ForeignKey('register.Application')
user = models.ForeignKey(admin_models.User)
update_time = models.DateTimeField()
signed_lopd = models.BooleanField(default=False)

def save(self, force_insert=False, force_update=False, using=None,
update_fields=None):
Expand Down
6 changes: 5 additions & 1 deletion checkin/templates/checkin/hacker.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ <h4 class="text-center">{{ app.lennyface }}</h4>
{% include 'include/field.html' with desc='Shirt Size' value=hacker.tshirt_size %}
{% include 'include/field.html' with desc='Diet' value=hacker.diet %}
{% include 'include/field.html' with desc='Status' value=app.get_status_display %}
{% if checkin %}
{% include 'include/field.html' with desc='Have signed LOPD?' value=checkin.signed_lopd|yesno:'Yes,No,Maybe' %}
{% endif %}
</dl>
</div>
<div class="panel-footer">
Expand All @@ -35,7 +38,8 @@ <h4>Let's keep this up!</h4>
<form action="" method="post">
{% csrf_token %}
<input type="hidden" name="app_id" value="{{ app.id }}"/>
<button class="btn btn-success btn-block" name="checkin" value="checkin">Check In!</button>
<button class="btn btn-success btn-block" name="checkin" value="checkin_lopd">Check In and signed!</button>
<button class="btn btn-warning btn-block" name="checkin" value="checkin_nolopd">Check In but NO signature!</button>
</form>
<a class="btn btn-default btn-block" href="javascript:history.back()">Go back</a>
{% endif %}
Expand Down
6 changes: 6 additions & 0 deletions checkin/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,20 @@ def get_context_data(self, **kwargs):
'hacker': app.hacker,
'checkedin': app.status == models.APP_ATTENDED
})
try:
context.update({'checkin': CheckIn.objects.filter(application=app).first()})
except:
pass
return context

def post(self, request, *args, **kwargs):
appid = request.POST.get('app_id')
lopd_signed = request.POST.get('checkin') == 'checkin_lopd'
app = models.Application.objects.get(id=appid)
app.check_in()
ci = CheckIn()
ci.user = request.user
ci.application = app
ci.signed_lopd = lopd_signed
ci.save()
return HttpResponseRedirect(request.META.get('HTTP_REFERER'))

0 comments on commit 239fa43

Please sign in to comment.