Skip to content

Commit 5e61f33

Browse files
committed
Merge branch 'release/1.3.2'
2 parents 50ba280 + 5f832e4 commit 5e61f33

File tree

14 files changed

+339
-88
lines changed

14 files changed

+339
-88
lines changed

README.md

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,36 @@
99
[![Download Status](https://img.shields.io/pypi/dm/django-adminlte-ui.svg)](https://pypi.python.org/pypi/django-adminlte-ui)
1010
[![Build Status](https://api.travis-ci.org/wuyue92tree/django-adminlte-ui.svg)](https://travis-ci.org/wuyue92tree/django-adminlte-ui)
1111
[![Documentation Status](https://readthedocs.org/projects/django-adminlte-ui/badge/?version=latest)](https://django-adminlte-ui.readthedocs.io/en/latest/?badge=latest)
12+
[![Gitter](https://badges.gitter.im/django-adminlte-ui/community.svg)](https://gitter.im/django-adminlte-ui/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
1213

1314
django admin theme base on adminlte
1415

1516
adminlte version: 2.3.6
1617

17-
# helper
18+
# Helper
1819

1920
- if you have good ideas, just contact me.
2021
- if you find some bug, just add an issue.
2122
- if you think this project is good, just star and fork, make it better 🍉.
2223

23-
# install
24+
# Demo
25+
26+
[Chinese](http://django-demo.antio.top/zh-hans/admin/)
27+
28+
[English](http://django-demo.antio.top/en/admin/)
29+
30+
- username: demo
31+
- password: demo123
32+
33+
database will restore every hour. 🍌
34+
35+
# Install
2436

2537
```
2638
pip install django-adminlte-ui
2739
```
2840

29-
# setup
41+
# Setup
3042

3143
```
3244
# settings.py
@@ -52,7 +64,7 @@ INSTALLED_APPS = [
5264
python manage.py migrate django_admin_settings
5365
```
5466

55-
# screen shot
67+
# Screen shot
5668

5769
## login page
5870
![login](./images/login.jpg)
@@ -74,13 +86,13 @@ python manage.py migrate django_admin_settings
7486
![menu list](./images/menu-list.png)
7587

7688

77-
# features
89+
# Features
7890

7991
- [Custom General Option](https://django-adminlte-ui.readthedocs.io/en/latest/guide/#general-option)
8092
- [Widgets](https://django-adminlte-ui.readthedocs.io/en/latest/guide/#widgets)
8193
- [Custom Menu](https://django-adminlte-ui.readthedocs.io/en/latest/guide/#menu)
8294

83-
# TODO
95+
# Todo
8496

8597
- Custom Dashboard
8698

adminlteui/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
version = '1.3.1'
1+
version = '1.3.2'
22
default_app_config = 'adminlteui.apps.AdminlteUIConfig'

adminlteui/admin.py

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from django.utils.translation import gettext_lazy as _
1111
from django.utils.html import format_html
1212
from django.conf import settings
13-
from django.http.response import HttpResponse
13+
from django.http.response import HttpResponse, HttpResponseForbidden
1414
from adminlteui.widgets import AdminlteSelect
1515
from treebeard.admin import TreeAdmin
1616
from treebeard.forms import movenodeform_factory
@@ -69,6 +69,14 @@ class GeneralOptionForm(forms.Form):
6969
help_text=_("Login page welcome sign.")
7070
)
7171

72+
avatar_field = forms.CharField(label=_('Avatar Field'),
73+
widget=widgets.AdminTextInputWidget(),
74+
required=False,
75+
help_text=_(
76+
"which field is avatar."))
77+
show_avatar = forms.BooleanField(
78+
label=_('Show Avatar'), required=False)
79+
7280
def save(self):
7381
try:
7482
# clear site-logo
@@ -77,6 +85,16 @@ def save(self):
7785
obj.delete()
7886
self.changed_data.remove('site_logo')
7987

88+
if not self.data.get('show_avatar'):
89+
try:
90+
obj = Options.objects.get(option_name='show_avatar')
91+
obj.option_value = 'off'
92+
obj.save()
93+
except Exception:
94+
obj = Options.objects.create(option_name='show_avatar',
95+
option_value='off')
96+
obj.save()
97+
8098
for data_item in self.changed_data:
8199
try:
82100
obj = Options.objects.get(option_name=data_item)
@@ -144,6 +162,11 @@ def get_urls(self):
144162
return urls + base_urls
145163

146164
def general_option_view(self, request):
165+
if request.user.has_perm('django_admin_settings.add_options') is False \
166+
and request.user.has_perm(
167+
'django_admin_settings.change_options') is False:
168+
return HttpResponseForbidden(format_html('<h1>403 Forbidden</h1>'))
169+
147170
context = dict(
148171
self.admin_site.each_context(request),
149172
)
@@ -159,7 +182,11 @@ def general_option_view(self, request):
159182
'welcome_sign': get_option(option_name='welcome_sign'),
160183
'site_logo': ImageBox(
161184
get_option(option_name='site_logo')) if get_option(
162-
option_name='site_logo') else ''
185+
option_name='site_logo') else '',
186+
'show_avatar': True if get_option(
187+
option_name='show_avatar') == 'on' else False,
188+
'avatar_field': get_option(
189+
option_name='avatar_field') or 'request.user.head_avatar',
163190
}
164191
form = GeneralOptionForm(initial=initial_value)
165192
else:
@@ -178,7 +205,11 @@ def general_option_view(self, request):
178205
'welcome_sign': get_option(option_name='welcome_sign'),
179206
'site_logo': ImageBox(
180207
get_option(option_name='site_logo')) if get_option(
181-
option_name='site_logo') else ''
208+
option_name='site_logo') else '',
209+
'show_avatar': True if get_option(
210+
option_name='show_avatar') == 'on' else False,
211+
'avatar_field': get_option(
212+
option_name='avatar_field') or 'request.user.head_avatar',
182213
}
183214
form = GeneralOptionForm(initial=initial_value)
184215
messages.add_message(request, messages.SUCCESS,
@@ -230,6 +261,8 @@ def get_urls(self):
230261
return urls + base_urls
231262

232263
def exchange_menu_view(self, request):
264+
if request.user.has_perm('django_admin_settings.view_menu') is False:
265+
return HttpResponseForbidden(format_html('<h1>403 Forbidden</h1>'))
233266
if request.is_ajax():
234267
response_data = dict()
235268
response_data['message'] = 'success'
@@ -244,12 +277,14 @@ def exchange_menu_view(self, request):
244277
if not use_custom_menu or use_custom_menu.option_value == '0':
245278
use_custom_menu.option_value = '1'
246279
use_custom_menu.save()
247-
messages.add_message(request, messages.SUCCESS, _('Menu exchanged, current is `custom menu`.'))
280+
messages.add_message(request, messages.SUCCESS, _(
281+
'Menu exchanged, current is `custom menu`.'))
248282

249283
else:
250284
use_custom_menu.option_value = '0'
251285
use_custom_menu.save()
252-
messages.add_message(request, messages.SUCCESS, _('Menu exchanged, current is `system menu`.'))
286+
messages.add_message(request, messages.SUCCESS, _(
287+
'Menu exchanged, current is `system menu`.'))
253288
return HttpResponse(json.dumps(response_data),
254289
content_type="application/json,charset=utf-8")
255290
return HttpResponse('method not allowed.')
156 Bytes
Binary file not shown.

adminlteui/locale/zh-Hans/LC_MESSAGES/django.po

Lines changed: 50 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ msgid ""
88
msgstr ""
99
"Project-Id-Version: PACKAGE VERSION\n"
1010
"Report-Msgid-Bugs-To: \n"
11-
"POT-Creation-Date: 2019-07-09 10:24+0800\n"
11+
"POT-Creation-Date: 2019-07-10 22:14+0800\n"
1212
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
1313
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
1414
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -49,35 +49,47 @@ msgstr "欢迎标语"
4949
msgid "Login page welcome sign."
5050
msgstr "登录页面欢迎标语"
5151

52-
#: admin.py:87 admin.py:105
52+
#: admin.py:72
53+
msgid "Avatar Field"
54+
msgstr "头像字段"
55+
56+
#: admin.py:76
57+
msgid "which field is avatar."
58+
msgstr "用户表中头像对应的字段"
59+
60+
#: admin.py:78
61+
msgid "Show Avatar"
62+
msgstr "显示头像"
63+
64+
#: admin.py:105 admin.py:123
5365
msgid "site_logo depends on setting.MEDIA_URL and setting.MEDIA_ROOT."
5466
msgstr "site_logo依赖于setting.MEDIA_URL和setting.MEDIA_ROOT。"
5567

56-
#: admin.py:185
68+
#: admin.py:216
5769
msgid "General Option Saved."
5870
msgstr "基本设置保存成功。"
5971

60-
#: admin.py:188
72+
#: admin.py:219
6173
msgid "General Option Save Failed."
6274
msgstr "基本设置保存失败。"
6375

64-
#: admin.py:217 admin.py:287 models.py:49
76+
#: admin.py:248 admin.py:324 models.py:49
6577
msgid "ContentType"
6678
msgstr "关联Model"
6779

68-
#: admin.py:245
80+
#: admin.py:281
6981
msgid "Menu exchanged, current is `custom menu`."
7082
msgstr "菜单切换成功,当前为`自定义菜单`"
7183

72-
#: admin.py:250
84+
#: admin.py:287
7385
msgid "Menu exchanged, current is `system menu`."
7486
msgstr "菜单切换成功,当前为`系统菜单`"
7587

76-
#: admin.py:271 models.py:41
88+
#: admin.py:308 models.py:41
7789
msgid "Link"
7890
msgstr "链接"
7991

80-
#: admin.py:279 models.py:46
92+
#: admin.py:316 models.py:46
8193
msgid "Icon"
8294
msgstr "图标"
8395

@@ -227,7 +239,7 @@ msgstr ""
227239
#: templates/admin/auth/user/change_password.html:22
228240
#: templates/admin/auth/user/change_password.html:27
229241
#: templates/admin/auth/user/change_password.html:94
230-
#: templates/admin/base.html:119
242+
#: templates/admin/base.html:151
231243
#: templates/registration/password_change_done.html:3
232244
#: templates/registration/password_change_form.html:7
233245
#: templates/registration/password_change_form.html:102
@@ -251,66 +263,67 @@ msgstr ""
251263
msgid "Please correct the errors below."
252264
msgstr ""
253265

254-
#: templates/admin/base.html:90
266+
#: templates/admin/base.html:104 templates/admin/base.html:120
255267
msgid "Super manager"
256268
msgstr "超级管理员"
257269

258-
#: templates/admin/base.html:95
270+
#: templates/admin/base.html:109 templates/admin/base.html:125
259271
msgid "Normal"
260272
msgstr "普通用户"
261273

262-
#: templates/admin/base.html:98
274+
#: templates/admin/base.html:112 templates/admin/base.html:128
263275
msgid "Register time"
264276
msgstr "注册时间"
265277

266-
#: templates/admin/base.html:122
278+
#: templates/admin/base.html:154
267279
#: templates/registration/password_change_done.html:3
268280
#: templates/registration/password_change_form.html:7
269281
msgid "Log out"
270282
msgstr ""
271283

272-
#: templates/admin/base.html:146
284+
#: templates/admin/base.html:185
273285
msgid "Online"
274286
msgstr "在线"
275287

276-
#: templates/admin/base.html:152 templates/admin/search_form.html:20
288+
#: templates/admin/base.html:192 templates/admin/search_form.html:20
277289
msgid "Search"
278290
msgstr "搜索"
279291

280-
#: templates/admin/base.html:162
292+
#: templates/admin/base.html:202
281293
msgid "MAIN NAVIGATION"
282294
msgstr "页面导航"
283295

284-
#: templates/admin/base.html:165
296+
#: templates/admin/base.html:205
285297
msgid "Dashboard"
286298
msgstr "仪表盘"
287299

288-
#: templates/admin/base.html:197
300+
#: templates/admin/base.html:237
289301
msgid "System manage"
290302
msgstr ""
291303

292-
#: templates/admin/base.html:203
304+
#: templates/admin/base.html:243
293305
msgid "Log manage"
294306
msgstr ""
295307

296-
#: templates/admin/base.html:204
308+
#: templates/admin/base.html:244
297309
msgid "System config"
298310
msgstr ""
299311

300-
#: templates/admin/base.html:210
312+
#: templates/admin/base.html:250
301313
msgid "Important"
302314
msgstr ""
303315

304-
#: templates/admin/base.html:211
316+
#: templates/admin/base.html:251
305317
msgid "Warning"
306318
msgstr ""
307319

308-
#: templates/admin/base.html:212
320+
#: templates/admin/base.html:252
309321
msgid "Information"
310322
msgstr ""
311323

312324
#: templates/admin/base_site.html:8 templates/admin/login.html:13
313325
#: templates/adminlte/general_option.html:23
326+
#: templates/registration/logged_out.html:13
314327
msgid "Django site admin"
315328
msgstr ""
316329

@@ -466,7 +479,7 @@ msgstr ""
466479
msgid "Log in"
467480
msgstr "登录"
468481

469-
#: templates/admin/login.html:60
482+
#: templates/admin/login.html:60 templates/registration/logged_out.html:58
470483
msgid "Login and Enjoy"
471484
msgstr "芝麻开门"
472485

@@ -570,14 +583,25 @@ msgstr ""
570583
#: templates/adminlte/general_option.html:14
571584
#: templates/adminlte/general_option.html:18
572585
#: templates/adminlte/general_option.html:27
573-
#: templates/adminlte/general_option.html:36 templatetags/adminlte_menu.py:139
586+
#: templates/adminlte/general_option.html:36 templatetags/adminlte_menu.py:142
574587
msgid "General Option"
575588
msgstr "基本设置"
576589

577590
#: templates/adminlte/menu_change_list.html:4
578591
msgid "Exchange Menu"
579592
msgstr "菜单切换"
580593

594+
#: templates/registration/logged_out.html:15
595+
#: templates/registration/logged_out.html:63
596+
#, fuzzy
597+
#| msgid "Log in"
598+
msgid "Log in again"
599+
msgstr "登录"
600+
601+
#: templates/registration/logged_out.html:61
602+
msgid "Thanks for spending some quality time with the Web site today."
603+
msgstr ""
604+
581605
#: templates/registration/password_change_done.html:3
582606
#: templates/registration/password_change_form.html:7
583607
msgid "Documentation"
156 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)