Skip to content

Fix: Render flash messages on all admin pages#6

Merged
matteospanio merged 2 commits intodevfrom
copilot/fix-flash-message-display
Jan 3, 2026
Merged

Fix: Render flash messages on all admin pages#6
matteospanio merged 2 commits intodevfrom
copilot/fix-flash-message-display

Conversation

Copy link
Contributor

Copilot AI commented Jan 3, 2026

Flash messages were only visible on the profile page because the rendering block existed in profile.html but not in the base master.html template.

Changes

  • templates/admin/master.html: Added flash message rendering block to main content section
  • tests/test_admin.py: Added test coverage for flash message rendering across admin pages

Implementation

The flash rendering logic from profile.html was duplicated into master.html before the {% block body %} tag:

{% with messages = get_flashed_messages(with_categories=true) %}
  {% if messages %}
    {% for category, message in messages %}
      <div class="alert alert-{{ 'danger' if category == 'error' else category }} alert-dismissible fade show" role="alert">
        <i class="fas fa-{% if category == 'error' %}exclamation-circle{% elif category == 'success' %}check-circle{% else %}info-circle{% endif %} mr-2"></i>
        {{ message }}
        <button type="button" class="close" data-dismiss="alert" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
    {% endfor %}
  {% endif %}
{% endwith %}

This ensures all pages extending master.html (dashboard, users, menus, dishes, etc.) now display flash messages consistently.

Screenshots

Flash message on admin dashboard after login:
Flash message on dashboard

Flash message on login page after logout:
Logout flash message

Original prompt

This section details on the original issue you should resolve

<issue_title>🐛 Bug: Admin flashes are not displayed correctly</issue_title>
<issue_description>Flash messages in the admin area are usually not displayed correctly.
At the moment, flashes appear only on the profile page (where the list of admins is shown), while they are missing on the other admin pages.

This suggests that the flash rendering logic is likely missing from the main admin template, and therefore flashes are not consistently rendered across the admin interface.

Steps to Reproduce

  1. Navigate to any admin page (except the profile page)
  2. Trigger an action that should display a flash message (e.g. create/update/delete)
  3. Observe that no flash message is shown
  4. Navigate to the profile page
  5. Observe that flash messages are displayed correctly

Expected Behavior
Flash messages should be rendered and visible on all admin pages, consistently and reliably.

Actual Behavior
Flash messages are only visible on the profile page; other admin pages do not display them.

Possible Cause
The flash rendering block is likely missing from the main admin HTML template (e.g. base/layout template), and is currently included only in the profile page template.

Suggested Fix

  • Update the main admin layout template to include the flash rendering logic
  • Ensure the flash list is displayed consistently on every admin page

Environment

  • Admin area
  • HTML templates (base/admin layout)</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: matteospanio <50635581+matteospanio@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix flash messages not displaying on all admin pages Fix: Render flash messages on all admin pages Jan 3, 2026
Copilot AI requested a review from matteospanio January 3, 2026 15:56
@matteospanio matteospanio marked this pull request as ready for review January 3, 2026 16:11
@matteospanio matteospanio changed the base branch from master to dev January 3, 2026 16:11
@matteospanio matteospanio merged commit 0625482 into dev Jan 3, 2026
4 checks passed
@matteospanio matteospanio deleted the copilot/fix-flash-message-display branch January 3, 2026 16:12
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.

🐛 Bug: Admin flashes are not displayed correctly

2 participants