From e6b9de3b7b5ae90efdaaae852bcb4939ccbd615b Mon Sep 17 00:00:00 2001 From: youguanxinqing Date: Tue, 20 Aug 2019 23:16:31 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=BB=E9=A2=98?= =?UTF-8?q?=E4=B8=8D=E8=83=BD=E6=AD=A3=E5=B8=B8=E4=BD=BF=E7=94=A8=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- xadmin/plugins/themes.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/xadmin/plugins/themes.py b/xadmin/plugins/themes.py index d83dd9cc3..a665c38dc 100644 --- a/xadmin/plugins/themes.py +++ b/xadmin/plugins/themes.py @@ -1,3 +1,9 @@ +''' +@Date: 2019-08-20 22:46:33 +@Author: Guan +@Github: https://github.com/youguanxinqing +@LastEditTime: 2019-08-20 23:15:55 +''' #coding:utf-8 from __future__ import print_function import requests @@ -73,8 +79,6 @@ def block_top_navmenu(self, context, nodes): try: headers = {"Accept": "application/json", "User-Agent": self.request.META['HTTP_USER_AGENT']} content = requests.get("https://bootswatch.com/api/3.json", headers=headers) - if six.PY3: - content = content.text.decode() watch_themes = json.loads(content.text)['themes'] ex_themes.extend([{'name': t['name'], 'description': t['description'], 'css': t['cssMin'], 'thumbnail': t['thumbnail']} for t in watch_themes]) @@ -84,7 +88,7 @@ def block_top_navmenu(self, context, nodes): cache.set(THEME_CACHE_KEY, json.dumps(ex_themes), 24 * 3600) themes.extend(ex_themes) - nodes.append(loader.render_to_string('xadmin/blocks/comm.top.theme.html', {'themes': themes, 'select_css': select_css})) + nodes.append(loader.render_to_string('xadmin/blocks/comm.top.theme.html', {'themes': themes, 'select_csss': select_css})) site.register_plugin(ThemePlugin, BaseAdminView) From 37f5b3c7beb53d1825eb5f3725fc4651b79486a6 Mon Sep 17 00:00:00 2001 From: youguanxinqing Date: Tue, 20 Aug 2019 23:19:42 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E8=BF=98=E5=8E=9F=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E6=A0=B7=E5=BC=8F=EF=BC=8C=E5=88=A0=E9=99=A4=E8=AF=AF=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- xadmin/plugins/themes.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/xadmin/plugins/themes.py b/xadmin/plugins/themes.py index a665c38dc..9c07ae687 100644 --- a/xadmin/plugins/themes.py +++ b/xadmin/plugins/themes.py @@ -1,9 +1,3 @@ -''' -@Date: 2019-08-20 22:46:33 -@Author: Guan -@Github: https://github.com/youguanxinqing -@LastEditTime: 2019-08-20 23:15:55 -''' #coding:utf-8 from __future__ import print_function import requests @@ -88,7 +82,7 @@ def block_top_navmenu(self, context, nodes): cache.set(THEME_CACHE_KEY, json.dumps(ex_themes), 24 * 3600) themes.extend(ex_themes) - nodes.append(loader.render_to_string('xadmin/blocks/comm.top.theme.html', {'themes': themes, 'select_csss': select_css})) + nodes.append(loader.render_to_string('xadmin/blocks/comm.top.theme.html', {'themes': themes, 'select_css': select_css})) site.register_plugin(ThemePlugin, BaseAdminView)