move AdminMessageMiddleware over to context processors (bug 624905)

This commit is contained in:
Andy McKay 2011-01-11 14:12:38 -08:00
Родитель 42ff809498
Коммит bb2f207d41
5 изменённых файлов: 7 добавлений и 19 удалений

Просмотреть файл

@ -9,6 +9,7 @@ import amo
from amo.urlresolvers import reverse
from access import acl
from cake.urlresolvers import remora_url
from zadmin.models import get_config
def app(request):
@ -77,5 +78,6 @@ def global_settings(request):
context.update({'account_links': account_links,
'settings': settings, 'amo': amo,
'tools_links': tools_links})
'tools_links': tools_links,
'ADMIN_MESSAGE': get_config('site_notice')})
return context

Просмотреть файл

@ -24,18 +24,6 @@ import jingo
import amo
from . import urlresolvers
from .helpers import urlparams
from zadmin.models import get_config
class AdminMessageMiddleware(object):
"""
1. Check db for an admin message.
2. Store it in request.
"""
def process_request(self, request):
# Get the value from Config if it exists
request.ADMIN_MESSAGE = get_config('site_notice')
class LocaleAndAppURLMiddleware(object):

Просмотреть файл

@ -33,7 +33,7 @@ def test_trailing_slash_middleware():
assert response['Location'].endswith('/en-US/firefox/about?xxx=%C3%83')
class AdminMessageMiddlewareTest(TestCase):
class AdminMessageTest(TestCase):
def test_message(self):
c = Config()
c.key = 'site_notice'

Просмотреть файл

@ -225,8 +225,6 @@ MIDDLEWARE_CLASSES = (
'cake.middleware.CakeCookieMiddleware',
'cake.middleware.CookieCleaningMiddleware',
'amo.middleware.AdminMessageMiddleware',
# This should come after authentication middleware
'access.middleware.ACLMiddleware',

Просмотреть файл

@ -32,10 +32,10 @@
data-media-url="{{ MEDIA_URL }}"
{% block bodyattrs %}{% endblock %}>
{% if request.ADMIN_MESSAGE or settings.READ_ONLY%}
{% if ADMIN_MESSAGE or settings.READ_ONLY%}
<div id="site-notice">
{% if request.ADMIN_MESSAGE %}
<p>{{ request.ADMIN_MESSAGE }}</p>
{% if ADMIN_MESSAGE %}
<p>{{ ADMIN_MESSAGE }}</p>
{% endif %}
{% if settings.READ_ONLY %}
<p>{{ _("Some features are temporarily disabled while we perform website maintenance. We'll be back to full capacity shortly.") }}</p>