forked from 0x2620/pandora
stop using RequestContext
This commit is contained in:
parent
18ff903658
commit
62caf55fe6
5 changed files with 30 additions and 40 deletions
|
@ -3,8 +3,7 @@
|
||||||
import copy
|
import copy
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from django.shortcuts import render_to_response, redirect
|
from django.shortcuts import render, redirect
|
||||||
from django.template import RequestContext
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.http import HttpResponse
|
from django.http import HttpResponse
|
||||||
|
|
||||||
|
@ -22,8 +21,7 @@ from changelog.models import add_changelog
|
||||||
from ox.django.api import actions
|
from ox.django.api import actions
|
||||||
|
|
||||||
def intro(request):
|
def intro(request):
|
||||||
context = RequestContext(request, {'settings': settings})
|
return render(request, 'intro.html', {'settings': settings})
|
||||||
return render_to_response('intro.html', context)
|
|
||||||
|
|
||||||
def index(request):
|
def index(request):
|
||||||
title = settings.SITENAME
|
title = settings.SITENAME
|
||||||
|
@ -38,19 +36,17 @@ def index(request):
|
||||||
title += ' - ' + p['title']
|
title += ' - ' + p['title']
|
||||||
text, created = models.Page.objects.get_or_create(name=page)
|
text, created = models.Page.objects.get_or_create(name=page)
|
||||||
text = text.text
|
text = text.text
|
||||||
context = RequestContext(request, {
|
return render(request, 'index.html', {
|
||||||
'base_url': request.build_absolute_uri('/'),
|
'base_url': request.build_absolute_uri('/'),
|
||||||
'settings': settings,
|
'settings': settings,
|
||||||
'text': text,
|
'text': text,
|
||||||
'title': title,
|
'title': title,
|
||||||
})
|
})
|
||||||
return render_to_response('index.html', context)
|
|
||||||
|
|
||||||
def embed(request, id):
|
def embed(request, id):
|
||||||
context = RequestContext(request, {
|
return render(request, 'embed.html', {
|
||||||
'settings': settings
|
'settings': settings
|
||||||
})
|
})
|
||||||
return render_to_response('embed.html', context)
|
|
||||||
|
|
||||||
def redirect_url(request, url):
|
def redirect_url(request, url):
|
||||||
if request.META['QUERY_STRING']:
|
if request.META['QUERY_STRING']:
|
||||||
|
|
|
@ -5,8 +5,7 @@ import os.path
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from django import forms
|
from django import forms
|
||||||
from django.shortcuts import get_object_or_404, redirect, render_to_response
|
from django.shortcuts import get_object_or_404, redirect, render
|
||||||
from django.template import RequestContext
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.db.models import Count, Q
|
from django.db.models import Count, Q
|
||||||
|
|
||||||
|
@ -224,12 +223,11 @@ actions.register(addMedia, cache=False)
|
||||||
@login_required_json
|
@login_required_json
|
||||||
def firefogg_upload(request):
|
def firefogg_upload(request):
|
||||||
if not 'profile' in request.GET or not 'id' in request.GET:
|
if not 'profile' in request.GET or not 'id' in request.GET:
|
||||||
context = RequestContext(request, {
|
return render(request, 'api.html', {
|
||||||
'api': [],
|
'api': [],
|
||||||
'settings': settings,
|
'settings': settings,
|
||||||
'sitename': settings.SITENAME
|
'sitename': settings.SITENAME
|
||||||
})
|
})
|
||||||
return render_to_response('api.html', context)
|
|
||||||
profile = request.GET['profile']
|
profile = request.GET['profile']
|
||||||
oshash = request.GET['id']
|
oshash = request.GET['id']
|
||||||
config = settings.CONFIG['video']
|
config = settings.CONFIG['video']
|
||||||
|
|
|
@ -10,9 +10,8 @@ import time
|
||||||
|
|
||||||
import Image
|
import Image
|
||||||
from django.db.models import Count, Sum
|
from django.db.models import Count, Sum
|
||||||
from django.template import RequestContext
|
|
||||||
from django.http import HttpResponse, HttpResponseForbidden, Http404
|
from django.http import HttpResponse, HttpResponseForbidden, Http404
|
||||||
from django.shortcuts import get_object_or_404, redirect, render_to_response
|
from django.shortcuts import get_object_or_404, redirect, render
|
||||||
from django.core.files.temp import NamedTemporaryFile
|
from django.core.files.temp import NamedTemporaryFile
|
||||||
from wsgiref.util import FileWrapper
|
from wsgiref.util import FileWrapper
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
@ -1240,10 +1239,10 @@ def item(request, id):
|
||||||
level = request.user.profile.level
|
level = request.user.profile.level
|
||||||
qs = models.Item.objects.filter(public_id=id, level__lte=level)
|
qs = models.Item.objects.filter(public_id=id, level__lte=level)
|
||||||
if qs.count() == 0:
|
if qs.count() == 0:
|
||||||
context = RequestContext(request, {
|
ctx = {
|
||||||
'base_url': request.build_absolute_uri('/'),
|
'base_url': request.build_absolute_uri('/'),
|
||||||
'settings': settings
|
'settings': settings
|
||||||
})
|
}
|
||||||
else:
|
else:
|
||||||
item = qs[0]
|
item = qs[0]
|
||||||
template = 'item.html'
|
template = 'item.html'
|
||||||
|
@ -1340,6 +1339,5 @@ def item(request, id):
|
||||||
if value:
|
if value:
|
||||||
ctx['keywords'] = ox.strip_tags(value)
|
ctx['keywords'] = ox.strip_tags(value)
|
||||||
|
|
||||||
context = RequestContext(request, ctx)
|
return render(request, template, ctx)
|
||||||
return render_to_response(template, context)
|
|
||||||
|
|
||||||
|
|
|
@ -13,8 +13,7 @@ from ox.django.shortcuts import render_to_json_response, get_object_or_404_json,
|
||||||
from django import forms
|
from django import forms
|
||||||
from django.db.models import Sum, Max
|
from django.db.models import Sum, Max
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.shortcuts import render_to_response
|
from django.shortcuts import render
|
||||||
from django.template import RequestContext
|
|
||||||
|
|
||||||
from item import utils
|
from item import utils
|
||||||
from archive.chunk import process_chunk
|
from archive.chunk import process_chunk
|
||||||
|
@ -381,13 +380,12 @@ def icon(request, id, size=16):
|
||||||
def pdf_viewer(request, id):
|
def pdf_viewer(request, id):
|
||||||
text = get_text_or_404_json(id)
|
text = get_text_or_404_json(id)
|
||||||
if text.type == 'pdf' and text.file and not text.uploading:
|
if text.type == 'pdf' and text.file and not text.uploading:
|
||||||
context = RequestContext(request, {
|
return render(request, 'pdf/viewer.html', {
|
||||||
'editable': json.dumps(text.editable(request.user)),
|
'editable': json.dumps(text.editable(request.user)),
|
||||||
'embeds': json.dumps(text.embeds),
|
'embeds': json.dumps(text.embeds),
|
||||||
'settings': settings,
|
'settings': settings,
|
||||||
'url': text.get_absolute_pdf_url()
|
'url': text.get_absolute_pdf_url()
|
||||||
})
|
})
|
||||||
return render_to_response('pdf/viewer.html', context)
|
|
||||||
response = json_response(status=404, text='file not found')
|
response = json_response(status=404, text='file not found')
|
||||||
return render_to_json_response(response)
|
return render_to_json_response(response)
|
||||||
|
|
||||||
|
@ -434,7 +432,7 @@ def text(request, id=''):
|
||||||
if id != '' and not text.accessible(request.user):
|
if id != '' and not text.accessible(request.user):
|
||||||
raise
|
raise
|
||||||
template = 'text.html'
|
template = 'text.html'
|
||||||
context = RequestContext(request, {
|
context = {
|
||||||
'base_url': request.build_absolute_uri('/'),
|
'base_url': request.build_absolute_uri('/'),
|
||||||
'description': ox.strip_tags(text.description),
|
'description': ox.strip_tags(text.description),
|
||||||
'icon': request.build_absolute_uri('/text/%s/icon256.jpg' % text.get_id()),
|
'icon': request.build_absolute_uri('/text/%s/icon256.jpg' % text.get_id()),
|
||||||
|
@ -442,12 +440,12 @@ def text(request, id=''):
|
||||||
'text': text,
|
'text': text,
|
||||||
'title': ox.strip_tags(text.name),
|
'title': ox.strip_tags(text.name),
|
||||||
'url': request.build_absolute_uri(text.get_absolute_url()),
|
'url': request.build_absolute_uri(text.get_absolute_url()),
|
||||||
})
|
}
|
||||||
except:
|
except:
|
||||||
template = 'index.html'
|
template = 'index.html'
|
||||||
context = RequestContext(request, {
|
context = {
|
||||||
'base_url': request.build_absolute_uri('/'),
|
'base_url': request.build_absolute_uri('/'),
|
||||||
'settings': settings,
|
'settings': settings,
|
||||||
'title': settings.SITENAME
|
'title': settings.SITENAME
|
||||||
})
|
}
|
||||||
return render_to_response(template, context)
|
return render(request, template, context)
|
||||||
|
|
|
@ -6,7 +6,7 @@ import re
|
||||||
import json
|
import json
|
||||||
|
|
||||||
from django.contrib.auth import authenticate, login, logout
|
from django.contrib.auth import authenticate, login, logout
|
||||||
from django.template import RequestContext, loader
|
from django.template import loader
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.core.mail import send_mail, BadHeaderError, EmailMessage
|
from django.core.mail import send_mail, BadHeaderError, EmailMessage
|
||||||
from django.shortcuts import redirect
|
from django.shortcuts import redirect
|
||||||
|
@ -306,13 +306,13 @@ def requestToken(request, data):
|
||||||
user_profile.save()
|
user_profile.save()
|
||||||
|
|
||||||
template = loader.get_template('password_reset_email.txt')
|
template = loader.get_template('password_reset_email.txt')
|
||||||
context = RequestContext(request, {
|
context = {
|
||||||
'code': code,
|
'code': code,
|
||||||
'sitename': settings.SITENAME,
|
'sitename': settings.SITENAME,
|
||||||
'footer': settings.CONFIG['site']['email']['footer'],
|
'footer': settings.CONFIG['site']['email']['footer'],
|
||||||
'url': request.build_absolute_uri('/'),
|
'url': request.build_absolute_uri('/'),
|
||||||
})
|
}
|
||||||
message = template.render(context)
|
message = template.render(context, request)
|
||||||
subject = '%s - Reset Password' % settings.SITENAME
|
subject = '%s - Reset Password' % settings.SITENAME
|
||||||
user.email_user(subject, message)
|
user.email_user(subject, message)
|
||||||
response = json_response({
|
response = json_response({
|
||||||
|
@ -593,14 +593,14 @@ def mail(request, data):
|
||||||
if 'receipt' in data \
|
if 'receipt' in data \
|
||||||
and data['receipt']:
|
and data['receipt']:
|
||||||
template = loader.get_template('mailout_receipt.txt')
|
template = loader.get_template('mailout_receipt.txt')
|
||||||
context = RequestContext(request, {
|
context = {
|
||||||
'footer': settings.CONFIG['site']['email']['footer'],
|
'footer': settings.CONFIG['site']['email']['footer'],
|
||||||
'to': ', '.join(['"%s" <%s>' % (u.username, u.email) for u in users]),
|
'to': ', '.join(['"%s" <%s>' % (u.username, u.email) for u in users]),
|
||||||
'subject': subject,
|
'subject': subject,
|
||||||
'message': data['message'],
|
'message': data['message'],
|
||||||
'url': request.build_absolute_uri('/'),
|
'url': request.build_absolute_uri('/'),
|
||||||
})
|
}
|
||||||
message = template.render(context)
|
message = template.render(context, request)
|
||||||
subject = u'Fwd: %s' % subject
|
subject = u'Fwd: %s' % subject
|
||||||
email_to = '"%s" <%s>' % (request.user.username, request.user.email)
|
email_to = '"%s" <%s>' % (request.user.username, request.user.email)
|
||||||
receipt = EmailMessage(subject,
|
receipt = EmailMessage(subject,
|
||||||
|
@ -637,7 +637,7 @@ def contact(request, data):
|
||||||
email_to = [settings.CONFIG['site']['email']['contact'], ]
|
email_to = [settings.CONFIG['site']['email']['contact'], ]
|
||||||
subject = data.get('subject', '').strip()
|
subject = data.get('subject', '').strip()
|
||||||
template = loader.get_template('contact_email.txt')
|
template = loader.get_template('contact_email.txt')
|
||||||
context = RequestContext(request, {
|
context = {
|
||||||
'name': name,
|
'name': name,
|
||||||
'email': email,
|
'email': email,
|
||||||
'subject': subject,
|
'subject': subject,
|
||||||
|
@ -645,9 +645,9 @@ def contact(request, data):
|
||||||
'sitename': settings.SITENAME,
|
'sitename': settings.SITENAME,
|
||||||
'footer': settings.CONFIG['site']['email']['footer'],
|
'footer': settings.CONFIG['site']['email']['footer'],
|
||||||
'url': request.build_absolute_uri('/'),
|
'url': request.build_absolute_uri('/'),
|
||||||
})
|
}
|
||||||
subject = ox.decode_html(subject)
|
subject = ox.decode_html(subject)
|
||||||
message = ox.decode_html(template.render(context))
|
message = ox.decode_html(template.render(context, request))
|
||||||
response = json_response(text='message sent')
|
response = json_response(text='message sent')
|
||||||
try:
|
try:
|
||||||
send_mail(u'%s Contact - %s' % (settings.SITENAME, subject), message, email_from, email_to)
|
send_mail(u'%s Contact - %s' % (settings.SITENAME, subject), message, email_from, email_to)
|
||||||
|
@ -657,7 +657,7 @@ def contact(request, data):
|
||||||
and 'receipt' in data \
|
and 'receipt' in data \
|
||||||
and data['receipt']:
|
and data['receipt']:
|
||||||
template = loader.get_template('contact_receipt.txt')
|
template = loader.get_template('contact_receipt.txt')
|
||||||
context = RequestContext(request, {
|
context = {
|
||||||
'name': name,
|
'name': name,
|
||||||
'from': email,
|
'from': email,
|
||||||
'sitename': settings.SITENAME,
|
'sitename': settings.SITENAME,
|
||||||
|
@ -666,8 +666,8 @@ def contact(request, data):
|
||||||
'subject': subject,
|
'subject': subject,
|
||||||
'message': data['message'].strip(),
|
'message': data['message'].strip(),
|
||||||
'url': request.build_absolute_uri('/'),
|
'url': request.build_absolute_uri('/'),
|
||||||
})
|
}
|
||||||
message = template.render(context)
|
message = template.render(context, request)
|
||||||
try:
|
try:
|
||||||
send_mail('Fwd: %s' % subject, message, email_from, [email])
|
send_mail('Fwd: %s' % subject, message, email_from, [email])
|
||||||
except:
|
except:
|
||||||
|
|
Loading…
Reference in a new issue