Exemplo n.º 1
0
def envelope_print(meeting_id, person_id):
    app = flask.current_app

    meeting = sugar.get_object_or_404(models.Meeting, id=meeting_id)
    person = sugar.get_person_or_404(meeting_id, person_id)
    secretariat = refdata.secretariat

    temp = path(tempfile.mkdtemp())
    flask.g.pdf_compatible = True
    country_names = []

    try:
      country_names = refdata.translated_country_names[
          person.data['personal_country']]
    except KeyError:
      pass

    context = dict(meeting=meeting,
                   person=person,
                   path=app.root_path,
                   secretariat=secretariat,
                   country_names=country_names)

    return sugar.render_pdf('participant/person_envelope.html',
                            temp=temp,
                            height='6.4in',
                            width='9.0in',
                            context=context,
                            filename=secure_filename(person.name),
                            use_wkhtmltopdf=True)
Exemplo n.º 2
0
def badge_misc_pdf(meeting_id, badge_type):
    meeting = sugar.get_object_or_404(models.Meeting, id=meeting_id)
    temp = path(tempfile.mkdtemp())
    app = flask.current_app

    if badge_type == 'visitor':
        category = models.Category.select().where(
            data__contains={'name_E': 'Visitor'}).get()
    elif badge_type == 'security':
        category = models.Category.select().where(
            data__contains={'name_E': 'Security'}).get()
    elif badge_type == 'exhibitor':
        category = models.Category.select().where(
            data__contains={'name_E': 'Exhibitor'}).get()
    elif badge_type == 'host_government':
        category = models.Category.select().where(
            data__contains={'name_E': 'Host Government'}).get()
    elif badge_type == 'local_staff':
        category = models.Category.select().where(
            data__contains={'name_E': 'Local staff'}).get()
    else:
        flask.abort(400)

    context = {
        'meeting': meeting,
        'category': category,
        'badge_type': badge_type,
        'path': app.root_path,
        'background_path': app.config['UPLOADED_BACKGROUNDS_DEST'],
    }

    return sugar.render_pdf('participant/badge_misc_simple.html', temp=temp,
                             height="2.15in", width="3.4in", context=context,
                             filename=sugar.random_string(6),
                             use_wkhtmltopdf=True)
Exemplo n.º 3
0
def badge_print(meeting_id, person_id, person_type):
    app = flask.current_app
    meeting = sugar.get_object_or_404(models.Meeting, id=meeting_id)

    if person_type == 'person':
        person = sugar.get_person_or_404(meeting_id, person_id)
    else:
        person = sugar.get_media_person_or_404(meeting_id, person_id)
    badge = flask.request.args.get('badge', None)

    # create a temporary folder and save participant photo to disk
    temp = path(tempfile.mkdtemp())
    photo = person.data.get('photo', None)

    if photo:
        person.photo_url = app.config['UPLOADED_PHOTOS_DEST'] / photo
    else:
        person.photo_url = None

    # save badge as html
    context = dict(meeting=meeting, person=person, path=app.root_path,
                   background_path=app.config['UPLOADED_BACKGROUNDS_DEST'],
                   badge=badge, person_type=person_type)
    return sugar.render_pdf("participant/person_badge_simple.html", temp=temp,
                             height="2.15in", width="3.4in", context=context,
                             filename=secure_filename(person.name),
                             use_wkhtmltopdf=True)
Exemplo n.º 4
0
def badge_print(meeting_id, person_id, person_type):
    app = flask.current_app
    meeting = sugar.get_object_or_404(models.Meeting, id=meeting_id)

    if person_type == 'person':
        person = sugar.get_person_or_404(meeting_id, person_id)
    else:
        person = sugar.get_media_person_or_404(meeting_id, person_id)
    badge = flask.request.args.get('badge', None)

    # create a temporary folder and save participant photo to disk
    temp = path(tempfile.mkdtemp())
    photo = person.data.get('photo', None)

    if photo:
        person.photo_url = app.config['UPLOADED_PHOTOS_DEST'] / photo
    else:
        person.photo_url = None

    if badge and badge == 'nostripe':
        color = 'all-white'
    else:
        category = person.category_model(meeting.id)
        color = category.data['badge_color'].replace(' ', '-')
    filename = color + '-left.png'
    if not app.config['BADGES_LOGOS'].joinpath(filename).exists():
        generate_badge_logo(color)

    # save badge as html
    context = dict(meeting=meeting, person=person, path=app.root_path,
                   background_path=app.config['UPLOADED_BACKGROUNDS_DEST'],
                   badge_logo_path=app.config['BADGES_LOGOS'],
                   badge=badge, person_type=person_type)
    return sugar.render_pdf("participant/person_badge_simple.html", temp=temp,
                             height="2.15in", width="3.4in", context=context,
                             filename=secure_filename(person.name),
                             use_wkhtmltopdf=True)