Пример #1
0
def dropbox_submitted(request):
    appstruct = defaults()
    try:
        data = deform.Form(dropbox_schema,
            formid='briefkasten-form',
            action=request.url,
            buttons=('submit',)).validate(request.POST.items())
        drop_box = dropbox_container.add_dropbox(**data)
        text = render('briefkasten:templates/editor_email.pt', dict(
            reply_url=request.route_url('dropbox_editor', drop_id=drop_box.drop_id, editor_token=drop_box.editor_token),
            message=drop_box.message,
            num_attachments=drop_box.num_attachments), request)
        drop_box.update_message(text)
        process_status = drop_box.process()
        try:
            del tempstore[data['attachment']['uid']]
        except (KeyError, TypeError):
            pass
        appstruct.update(form=None,
            form_submitted=True,
            drop_id=drop_box.drop_id,
            process_status=process_status)
    except deform.ValidationFailure, exception:
        appstruct.update(form_submitted=False,
            form=exception.render())
Пример #2
0
def test_submitter_views_reply(browser):
    dropbox = dropbox_container.add_dropbox(message=u"Hello")
    reply = u"Good bye und schöne Grüße."
    author = u"John Doe"
    dropbox.add_reply(dict(reply=reply, author=author))
    response = browser.get("/briefkasten/%s" % dropbox.drop_id)
    response.mustcontain(reply)
    response.mustcontain(author)
Пример #3
0
def test_editor_posts_reply(zbrowser):
    dropbox = dropbox_container.add_dropbox(message=u'Hello')
    reply = u'How do you do?'
    author = u'John Doe'
    zbrowser.open('/briefkasten/%s/%s' % (dropbox.drop_id, dropbox.editor_token))
    zbrowser.getControl(name='reply').value = reply
    zbrowser.getControl(name='author').value = author
    zbrowser.getForm(index=1).submit()
    refetched_dropbox = dropbox_container.get_dropbox(dropbox.drop_id)
    assert refetched_dropbox != dropbox
    assert refetched_dropbox.replies[0]['reply'] == reply
    assert refetched_dropbox.replies[0]['author'] == author
Пример #4
0
def test_editor_posts_reply(browser):
    dropbox = dropbox_container.add_dropbox(message=u"Hello")
    reply = u"How do you do?"
    author = u"John Doe"
    page = browser.get("/briefkasten/%s/%s" % (dropbox.drop_id, dropbox.editor_token))
    form = page.forms["deform"]
    form["reply"] = reply
    form["author"] = author
    form.submit()
    refetched_dropbox = dropbox_container.get_dropbox(dropbox.drop_id)
    assert refetched_dropbox != dropbox
    assert refetched_dropbox.replies[0]["reply"] == reply
    assert refetched_dropbox.replies[0]["author"] == author
Пример #5
0
def dropbox_submitted(request):
    try:
        data = deform.Form(dropbox_schema,
            formid='briefkasten-form',
            action=request.url,
            buttons=('submit',)).validate(request.POST.items())
        drop_box = dropbox_container.add_dropbox(**data)
        process_status = drop_box.process()
        try:
            del tempstore[data['attachment']['uid']]
        except (KeyError, TypeError):
            pass
        return dict(title=title,
            form=None,
            form_submitted=True,
            drop_id=drop_box.drop_id,
            process_status=process_status)
    except deform.ValidationFailure, exception:
        return dict(title=title,
            form_submitted=False,
            form=exception.render())
Пример #6
0
def test_correct_token(browser):
    dropbox = dropbox_container.add_dropbox(message=u'Hello')
    response = browser.get('/briefkasten/%s/%s' % (dropbox.drop_id, dropbox.editor_token))
    assert response.status == '200 OK'
Пример #7
0
def test_incorrect_token_raises_not_found(browser):
    dropbox = dropbox_container.add_dropbox(message=u'Hello')
    response = browser.get('/briefkasten/%s/xxxx' % dropbox.drop_id, status=404)
    assert response.status == '404 Not Found'
Пример #8
0
def test_editor_posts_empty_reply(zbrowser):
    dropbox = dropbox_container.add_dropbox(message=u'Hello')
    zbrowser.open('/briefkasten/%s/%s' % (dropbox.drop_id, dropbox.editor_token))
    zbrowser.getForm(index=1).submit()
    assert dropbox.replies == []
Пример #9
0
def test_editor_posts_empty_reply(browser):
    dropbox = dropbox_container.add_dropbox(message=u"Hello")
    browser.get("/briefkasten/%s/%s" % (dropbox.drop_id, dropbox.editor_token)).forms[0].submit()
    assert dropbox.replies == []