Openfoodnetwork: Backoffice errors due to upload of T&C files in formats other than .PDF

Created on 10 Sep 2020  路  4Comments  路  Source: openfoodfoundation/openfoodnetwork

Description


PR #5912 introduced the Terms and Conditions feature, consisting in the upload of a customizable .PDF file in the backoffice, which in turn appears to the customer - as a link to a new tab, on the checkout page.

This bug reports the behavior and errors caused when another file type - other than .PDF - is uploaded in the back office. After the above mentioned PR, uploading other file types is possible, although an error message is displayed. After upload, clicking on the file link, visible on "Business Details" section generates a snail.

This bug only concerns the backoffice.

Expected Behavior

  • It should not be possible to upload other file type other than .PDF
  • Attempting to do so shows an informative error message

Actual Behaviour

  • After PR #5912 it is possible to upload other file types other than .PDF
  • An error message is displayed - perhaps it could be improved as well?
  • Clinking on the link of that file -> Snail

Steps to Reproduce




As admin, in the Backoffice

  1. Go to Enterprise Settings -> Business Details for an enterprise. Upload a .TXT file. Save the changes.
  2. You should be redirected to /admin/enterprises//edit and a error message should be visible
  3. Return to Enterprise Settings -> Business Details and verify that, despite the error message, the file was added.
  4. Click on the file -> Snail

Animated Gif/Screenshot


image

image

image

Bugsnag
https://openfoodnetwork.slack.com/archives/CEF14NU3V/p1599742532044400

Workaround

Uploading .pdf files only.

Severity

bug-s3: a feature is broken but there is a workaround

Your Environment

  • Version used: to be introduced in v3.2.7
  • Browser name and version: Firefox 80
  • Operating System and version (desktop or mobile): Desktop Ubuntu 20.04

Possible Fix

bug-s4 good first issue hackathon

All 4 comments

I think we could copy what GH does for attachments. Refuse to store the file as soon as we notice it's not a PDF plus the error message. Likewise, we could also add a side note next to the button specifying only PDF is allowed (unless we do already).

Filipe, I think this is now improved from https://github.com/openfoodfoundation/openfoodnetwork/pull/6099#issuecomment-717589579

The file input is now filtered by default on pdf files. To upload a txt file you need to change the filter manually to list other file types other than PDF. Maybe this is now an S4.

Makes sense, I agree with downgrading :+1:
Do you think it's a good first issue?

I'll move it to "All the things" for now.

I think it is. For some reason, the form is still listing the file which didn't get persisted due to the model validation.

Was this page helpful?
0 / 5 - 0 ratings