Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI improvement: Upload success/error messages #72

Merged
merged 12 commits into from
Jun 11, 2020
Merged

Conversation

mengsarah
Copy link
Collaborator

Mostly worked on the messages on the /upload page. There are some minor unrelated changes elsewhere.

  • Number and Year are no longer squashed if you have big text on a big enough screen
  • "Misuse of uploads will be met by a ban!" warning now hardcoded into the page so it persists
  • and moved that ^ right before the submit button, so no excuse for missing it (previously was below the submit button)
  • New message div for the two JS-triggered upload error messages (big file or not PDF) that is hidden at first--so now it can't be missed the first time around
  • New message div for the on-page-load success and error messages
  • and that ^ is at the top of the page, where it should be since it's upon page load (previously at the bottom of the page)
  • AND it's Django-style! per @50Wliu 's suggestion--and I also updated views.py correspondingly
  • Made some of the error messages nicer

@mengsarah mengsarah linked an issue Jun 11, 2020 that may be closed by this pull request
@mengsarah mengsarah removed a link to an issue Jun 11, 2020
@verndrade verndrade self-requested a review June 11, 2020 14:50
Copy link
Collaborator

@verndrade verndrade left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work!

Copy link
Collaborator

@winstliu winstliu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love it! I can't actually see what it looks like because of migration issues...but seems like it should be fine :).

I have a thing against leaving old commented-out code in the codebase, so I would prefer that it's removed, but not a big deal.

{% if messages %}
{% for message in messages %}
<div class="text-center">
{% if message.level == DEFAULT_MESSAGE_LEVELS.SUCCESS %}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you stick the following into settings.py, we'll get full messages<->Bootstrap compat and then you can then do something like ...other classes... alert-{{ message.tags }} instead of the if/else casing for the level. (or, since it seems like we aren't using alert-* styling b/c of the background color, just {{ message.tags }})

# at the top of the file
from django.contrib.messages import constants as messages

# wherever you want
MESSAGE_TAGS = {
    messages.ERROR: 'danger'
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, thanks, I'll look into that later! Good to know--I felt like the if/else casing was a bit unwieldy

<input class="form-control-file" id="file" type="file" name="file" accept="application/pdf" required>
</div>
<div class="form-group col-md">
<div id="message" class="alert d-inline-block warning" style="display: none !important;" role="alert"> </div>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: since there's nothing in here by default, would it even display anything if you removed the display: none?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, removing that would display a nice red block that houses no text by default

@mengsarah mengsarah merged commit 3b23f31 into development Jun 11, 2020
@mengsarah mengsarah deleted the UI-improvement branch June 11, 2020 17:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants