Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
f1nality committed Apr 29, 2017
1 parent 81dd7d5 commit b145be8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
14 changes: 4 additions & 10 deletions jet/dashboard/dashboard.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from django.template import Context
from importlib import import_module
from django.core.urlresolvers import reverse
from django.template.loader import render_to_string
from jet.dashboard import modules
from jet.dashboard.models import UserDashboardModule
from django.utils.translation import ugettext_lazy as _
from jet.ordered_set import OrderedSet
from jet.utils import get_admin_site_name
from jet.utils import get_admin_site_name, context_to_dict

try:
from django.template.context_processors import csrf
except ImportError:
Expand Down Expand Up @@ -48,12 +48,6 @@ def __init__(self, context, **kwargs):
self.set_context(context)

def set_context(self, context):
if isinstance(context, Context):
flat = {}
for d in context.dicts:
flat.update(d)
context = flat

self.context = context
self.init_with_context(context)
self.load_modules()
Expand Down Expand Up @@ -153,7 +147,7 @@ def load_modules(self):
self.modules = loaded_modules

def render(self):
context = self.context
context = context_to_dict(self.context)
context.update({
'columns': range(self.columns),
'modules': self.modules,
Expand All @@ -164,7 +158,7 @@ def render(self):
return render_to_string('jet.dashboard/dashboard.html', context)

def render_tools(self):
context = self.context
context = context_to_dict(self.context)
context.update({
'children': self.children,
'app_label': self.app_label,
Expand Down
11 changes: 11 additions & 0 deletions jet/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import datetime
import json
from django.template import Context
from django.utils import translation
from jet import settings
from jet.models import PinnedApplication
Expand Down Expand Up @@ -426,3 +427,13 @@ def get_menu_item_app(data):
app['current'] = False

return app_list


def context_to_dict(context):
if isinstance(context, Context):
flat = {}
for d in context.dicts:
flat.update(d)
context = flat

return context

0 comments on commit b145be8

Please sign in to comment.