diff --git a/django/django/contrib/admin/media/css/base.css b/django/django/contrib/admin/media/css/base.css
index 7299c95..069f303 100644
a
|
b
|
ul.messagelist li {
|
442 | 442 | margin: 0 0 3px 0; |
443 | 443 | border-bottom: 1px solid #ddd; |
444 | 444 | color: #666; |
| 445 | } |
| 446 | |
| 447 | ul.messagelist li.info { |
445 | 448 | background: #ffc url(../img/admin/icon_success.gif) 5px .3em no-repeat; |
446 | 449 | } |
447 | 450 | |
| 451 | ul.messagelist li.error { |
| 452 | background: #ffc url(../img/admin/icon_error.gif) 5px .3em no-repeat; |
| 453 | } |
| 454 | |
448 | 455 | .errornote { |
449 | 456 | font-size: 12px !important; |
450 | 457 | display: block; |
diff --git a/django/django/contrib/admin/options.py b/django/django/contrib/admin/options.py
index 20f3ed4..d83b4aa 100644
a
|
b
|
class ModelAdmin(BaseModelAdmin):
|
535 | 535 | change_message = ' '.join(change_message) |
536 | 536 | return change_message or _('No fields changed.') |
537 | 537 | |
538 | | def message_user(self, request, message): |
| 538 | def message_user(self, request, message, message_flag=None): |
539 | 539 | """ |
540 | 540 | Send a message to the user. The default implementation |
541 | 541 | posts a message using the auth Message object. |
542 | 542 | """ |
543 | | request.user.message_set.create(message=message) |
| 543 | if message_flag is None: |
| 544 | request.user.message_set.create(message=message) |
| 545 | else: |
| 546 | request.user.message_set.create(message=message, message_flag=message_flag) |
544 | 547 | |
545 | 548 | def save_form(self, request, form, change): |
546 | 549 | """ |
diff --git a/django/django/contrib/admin/templates/admin/base.html b/django/django/contrib/admin/templates/admin/base.html
index 9525728..d8e23b0 100644
a
|
b
|
|
55 | 55 | {% endif %} |
56 | 56 | |
57 | 57 | {% if messages %} |
58 | | <ul class="messagelist">{% for message in messages %}<li>{{ message }}</li>{% endfor %}</ul> |
| 58 | <ul class="messagelist">{% for m in messages %}<li{% if m.is_info %} class="info"{% else %}{% if m.is_error %} class="error"{% endif %}{% endif %}>{{ m }}</li>{% endfor %}</ul> |
59 | 59 | {% endif %} |
60 | 60 | |
61 | 61 | <!-- Content --> |
diff --git a/django/django/contrib/auth/models.py b/django/django/contrib/auth/models.py
index e337bec..b3bf613 100644
a
|
b
|
from django.utils.translation import ugettext_lazy as _
|
12 | 12 | |
13 | 13 | UNUSABLE_PASSWORD = '!' # This will never be a valid hash |
14 | 14 | |
| 15 | INFO = 1 |
| 16 | ERROR = 2 |
| 17 | |
15 | 18 | try: |
16 | 19 | set |
17 | 20 | except NameError: |
… |
… |
class User(models.Model):
|
261 | 264 | def get_and_delete_messages(self): |
262 | 265 | messages = [] |
263 | 266 | for m in self.message_set.all(): |
264 | | messages.append(m.message) |
| 267 | messages.append(m) |
265 | 268 | m.delete() |
266 | 269 | return messages |
267 | 270 | |
… |
… |
class Message(models.Model):
|
299 | 302 | """ |
300 | 303 | user = models.ForeignKey(User) |
301 | 304 | message = models.TextField(_('message')) |
| 305 | message_flag = models.PositiveSmallIntegerField(default=INFO) |
| 306 | |
| 307 | def is_info(self): |
| 308 | return self.message_flag == INFO |
| 309 | |
| 310 | def is_error(self): |
| 311 | return self.message_flag == ERROR |
302 | 312 | |
303 | 313 | def __unicode__(self): |
304 | 314 | return self.message |