Skip to content
This repository has been archived by the owner on May 17, 2024. It is now read-only.

Commit

Permalink
Made the Print button on event registrations page work with the new…
Browse files Browse the repository at this point in the history
… printing work as per #42
  • Loading branch information
miteshashar committed Jul 26, 2013
1 parent 5296126 commit 9440be9
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 46 deletions.
16 changes: 8 additions & 8 deletions peopleflow/templates/participants.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ <h1>{{ event.title }}- Venue Signup. </h1>
<span class="unassign_confirm" data-url="{{ url_for('event_signout', event=event.id, participant=p.id) }}">Pls confirm (<span class="timeout"></span>)</span>
<span class="tap_card" data-url="{{ url_for('event_signin', event=event.id, participant=p.id) }}">Tap the card (<span class="timeout"></span>)</span>
</a>
<a class="btn print_card" data-url="{{ url_for('print_card') }}" data-method="POST" data-name='{{ p.name|e }}' data-twitter='{{ p.twitter }}'>Print</a>
<a class="btn print_card" data-url="{{ url_for('print_card', event=event.id, participant=p.id) }}" data-method="POST" data-id='{{ p.id }}'>Print</a>
</td>
</tr>
{% else %}
Expand All @@ -70,15 +70,15 @@ <h1>{{ event.title }}- Venue Signup. </h1>
$('a.print_card').on('click', function(event) {
$.ajax({
url: $(this).attr('data-url'),
data: {'name': $(this).attr('data-name'),
'twitter': $(this).attr('data-twitter')
},
data: {'id': $(this).attr('data-id')},
type: $(this).attr('data-method'),
success: function(data) {
console.log(data.msg);
},
failure: function(data){
console.log(data.msg);
if(data.status) {
toastr.success(data.msg);
}
else {
toastr.error(data.msg);
}
}
});
});
Expand Down
2 changes: 1 addition & 1 deletion peopleflow/views/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# -*- coding: utf-8 -*-

from . import index, user, login, event, participant, kiosk
from . import index, login, event, participant, kiosk
19 changes: 17 additions & 2 deletions peopleflow/views/participant.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
from .. import lastuser
from ..models import db, Event, Participant
from ..forms import ParticipantForm
from ..helpers.printlabel import printlabel, make_label_content
from datetime import datetime, timedelta
from time import strftime
from flask import request, flash, url_for, render_template
from coaster.views import load_model, jsonp
from flask import request, flash, url_for, render_template, jsonify
from coaster.views import load_model, load_models, jsonp
from baseframe.forms import render_redirect
from flask.ext.wtf import SelectMultipleField, widgets

Expand Down Expand Up @@ -66,6 +67,20 @@ def get_participant(event, nfc_id):
response = jsonp(error="invalid")
return response

@app.route('/event/<event>/participant/<participant>/print_card', methods=['POST'])
@lastuser.requires_permission(['kioskadmin', 'registrations'])
@load_models(
(Participant, {'event_id': 'event', 'id': 'participant'}, 'participant')
)
def print_card(participant):
try:
if 'PRINTER_NAME' in app.config:
printlabel(app.config['PRINTER_NAME'], make_label_content(participant))
return jsonify(status=True, msg=u"Card for %s queued for printing" % participant.name)
else:
return jsonify(status=False, msg=u"Printer not configured")
except:
return jsonify(status=False, msg=u"Card for %s queued for printing" % participant.name)

@app.route('/<eid>/search', methods=['POST'])
@load_model(Event,{'id':'eid'},'event')
Expand Down
35 changes: 0 additions & 35 deletions peopleflow/views/user.py

This file was deleted.

0 comments on commit 9440be9

Please sign in to comment.