[Django] #20610: Add a message level dict to `contrib.messages.context_processors.messages`

15 views
Skip to first unread message

Django

unread,
Jun 16, 2013, 2:11:13 AM6/16/13
to django-...@googlegroups.com
#20610: Add a message level dict to `contrib.messages.context_processors.messages`
----------------------------------+--------------------
Reporter: bmispelon | Owner: nobody
Type: New feature | Status: new
Component: contrib.messages | Version:
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------+--------------------
It'd be nice if the provided context processor also added a dictionary of
message levels to the context.

This would allow something like this:
{{{#!html+django
{% for message in messages %}
{% if message.level == MESSAGE_LEVELS.SUCCESS %}...{% endif %}
...
{% endfor %}
}}}

Currently, one has to pass the message levels manually into the context,
or do something like this, which is brittle:
{{{#!html+django
{% if 'success' i nmessage.tags %}...{% endif %}
}}}

There should not be any backwards-compatibility issue and the change is
rather minimal.
I've attached a proof-of-concept patch. If there's interest, I'd be
willing to polish it up (mostly adding tests and documentation).

--
Ticket URL: <https://code.djangoproject.com/ticket/20610>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jun 16, 2013, 2:34:05 PM6/16/13
to django-...@googlegroups.com
#20610: Add a message level dict to `contrib.messages.context_processors.messages`
----------------------------------+--------------------------------------

Reporter: bmispelon | Owner: nobody
Type: New feature | Status: new
Component: contrib.messages | Version:
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
----------------------------------+--------------------------------------
Changes (by aaugustin):

* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0


Comment:

Technically, it's backwards incompatible for people who have
"MESSAGE_LEVELS" in their context. That's minor, but it should be
mentioned in the release notes.

--
Ticket URL: <https://code.djangoproject.com/ticket/20610#comment:1>

Django

unread,
Aug 19, 2013, 1:32:28 PM8/19/13
to django-...@googlegroups.com
#20610: Add a message level dict to `contrib.messages.context_processors.messages`
----------------------------------+------------------------------------

Reporter: bmispelon | Owner: nobody
Type: New feature | Status: new
Component: contrib.messages | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
----------------------------------+------------------------------------
Changes (by timo):

* needs_docs: 0 => 1
* has_patch: 0 => 1
* version: => master
* needs_tests: 0 => 1
* stage: Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/20610#comment:2>

Django

unread,
Oct 28, 2013, 4:55:05 PM10/28/13
to django-...@googlegroups.com
#20610: Add a message level dict to `contrib.messages.context_processors.messages`
----------------------------------+------------------------------------

Reporter: bmispelon | Owner: nobody
Type: New feature | Status: new
Component: contrib.messages | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
----------------------------------+------------------------------------
Changes (by bmispelon):

* needs_docs: 1 => 0
* needs_tests: 1 => 0


Comment:

Here's a pull request with tests and documentation:
https://github.com/django/django/pull/1822

--
Ticket URL: <https://code.djangoproject.com/ticket/20610#comment:3>

Django

unread,
Oct 30, 2013, 8:34:02 AM10/30/13
to django-...@googlegroups.com
#20610: Add a message level dict to `contrib.messages.context_processors.messages`
-------------------------------------+-------------------------------------

Reporter: bmispelon | Owner: nobody
Type: New feature | Status: new
Component: contrib.messages | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
Has patch: 1 | checkin
Needs tests: 0 | Needs documentation: 0
Easy pickings: 0 | Patch needs improvement: 0
| UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timo):

* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/20610#comment:4>

Django

unread,
Oct 30, 2013, 8:55:04 AM10/30/13
to django-...@googlegroups.com
#20610: Add a message level dict to `contrib.messages.context_processors.messages`
-------------------------------------+-------------------------------------
Reporter: bmispelon | Owner: nobody
Type: New feature | Status: closed
Component: contrib.messages | Version: master
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for
Has patch: 1 | checkin
Needs tests: 0 | Needs documentation: 0
Easy pickings: 0 | Patch needs improvement: 0
| UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Baptiste Mispelon <bmispelon@…>):

* status: new => closed
* resolution: => fixed


Comment:

In [changeset:"9fde42a69a56cb6c8cdfd67b07c67a1b97638f12"]:
{{{
#!CommitTicketReference repository=""
revision="9fde42a69a56cb6c8cdfd67b07c67a1b97638f12"
Fixed #20610: Added a message level dict to contrib.message context
processor.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/20610#comment:5>

Django

unread,
May 6, 2014, 2:40:00 PM5/6/14
to django-...@googlegroups.com
#20610: Add a message level dict to `contrib.messages.context_processors.messages`
-------------------------------------+-------------------------------------
Reporter: bmispelon | Owner: nobody

Type: New feature | Status: closed
Component: contrib.messages | Version: master
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Ready for
Has patch: 1 | checkin
Needs tests: 0 | Needs documentation: 0
Easy pickings: 0 | Patch needs improvement: 0
| UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Claude Paroz <claude@…>):

In [changeset:"79e4a189f3b17b5a7426f889c4412126eb169256"]:
{{{
#!CommitTicketReference repository=""
revision="79e4a189f3b17b5a7426f889c4412126eb169256"
[1.7.x] Updated the messages context processor docs

Refs #20610.
Backport of 7951f125e frmo master.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/20610#comment:6>

Reply all
Reply to author
Forward
0 new messages