Code

Opened 4 years ago

Closed 4 years ago

Last modified 3 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: UI/UX:

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 4 years ago.
style_messages_for_level.patch (1.4 KB) - added by sebastian_noack 4 years ago.

Download all attachments as: .zip

Change History (7)

Changed 4 years ago by sebastian_noack

comment:1 Changed 4 years ago by piquadrat

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

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 Changed 4 years ago by jacob

  • milestone set to 1.3
  • Triage Stage changed from Unreviewed to Accepted

comment:3 Changed 4 years ago by sebastian_noack

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.

Changed 4 years ago by sebastian_noack

comment:4 Changed 4 years ago by lukeplant

  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #12803

comment:5 Changed 3 years ago by jacob

  • milestone 1.3 deleted

Milestone 1.3 deleted

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.