Opened 14 years ago

Closed 14 years ago

Last modified 13 years ago

#13652 closed (duplicate)

Support error user messages [PATCH]

Reported by: Sebastian Noack Owned by: nobody
Component: contrib.admin Version: 1.2
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Currently user messages (django.contrib.auth.Message) as used by the admin, are always displayed with a success icon. But I also use ModelAdmin.message_user() to log failures or warnings. So I think we should have a way to flag user messages and show them different in the admin. I have written a patch, that adds a new column to the Message model indicating the type of the message (INFO or ERROR). The default is INFO, because of info message are rendered the same way as all messages are rendered at the moment. So this patch does not break any existing code. But the ModelAdmin.message_user() method got another optional argument, you can use to specify INFO or ERROR.

Attachments (2)

add_message_flag_to_message_model.patch (3.3 KB ) - added by Sebastian Noack 14 years ago.
style_messages_for_level.patch (1.4 KB ) - added by Sebastian Noack 14 years ago.

Download all attachments as: .zip

Change History (7)

by Sebastian Noack, 14 years ago

comment:1 by Benjamin Wohlwend, 14 years ago

The Message model from contrib.auth has been deprecated in Django 1.2 (see http://docs.djangoproject.com/en/dev/topics/auth/#messages), so the chances of any feature additions getting into trunk are pretty slim. The all new messages framework supports levels similarly to what you propose. I don't know if they are already used in the admin app, though.

comment:2 by Jacob, 14 years ago

milestone: 1.3
Triage Stage: UnreviewedAccepted

comment:3 by Sebastian Noack, 14 years ago

I have written the patch for django 1.1, so you can ignore it. ;) I have looked at the messages framework introduced with django 1.2. It looks great and yes it is used by the admin. But the admin does not care about the level right now. I have added a new patch for django 1.2, which uses the icon related to the level, when displaying messages in the admin. Since the admin is using the message framework, ModelAdmin.message_user(request, msg) just calls django.contrib.messages.info(request, msg). So I would recommend to deprecate ModelAdmin.message_user() in favour of info(), debug(), success(), warning() and error() from django.contrib.messages.

by Sebastian Noack, 14 years ago

comment:4 by Luke Plant, 14 years ago

Resolution: duplicate
Status: newclosed

Duplicate of #12803

comment:5 by Jacob, 13 years ago

milestone: 1.3

Milestone 1.3 deleted

Note: See TracTickets for help on using tickets.
Back to Top