Skip to content

Commit

Permalink
Merge pull request #642 from JieZhaoAllen/bootswatch-dev
Browse files Browse the repository at this point in the history
解决xadmin主题无效的问题
  • Loading branch information
wgbbiao authored Apr 3, 2019
2 parents f209bf6 + ea53bfc commit 291b63b
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions xadmin/plugins/themes.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#coding:utf-8
from __future__ import print_function
import httplib2
import requests
from django.template import loader
from django.core.cache import cache
from django.utils import six
Expand Down Expand Up @@ -71,16 +71,13 @@ def block_top_navmenu(self, context, nodes):
else:
ex_themes = []
try:
h = httplib2.Http()
resp, content = h.request("https://bootswatch.com/api/3.json", 'GET', '',
headers={"Accept": "application/json", "User-Agent": self.request.META['HTTP_USER_AGENT']})
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.decode()
watch_themes = json.loads(content)['themes']
ex_themes.extend([
{'name': t['name'], 'description': t['description'],
'css': t['cssMin'], 'thumbnail': t['thumbnail']}
for t in watch_themes])
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])
except Exception as e:
print(e)

Expand Down

0 comments on commit 291b63b

Please sign in to comment.