Commit 252fd315 by Czémán Arnold

circle, common, dashboard, firewall, request: fix deprecated context and cache…

circle, common, dashboard, firewall, request: fix deprecated context and cache handling, get_models, and max_length type for ConnectCommand name
parent e385e311
...@@ -12,9 +12,9 @@ def update_permissions_after_migration(sender, **kwargs): ...@@ -12,9 +12,9 @@ def update_permissions_after_migration(sender, **kwargs):
""" """
from django.conf import settings from django.conf import settings
from django.db.models import get_models from django.apps import apps
from django.contrib.auth.management import create_permissions from django.contrib.auth.management import create_permissions
create_permissions(sender, get_models(), 2 if settings.DEBUG else 0) create_permissions(sender, apps.get_models(), 2 if settings.DEBUG else 0)
post_migrate.connect(update_permissions_after_migration) post_migrate.connect(update_permissions_after_migration)
...@@ -45,7 +45,8 @@ def handler500(request): ...@@ -45,7 +45,8 @@ def handler500(request):
logger.exception("unhandled exception") logger.exception("unhandled exception")
ctx = get_context(request, exception) ctx = get_context(request, exception)
try: try:
resp = render_to_response("500.html", ctx, RequestContext(request)) resp = render_to_response("500.html", ctx,
RequestContext(request).flatten())
except: except:
resp = render_to_response("500.html", ctx) resp = render_to_response("500.html", ctx)
resp.status_code = 500 resp.status_code = 500
......
...@@ -151,7 +151,7 @@ class ConnectCommand(Model): ...@@ -151,7 +151,7 @@ class ConnectCommand(Model):
access_method = CharField(max_length=10, choices=ACCESS_METHODS, access_method = CharField(max_length=10, choices=ACCESS_METHODS,
verbose_name=_('access method'), verbose_name=_('access method'),
help_text=_('Type of the remote access method.')) help_text=_('Type of the remote access method.'))
name = CharField(max_length="128", verbose_name=_('name'), blank=False, name = CharField(max_length=128, verbose_name=_('name'), blank=False,
help_text=_("Name of your custom command.")) help_text=_("Name of your custom command."))
template = CharField(blank=True, null=True, max_length=256, template = CharField(blank=True, null=True, max_length=256,
verbose_name=_('command template'), verbose_name=_('command template'),
......
...@@ -18,7 +18,7 @@ from __future__ import unicode_literals, absolute_import ...@@ -18,7 +18,7 @@ from __future__ import unicode_literals, absolute_import
import logging import logging
from django.core.cache import get_cache from django.core.cache import cache
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.conf import settings from django.conf import settings
from django.contrib.auth.models import Group, User from django.contrib.auth.models import Group, User
...@@ -103,7 +103,6 @@ class IndexView(LoginRequiredMixin, TemplateView): ...@@ -103,7 +103,6 @@ class IndexView(LoginRequiredMixin, TemplateView):
# toplist # toplist
if settings.STORE_URL: if settings.STORE_URL:
cache_key = "files-%d" % self.request.user.pk cache_key = "files-%d" % self.request.user.pk
cache = get_cache("default")
files = cache.get(cache_key) files = cache.get(cache_key)
if not files: if not files:
try: try:
......
...@@ -331,7 +331,8 @@ class NodeActivityView(LoginRequiredMixin, SuperuserRequiredMixin, View): ...@@ -331,7 +331,8 @@ class NodeActivityView(LoginRequiredMixin, SuperuserRequiredMixin, View):
'activities': render_to_string( 'activities': render_to_string(
"dashboard/node-detail/_activity-timeline.html", "dashboard/node-detail/_activity-timeline.html",
RequestContext(request, {'activities': activities, RequestContext(request, {'activities': activities,
'show_show_all': show_show_all})) 'show_show_all': show_show_all}
).flatten())
} }
return HttpResponse( return HttpResponse(
......
...@@ -24,7 +24,7 @@ from django.conf import settings ...@@ -24,7 +24,7 @@ from django.conf import settings
from django.contrib import messages from django.contrib import messages
from django.contrib.auth.decorators import login_required from django.contrib.auth.decorators import login_required
from django.template.defaultfilters import urlencode from django.template.defaultfilters import urlencode
from django.core.cache import get_cache from django.core.cache import cache
from django.core.exceptions import SuspiciousOperation from django.core.exceptions import SuspiciousOperation
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.http import HttpResponse from django.http import HttpResponse
...@@ -65,7 +65,7 @@ class StoreList(LoginRequiredMixin, TemplateView): ...@@ -65,7 +65,7 @@ class StoreList(LoginRequiredMixin, TemplateView):
context = self.get_context_data(**kwargs) context = self.get_context_data(**kwargs)
return render_to_response( return render_to_response(
"dashboard/store/_list-box.html", "dashboard/store/_list-box.html",
RequestContext(self.request, context), RequestContext(self.request, context).flatten(),
) )
else: else:
return super(StoreList, self).get(*args, **kwargs) return super(StoreList, self).get(*args, **kwargs)
...@@ -193,7 +193,6 @@ def store_new_directory(request): ...@@ -193,7 +193,6 @@ def store_new_directory(request):
@login_required @login_required
def store_refresh_toplist(request): def store_refresh_toplist(request):
cache_key = "files-%d" % request.user.pk cache_key = "files-%d" % request.user.pk
cache = get_cache("default")
try: try:
store = Store(request.user) store = Store(request.user)
toplist = store.toplist() toplist = store.toplist()
......
...@@ -231,7 +231,7 @@ class MyPreferencesView(UpdateView): ...@@ -231,7 +231,7 @@ class MyPreferencesView(UpdateView):
def get(self, request, form=None, *args, **kwargs): def get(self, request, form=None, *args, **kwargs):
# if this is not here, it won't work # if this is not here, it won't work
self.object = self.get_object() self.object = self.get_object()
context = self.get_context_data(*args, **kwargs) context = self.get_context_data(form=form, *args, **kwargs)
if form is not None: if form is not None:
# a little cheating, users can't post invalid # a little cheating, users can't post invalid
# language selection forms (without modifying the HTML) # language selection forms (without modifying the HTML)
......
...@@ -1286,15 +1286,15 @@ def vm_activity(request, pk): ...@@ -1286,15 +1286,15 @@ def vm_activity(request, pk):
response['activities'] = render_to_string( response['activities'] = render_to_string(
"dashboard/vm-detail/_activity-timeline.html", "dashboard/vm-detail/_activity-timeline.html",
RequestContext(request, context), RequestContext(request, context).flatten(),
) )
response['ops'] = render_to_string( response['ops'] = render_to_string(
"dashboard/vm-detail/_operations.html", "dashboard/vm-detail/_operations.html",
RequestContext(request, context), RequestContext(request, context).flatten(),
) )
response['disk_ops'] = render_to_string( response['disk_ops'] = render_to_string(
"dashboard/vm-detail/_disk-operations.html", "dashboard/vm-detail/_disk-operations.html",
RequestContext(request, context), RequestContext(request, context).flatten(),
) )
return HttpResponse( return HttpResponse(
......
...@@ -25,7 +25,7 @@ from .models import (Host, Rule, Vlan, Domain, Record, BlacklistItem, ...@@ -25,7 +25,7 @@ from .models import (Host, Rule, Vlan, Domain, Record, BlacklistItem,
SwitchPort) SwitchPort)
from .iptables import IptRule, IptChain from .iptables import IptRule, IptChain
import django.conf import django.conf
from django.template import loader, Context from django.template import loader
from django.utils import timezone from django.utils import timezone
...@@ -152,9 +152,9 @@ class BuildFirewall: ...@@ -152,9 +152,9 @@ class BuildFirewall:
template = loader.get_template('firewall/iptables.conf') template = loader.get_template('firewall/iptables.conf')
context['proto'] = 'ipv4' context['proto'] = 'ipv4'
ipv4 = unicode(template.render(Context(context))) ipv4 = unicode(template.render(context))
context['proto'] = 'ipv6' context['proto'] = 'ipv6'
ipv6 = unicode(template.render(Context(context))) ipv6 = unicode(template.render(context))
return (ipv4, ipv6) return (ipv4, ipv6)
......
...@@ -69,7 +69,7 @@ class InitialFromFileMixin(object): ...@@ -69,7 +69,7 @@ class InitialFromFileMixin(object):
self.initial['message'] = render_to_string( self.initial['message'] = render_to_string(
self.initial_template, self.initial_template,
RequestContext(request, {}), RequestContext(request, {}).flatten(),
) )
def clean_message(self): def clean_message(self):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment