Skip to content

Commit

Permalink
move AdminMessageMiddleware over to context processors (bug 624905)
Browse files Browse the repository at this point in the history
  • Loading branch information
Andy McKay committed Jan 11, 2011
1 parent 42ff809 commit bb2f207
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 19 deletions.
4 changes: 3 additions & 1 deletion apps/amo/context_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from amo.urlresolvers import reverse
from access import acl
from cake.urlresolvers import remora_url
from zadmin.models import get_config


def app(request):
Expand Down Expand Up @@ -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
12 changes: 0 additions & 12 deletions apps/amo/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,6 @@
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):
Expand Down
2 changes: 1 addition & 1 deletion apps/amo/tests/test_middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 0 additions & 2 deletions settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,6 @@ def JINJA_CONFIG():
'cake.middleware.CakeCookieMiddleware',
'cake.middleware.CookieCleaningMiddleware',

'amo.middleware.AdminMessageMiddleware',

# This should come after authentication middleware
'access.middleware.ACLMiddleware',

Expand Down
6 changes: 3 additions & 3 deletions templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down

0 comments on commit bb2f207

Please sign in to comment.