Skip to content
This repository has been archived by the owner on Sep 5, 2019. It is now read-only.

Commit

Permalink
Switches to onegov.file for form submission files
Browse files Browse the repository at this point in the history
  • Loading branch information
Denis Krienbühl committed Sep 22, 2017
1 parent b97c2a6 commit ccd2f3d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 21 deletions.
3 changes: 3 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
Changelog
---------

- Switches to onegov.file for form submission files.
[href]

- Fixes dialog not showing for undeletable objects.
[href]

Expand Down
8 changes: 5 additions & 3 deletions onegov/org/layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
from onegov.core.static import StaticFile
from onegov.core.utils import linkify
from onegov.event import OccurrenceCollection
from onegov.form import FormCollection, FormSubmissionFile, render_field
from onegov.file import File
from onegov.form import FormCollection, render_field
from onegov.newsletter import NewsletterCollection, RecipientCollection
from onegov.org import _
from onegov.org import utils
Expand Down Expand Up @@ -317,8 +318,9 @@ def field_download_link(self, field):
return None

if field.data.get('data', '').startswith('@'):
return self.request.link(
FormSubmissionFile(id=field.data['data'].lstrip('@')))
return self.request.class_link(File, {
'id': field.data['data'].lstrip('@')
})

@cached_property
def move_person_url_template(self):
Expand Down
7 changes: 0 additions & 7 deletions onegov/org/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from onegov.form import (
FormDefinition,
FormCollection,
FormSubmissionFile,
CompleteFormSubmission,
PendingFormSubmission
)
Expand Down Expand Up @@ -143,12 +142,6 @@ def get_complete_form_submission(app, id):
id, state='complete', current_only=False)


@OrgApp.path(model=FormSubmissionFile, path='/formular-datei/{id}',
converters=dict(id=UUID))
def get_form_submission_file(app, id):
return FormCollection(app.session()).submissions.file_by_id(id)


@OrgApp.path(model=Editor, path='/editor/{action}/{trait}/{page_id}')
def get_editor(app, action, trait, page_id):
if not Editor.is_supported_action(action):
Expand Down
11 changes: 0 additions & 11 deletions onegov/org/views/form_submission.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
""" Renders and handles defined forms, turning them into submissions. """

import base64
import morepath

from onegov.core.security import Public, Private
from onegov.ticket import TicketCollection
from onegov.form import (
FormCollection,
FormDefinition,
FormSubmissionFile,
PendingFormSubmission,
CompleteFormSubmission
)
Expand Down Expand Up @@ -191,12 +189,3 @@ def handle_complete_submission(self, request):
request.success(_("Thank you for your submission!"))

return morepath.redirect(request.link(ticket, 'status'))


@OrgApp.view(model=FormSubmissionFile, permission=Private)
def view_form_submission_file(self, request):
response = morepath.Response(base64.b64decode(self.filedata))
response.content_type = self.submission_data['mimetype']
response.content_encoding = 'gzip'

return response

0 comments on commit ccd2f3d

Please sign in to comment.