Skip to content
Open
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
4 changes: 2 additions & 2 deletions esp/esp/accounting/controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -656,11 +656,11 @@ def link_paid_transfers(self, payment):
raise ValueError("Transfers do not sum to target: %.2f" % target_full)

@staticmethod
def updatePaid(program, user, paid=True):
def updatePaid(program, user, paid=True, in_full=False):
""" Create an invoice for the user and, if paid is True, create a receipt showing
that they have paid all of the money they owe for the program. """
iac = IndividualAccountingController(program, user)
if not iac.has_paid():
if not iac.has_paid(in_full):
iac.ensure_required_transfers()
if paid:
iac.submit_payment(iac.amount_due())
Expand Down
6 changes: 5 additions & 1 deletion esp/esp/program/modules/forms/onsite.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ def __init__(self, *args, **kwargs):
[('', '')] + [(x, x) for x in ESPUser.grade_options()])

class OnsiteBarcodeCheckinForm(forms.Form):
uids = forms.CharField(label='', widget=forms.Textarea(attrs={'rows': 10}))
uids = forms.CharField(label = 'User IDs', widget=forms.Textarea(attrs={'rows': 10}))
attended = forms.BooleanField(label = "Attending? (i.e. here right now?)", required = False, initial = True)
med = forms.BooleanField(label = "Medical Form?", required = False, initial = False)
liab = forms.BooleanField(label = "Liability Form?", required = False, initial = False)
paid = forms.BooleanField(label = "Paid in Full?", required = False, initial = False)

class TeacherCheckinForm(forms.Form):
when = forms.DateTimeField(label='Date/Time', widget=DateTimeWidget, required = False)
Expand Down
52 changes: 34 additions & 18 deletions esp/esp/program/modules/handlers/onsitecheckinmodule.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def module_properties(cls):
}

def updatePaid(self, paid=True):
IndividualAccountingController.updatePaid(self.program, self.student, paid)
IndividualAccountingController.updatePaid(self.program, self.student, paid, in_full=True)

def create_record(self, event):
created = False
Expand All @@ -71,9 +71,9 @@ def create_record(self, event):
rec = Record(user=self.student, event=rt, program=self.program)
rec.save()
created = True
elif event=="paid":
self.updatePaid(True)
else:
if event=="paid":
self.updatePaid(True)
rt = RecordType.objects.get(name=event)
recs, created = Record.objects.get_or_create(user=self.student,
event=rt,
Expand Down Expand Up @@ -214,7 +214,7 @@ def rapidcheckin(self, request, tl, one, two, module, extra, prog):
def barcodecheckin(self, request, tl, one, two, module, extra, prog):
context = {}
if request.method == 'POST':
results = {'not_found': [], 'existing': [], 'new': [], 'not_student': []}
results = {'not_found': [], 'existing': [], 'new': [], 'not_student': [], 'paid': [], 'liab': [], 'med': []}
form = OnsiteBarcodeCheckinForm(request.POST)
if form.is_valid():
codes=form.cleaned_data['uids'].split()
Expand All @@ -226,13 +226,18 @@ def barcodecheckin(self, request, tl, one, two, module, extra, prog):
continue

if student.isStudent():
if prog.isCheckedIn(student):
results['existing'].append(code)
else:
rt = RecordType.objects.get(name="attended")
new = Record(user=student, program=prog, event=rt)
new.save()
results['new'].append(code)
self.student = student
for key in ['attended', 'paid', 'liab', 'med']:
if form.cleaned_data[key]:
if key == "attended":
if prog.isCheckedIn(student):
results['existing'].append(code)
else:
self.create_record(key)
results['new'].append(code)
else:
created = self.create_record(key)
results[key].append(code)
else:
results['not_student'].append(code)
else:
Expand All @@ -250,6 +255,10 @@ def ajaxbarcodecheckin(self, request, tl, one, two, module, extra, prog):
POST to this view to check-in a student with a user ID.
POST data:
'code': The student's ID.
'attended': Whether to set an 'attended' record.
'paid': Whether to mark the remainder of the student's as paid.
'med': Whether to set a 'med' record.
'liab': Whether to set a 'liab' record.
"""
json_data = {}
if request.method == 'POST' and 'code' in request.POST:
Expand All @@ -261,13 +270,20 @@ def ajaxbarcodecheckin(self, request, tl, one, two, module, extra, prog):
student = students[0]
info_string = student.name() + " (" + str(code) + ")"
if student.isStudent():
if prog.isCheckedIn(student):
json_data['message'] = '%s is already checked in!' % info_string
else:
rt = RecordType.objects.get(name="attended")
new = Record(user=student, program=prog, event=rt)
new.save()
json_data['message'] = '%s is now checked in!' % info_string
self.student = student
messages = []
for key in ['attended', 'paid', 'liab', 'med']:
if request.POST.get(key) == "true":
if key == "attended":
if prog.isCheckedIn(student):
messages.append('%s is already checked in!' % info_string)
else:
self.create_record(key)
messages.append('%s is now checked in!' % info_string)
else:
self.create_record(key)
messages.append('%s record set for %s' % (key, info_string))
json_data['message'] = "\n".join(messages)
else:
json_data['message'] = '%s is not a student!' % info_string
return HttpResponse(json.dumps(json_data), content_type='text/json')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,17 @@
Quagga.onDetected(function(result) {
var code = result.codeResult.code;
var autocheckin = document.getElementById("autocheckinbox");
var data = {}
$j('#checkinform input[type="checkbox"]').each(function() {
data[this.name] = this.checked;
});

if (App.lastResult !== code) {
App.lastResult = code;
beep();
if (autocheckin.checked){
var data = {code: code, csrfmiddlewaretoken: csrf_token()};
data["code"] = code;
data["csrfmiddlewaretoken"] = csrf_token();
$j.post('ajaxbarcodecheckin', data, function(result) {
if (result.hasOwnProperty('message')) {
var message = result.message;
Expand Down Expand Up @@ -51,42 +56,61 @@ <h1>Barcode Checkin &mdash; For {{ program.niceName }}</h1>
</p>

{% if results %}
<p>
Checked in {{ results.new|length }} students. {{ results.not_found|length }} students were not found, {{ results.existing|length }} students were already checked in, and {{ results.not_student|length }} IDs did not correspond to students.
</p>
{% if results.not_found %}
<p>
Students not found:
{% for id in results.not_found %}
{{ id }}{% if not forloop.last %},{% endif %}
{% endfor %}
</p>
{% endif %}
{% if results.not_student %}
<p>
IDs not corresponding to students:
{% for id in results.not_student %}
{{ id }}{% if not forloop.last %},{% endif %}
{% endfor %}
</p>
{% endif %}
{% comment %}
{% if results.existing %}
<p>
IDs already checked in:
{% for id in results.existing %}
{{ id }}{% if not forloop.last %},{% endif %}
{% endfor %}
</p>
{% endif %}
{% endcomment %}
<div class="alert alert-info">
<span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span>
<span>
Checked in {{ results.new|length }} students. {{ results.not_found|length }} students were not found, {{ results.existing|length }} students were already checked in, and {{ results.not_student|length }} IDs did not correspond to students.
</span>
{% if results.paid %}
<span>
{{ results.paid|length }} student(s) paid.
</span>
{% endif %}
{% if results.liab %}
<span>
{{ results.liab|length }} student(s) handed in their liability waiver.
</span>
{% endif %}
{% if results.med %}
<span>
{{ results.med|length }} student(s) handed in their medical waiver.
</span>
{% endif %}
{% if results.not_found %}
<span>
Students not found:
{% for id in results.not_found %}
{{ id }}{% if not forloop.last %},{% endif %}
{% endfor %}
</span>
{% endif %}
{% if results.not_student %}
<span>
IDs not corresponding to students:
{% for id in results.not_student %}
{{ id }}{% if not forloop.last %},{% endif %}
{% endfor %}
</span>
{% endif %}
{% comment %}
{% if results.existing %}
<span>
IDs already checked in:
{% for id in results.existing %}
{{ id }}{% if not forloop.last %},{% endif %}
{% endfor %}
</span>
{% endif %}
{% endcomment %}
</div>
{% endif %}

<form id="checkinform" name="checkinform" method="POST" action="{{ request.path }}">
{{ form.as_p }}
<p class="ids">
<input type="submit" value="Submit" />
</p>
<table style="width: unset;">
{{ form.as_table }}
<tr><td colspan="2"><input type="submit" value="Submit" /></td></tr>
</table>

</form>

<br><br>
Expand All @@ -101,7 +125,7 @@ <h1>Barcode Checkin &mdash; For {{ program.niceName }}</h1>
<option value="i2of5_reader">Interleaved 2 of 5</option>
</select>
<br><br>
<input type="checkbox" id="autocheckinbox" value="autocheckin" checked> Auto-checkin scanned barcodes<br>
<input type="checkbox" class="btn" id="autocheckinbox" value="autocheckin" checked><label for="autocheckinbox">Auto-checkin scanned barcodes</label><br>
</div>
<div class="overlay overlay--inline">
<div class="overlay__content viewport" id="interactive">
Expand Down
Loading