Exemple #1
0
def dropbox_submission(dropbox, request):
    try:
        data = DropboxSchema().deserialize(request.POST)
    except Exception as exc:
        print(exc)
        import pdb; pdb.set_trace(  )
    # recognize submissions from the watchdog:
    is_test_submission = is_equal(request.registry.settings.get('test_submission_secret', ''),
        data.pop('testing_secret', ''))
    # a non-js client might have uploaded attachments via the form fileupload field:
    if data['attachments'] is not None:
        for attachment in data['attachments']:
            dropbox.add_attachment(attachment)

    drop_url = request.route_url('dropbox_view', drop_id=dropbox.drop_id)
    editor_url = request.route_url('dropbox_editor',
        drop_id=dropbox.drop_id,
        editor_token=dropbox.editor_token)
    # prepare the notification email text (we render it for process.sh, because... Python :-)
    notification_text = render('briefkasten:templates/editor_email.pt', dict(
        reply_url=editor_url,
        message=data['message'],
        num_attachments=dropbox.num_attachments), request)
    dropbox.update_message(notification_text)
    # now we can call the process method
    process_status = dropbox.process(testing=is_test_submission)
    if process_status == 0:
        return HTTPFound(location=drop_url)
Exemple #2
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())
        testing_secret = request.registry.settings.get('test_submission_secret', '')
        is_test_submission = is_equal(testing_secret,
            data.pop('testing_secret', ''))
        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(testing=is_test_submission)
        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())
Exemple #3
0
def dropbox_submission(dropbox, request):
    """ handles the form submission, redirects to the dropbox's status page."""
    try:
        data = dropbox_schema.deserialize(request.POST)
    except Exception:
        return HTTPFound(location=request.route_url('dropbox_form'))

    # set the message
    dropbox.message = data.get('message')

    # recognize submission from watchdog
    if 'testing_secret' in dropbox.settings:
        dropbox.from_watchdog = is_equal(
            unicode(dropbox.settings['test_submission_secret']),
            data.pop('testing_secret', u''))

    # a non-js client might have uploaded an attachment via the form's fileupload field:
    if data.get('upload') is not None:
        dropbox.add_attachment(data['upload'])

    # now we can call the process method
    dropbox.submit()
    drop_url = request.route_url('dropbox_view', drop_id=dropbox.drop_id)
    print("Created dropbox %s" % drop_url)
    return HTTPFound(location=drop_url)
Exemple #4
0
def dropbox_submission(dropbox, request):
    """ handles the form submission, redirects to the dropbox's status page."""
    try:
        data = dropbox_schema.deserialize(request.POST)
    except Exception:
        return HTTPFound(location=request.route_url('dropbox_form'))

    # set the message
    dropbox.message = data.get('message')

    # recognize submission from watchdog
    if 'testing_secret' in dropbox.settings:
        dropbox.from_watchdog = is_equal(
            unicode(dropbox.settings['test_submission_secret']),
            data.pop('testing_secret', u''))

    # a non-js client might have uploaded an attachment via the form's fileupload field:
    if data.get('upload') is not None:
        dropbox.add_attachment(data['upload'])

    # now we can call the process method
    dropbox.submit()
    drop_url = request.route_url('dropbox_view', drop_id=dropbox.drop_id)
    print("Created dropbox %s" % drop_url)
    return HTTPFound(location=drop_url)