Implement an easy bridge between django reverse() and javascript ajax
This commit is contained in:
@@ -5,6 +5,7 @@ from django.db.models import Sum
|
||||
from donate.models import Donation
|
||||
from datetime import datetime
|
||||
from django.conf import settings
|
||||
from django.core.urlresolvers import reverse
|
||||
|
||||
def random_quote(request):
|
||||
quote = models.Quote.objects.order_by('?')
|
||||
@@ -33,3 +34,12 @@ def donation_info(request):
|
||||
else:
|
||||
progress = donationTotal/goal*100
|
||||
return {'donation_month_total': donationTotal, 'donation_month_goal': goal, 'donation_goal_progress': progress}
|
||||
|
||||
def javascript_uris(request):
|
||||
uris = (
|
||||
'local.views.mark_notifications_read',
|
||||
)
|
||||
ret = []
|
||||
for u in uris:
|
||||
ret.append({'name':u, 'uri':reverse(u)})
|
||||
return {'js_uris': ret}
|
||||
|
@@ -175,6 +175,7 @@ TEMPLATE_CONTEXT_PROCESSORS = (
|
||||
"local.context.login_form",
|
||||
"local.context.forum_activity",
|
||||
"local.context.donation_info",
|
||||
"local.context.javascript_uris",
|
||||
"minecraft.context.server_info",
|
||||
"appversion.context.git_version",
|
||||
"messages.context_processors.inbox",
|
||||
|
@@ -15,6 +15,11 @@
|
||||
<link rel="stylesheet" type="text/css" href="{{ STATIC_PREFIX }}/css/badges.css?{{app_version}}"/>
|
||||
<link rel="icon" type="image/png" href="{{ STATIC_PREFIX }}/images/logo.png"/>
|
||||
{% block extracss %}{% endblock extracss %}
|
||||
<script type="text/javascript">
|
||||
var uris = {};
|
||||
{% for uri in js_uris %}
|
||||
uris["{{uri.name}}"] = "{{uri.uri}}"; {% endfor %}
|
||||
</script>
|
||||
<!-- Google+ -->
|
||||
<script type="text/javascript">
|
||||
window.___gcfg = {lang: 'en'};
|
||||
|
Reference in New Issue
Block a user