Exemple #1
0
def test_meeting_custom_logos_remove(app, user, brand_dir):
    meeting = MeetingFactory()
    right_logo = (StringIO('Right'), 'right.png')
    left_logo = (StringIO('Left'), 'left.jpg')
    upload_dir = local(app.config['UPLOADED_LOGOS_DEST'])

    client = app.test_client()
    with app.test_request_context():
        with client.session_transaction() as sess:
            sess['user_id'] = user.id
        product_logo = Logo('product_logo')
        product_side_logo = Logo('product_side_logo')

        resp = upload_new_logo(app, user, meeting.id, 'PRODUCT_LOGO', left_logo)
        assert upload_dir.join(product_logo.filename).check()

        resp = client.delete(url_for('meetings.logo_upload',
                                     meeting_id=meeting.id,
                                     logo_slug='PRODUCT_LOGO'))
        assert resp.status_code == 200
        assert not upload_dir.join(product_logo.filename).check()

        resp = upload_new_logo(app, user, meeting.id, 'PRODUCT_SIDE_LOGO',
                               right_logo)
        right_logo_filename = product_side_logo.filename
        assert upload_dir.join(right_logo_filename).check()

        resp = client.delete(url_for('meetings.logo_upload',
                                     meeting_id=meeting.id,
                                     logo_slug='PRODUCT_SIDE_LOGO'))
        assert resp.status_code == 200
        assert not upload_dir.join(right_logo_filename).check()
Exemple #2
0
def test_pdf_badge_with_custom_logos(app, user, brand_dir):
    category = MeetingCategoryFactory(category_type=Category.PARTICIPANT)
    ParticipantFactory.create_batch(5, meeting=category.meeting)

    right_logo = (StringIO('Right'), 'right.png')
    left_logo = (StringIO('Left'), 'left.jpg')

    upload_new_logo(app, user, category.meeting.id, 'PRODUCT_LOGO', right_logo)
    upload_new_logo(app, user, category.meeting.id, 'PRODUCT_SIDE_LOGO',
                    left_logo)

    with app.test_request_context():
        g.meeting = category.meeting
        participants = Participant.query.all()
        context = {'participants': participants}
        renderer = PdfRenderer('meetings/printouts/badges_pdf.html',
                               height='2.15in', width='3.4in', context=context)
        renderer._render_template()

    with open(renderer.template_path, 'r') as content_file:
        content = content_file.read()
        product_logos = PyQuery(content)('.logo')
        for logo in product_logos:
            assert logo.attrib['src'] == Logo('PRODUCT_LOGO').url

        side_logos = PyQuery(content)('.side-logo')
        for logo in side_logos:
            assert logo.attrib['src'] == Logo('PRODUCT_SIDE_LOGO').url
Exemple #3
0
def test_meeting_custom_logos(app, user, brand_dir):
    meeting = MeetingFactory()
    right_logo = (StringIO('Right'), 'right.png')
    left_logo = (StringIO('Left'), 'left.jpg')
    upload_dir = local(app.config['UPLOADED_LOGOS_DEST'])

    with app.test_request_context():
        resp = upload_new_logo(app, user, meeting.id, 'PRODUCT_LOGO', left_logo)
        product_logo = Logo('product_logo')

        assert product_logo.url in resp.data
        assert upload_dir.join(product_logo.filename).check()

        resp = upload_new_logo(app, user, meeting.id, 'PRODUCT_SIDE_LOGO',
                               right_logo)
        product_side_logo = Logo('product_side_logo')

        assert product_side_logo.url in resp.data
        assert upload_dir.join(product_side_logo.filename).check()

    client = app.test_client()
    with app.test_request_context():
        with client.session_transaction() as sess:
            sess['user_id'] = user.id
        resp = client.get(url_for('meetings.logos', meeting_id=meeting.id))
        assert resp.status_code == 200
        html = PyQuery(resp.data)
        logo_src = html('#PRODUCT_LOGO a').attr('href')
        assert logo_src == product_logo.url
        side_logo_src = html('#PRODUCT_SIDE_LOGO a').attr('href')
        assert side_logo_src == product_side_logo.url

        remove_buttons = html('.remove-photo.disabled ')
        assert len(remove_buttons) == 0
Exemple #4
0
def test_meeting_default_logos(app, user, brand_dir):
    meeting = MeetingFactory()

    client = app.test_client()
    with app.test_request_context():
        with client.session_transaction() as sess:
            sess['user_id'] = user.id

        product_logo = Logo('product_logo')
        product_side_logo = Logo('product_side_logo')
        product_back_logo = Logo('badge_back_logo')
        product_logo.path.touch()
        product_side_logo.path.touch()
        product_back_logo.path.touch()

        resp = client.get(url_for('meetings.logos', meeting_id=meeting.id))
        assert resp.status_code == 200

        html = PyQuery(resp.data)
        logo_src = html('#PRODUCT_LOGO img').attr('src')
        assert logo_src == product_logo.url
        side_logo_src = html('#PRODUCT_SIDE_LOGO img').attr('src')
        assert side_logo_src == product_side_logo.url
        product_back_logo_stc = html('#BADGE_BACK_LOGO img').attr('src')
        assert product_back_logo_stc == product_back_logo.url

        remove_buttons = html('.remove-photo')
        assert len(remove_buttons) == 3
        for button in remove_buttons:
            assert 'display: none' in button.attrib['style']
    def get(self):
        left_logo = Logo('PRODUCT_LOGO')
        left_logo_form = MeetingLogoEditForm(logo=left_logo.filename)

        right_logo = Logo('PRODUCT_SIDE_LOGO')
        right_logo_form = MeetingLogoEditForm(logo=right_logo.filename)

        badge_back_logo = Logo('BADGE_BACK_LOGO')
        badge_back_logo_form = MeetingLogoEditForm(
            logo=badge_back_logo.filename)

        return render_template('meetings/logos/logos.html',
                               left_logo_form=left_logo_form,
                               left_logo=left_logo,
                               right_logo_form=right_logo_form,
                               right_logo=right_logo,
                               badge_back_logo=badge_back_logo,
                               badge_back_logo_form=badge_back_logo_form)
Exemple #6
0
def inject_badge_context(participant):
    product_logo = Logo('product_logo')
    product_side_logo = Logo('product_side_logo')
    badge_back_logo = Logo('badge_back_logo')

    participant_photo, background, = None, None
    if participant.photo:
        crop_photo = crop(
            Path(app.config['PATH_CUSTOM_KEY']) / participant.photo)
        participant_photo = app.config['FILES_PATH'] / crop_photo

    if participant.category.background:
        background = (app.config['UPLOADED_BACKGROUNDS_DEST'] /
                      participant.category.background)
    return {
        'product_logo': product_logo,
        'product_side_logo': product_side_logo,
        'badge_back_logo': badge_back_logo,
        'participant_photo': participant_photo,
        'background': background,
    }
Exemple #7
0
def test_meeting_left_custom_logo_change_removes_old_logo(app, user, brand_dir):
    meeting = MeetingFactory()
    old_logo = (StringIO('Old'), 'old.png')
    new_file_content = 'New!'
    new_logo = (StringIO(new_file_content), 'new.jpg')
    upload_dir = local(app.config['UPLOADED_LOGOS_DEST'])

    client = app.test_client()
    with app.test_request_context():
        with client.session_transaction() as sess:
            sess['user_id'] = user.id
        product_logo = Logo('product_logo')

        upload_new_logo(app, user, meeting.id, 'PRODUCT_LOGO', old_logo)
        old_file = upload_dir.join(product_logo.filename)
        assert old_file.check()
        old_file_content = old_file.read()

        upload_new_logo(app, user, meeting.id, 'PRODUCT_LOGO', new_logo)
        new_file = upload_dir.join(product_logo.filename)
        assert new_file.check()
        assert new_file.read() != old_file_content
        assert new_file.read() == new_file_content
 def save(self, logo_slug):
     if self.logo.data:
         logo = Logo(logo_slug)
         logo.save(self.logo.data)
         return logo
 def save(self, logo_slug):
     if self.logo.data:
         logo = Logo(logo_slug)
         logo.save(self.logo.data)
         return logo
 def delete(self, logo_slug):
     logo = Logo(logo_slug)
     logo.unlink()
     return jsonify(status="success", url=url_for('.logos'))
 def delete(self, logo_slug):
     logo = Logo(logo_slug)
     logo.unlink()
     return jsonify(status="success", url=url_for('.logos'))