Browse Source

use context processors for MEDIA_URL and ROSETTA_ISNTALLED variables

Natenom/support-murmur-13-1446181288462
Michael Ziegler 15 years ago
parent
commit
432f97e654
  1. 4
      pyweb/mumble/views.py
  2. 23
      pyweb/processors.py
  3. 9
      pyweb/settings.py
  4. 4
      pyweb/templates/index.html
  5. 2
      pyweb/views.py

4
pyweb/mumble/views.py

@ -70,7 +70,6 @@ def mumbles( request ):
'mumble/list.html',
{ 'MumbleObjects': mumbles,
'MumbleActive': True,
'MEDIA_URL': settings.MEDIA_URL,
},
context_instance = RequestContext(request)
);
@ -86,7 +85,6 @@ def mobile_mumbles( request ):
'mumble/mobile_list.html',
{ 'MumbleObjects': mumbles,
'MumbleActive': True,
'MEDIA_URL': settings.MEDIA_URL,
},
context_instance = RequestContext(request)
);
@ -191,7 +189,6 @@ def show( request, server ):
return render_to_response(
'mumble/mumble.html',
{
'MEDIA_URL': settings.MEDIA_URL,
'login_url': "%s?next=%s" % ( login_url, show_url ),
'DBaseObject': srv,
'ChannelTable': channelTable,
@ -222,7 +219,6 @@ def mobile_show( request, server ):
return render_to_response(
'mumble/mobile_mumble.html',
{
'MEDIA_URL': settings.MEDIA_URL,
'DBaseObject': srv,
'MumbleActive': True,
'MumbleAccount':user,

23
pyweb/processors.py

@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-
"""
* Copyright (C) 2009, Michael "Svedrin" Ziegler <diese-addy@funzt-halt.net>
*
* Mumble-Django is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
"""
def media_url(request):
from django.conf import settings
return { 'MEDIA_URL': settings.MEDIA_URL }
def installed_apps(request):
from django.conf import settings
return { 'ROSETTA_INSTALLED': "rosetta" in settings.INSTALLED_APPS }

9
pyweb/settings.py

@ -178,6 +178,15 @@ TEMPLATE_DIRS = (
join( MUMBLE_DJANGO_ROOT, 'pyweb', 'templates' ),
)
TEMPLATE_CONTEXT_PROCESSORS = (
"django.core.context_processors.auth",
"django.core.context_processors.debug",
"django.core.context_processors.i18n",
"django.core.context_processors.media",
'processors.media_url',
'processors.installed_apps',
);
TEST_RUNNER = 'mumble.testrunner.run_tests'
TEST_MURMUR_LAB_DIR = join( dirname(MUMBLE_DJANGO_ROOT), 'murmur' );
TEST_MURMUR_FILES_DIR = join( MUMBLE_DJANGO_ROOT, 'testdata' );

4
pyweb/templates/index.html

@ -30,7 +30,9 @@
{% endif %}
{% if user.is_staff %}
<a href="{% url admin:index %}" target="_blank">{% trans "Administration" %}</a> |
<a href="{% url rosetta.views.home %}" target="_blank">{% trans "Edit translations" %}</a> |
{% if ROSETTA_INSTALLED %}
<a href="{% url rosetta.views.home %}" target="_blank">{% trans "Edit translations" %}</a> |
{% endif %}
{% endif %}
<a href="{% url views.imprint %}">{% trans "Imprint" %}</a>
</div>

2
pyweb/views.py

@ -30,7 +30,6 @@ from mumble.models import Mumble, MumbleUser
def profile( request ):
userdata = {
"ProfileActive": True,
'MEDIA_URL': settings.MEDIA_URL,
"mumbleaccs": MumbleUser.objects.filter( owner = request.user ),
# "gbposts": Entry.objects.filter( author = request.user ).count(),
# "gbcomments": Comment.objects.filter( author = request.user ).count(),
@ -47,5 +46,4 @@ def profile( request ):
def imprint( request ):
return render_to_response(
'registration/imprint.html',
{ 'MEDIA_URL': settings.MEDIA_URL, },
context_instance = RequestContext(request) );
Loading…
Cancel
Save