Skip to content

Commit

Permalink
Merge branch 'release/1.3.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
wuyue92tree committed Jul 10, 2019
2 parents 50ba280 + 5f832e4 commit 5e61f33
Show file tree
Hide file tree
Showing 14 changed files with 339 additions and 88 deletions.
24 changes: 18 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,36 @@
[![Download Status](https://img.shields.io/pypi/dm/django-adminlte-ui.svg)](https://pypi.python.org/pypi/django-adminlte-ui)
[![Build Status](https://api.travis-ci.org/wuyue92tree/django-adminlte-ui.svg)](https://travis-ci.org/wuyue92tree/django-adminlte-ui)
[![Documentation Status](https://readthedocs.org/projects/django-adminlte-ui/badge/?version=latest)](https://django-adminlte-ui.readthedocs.io/en/latest/?badge=latest)
[![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)

django admin theme base on adminlte

adminlte version: 2.3.6

# helper
# Helper

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

# install
# Demo

[Chinese](http://django-demo.antio.top/zh-hans/admin/)

[English](http://django-demo.antio.top/en/admin/)

- username: demo
- password: demo123

database will restore every hour. 🍌

# Install

```
pip install django-adminlte-ui
```

# setup
# Setup

```
# settings.py
Expand All @@ -52,7 +64,7 @@ INSTALLED_APPS = [
python manage.py migrate django_admin_settings
```

# screen shot
# Screen shot

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


# features
# Features

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

# TODO
# Todo

- Custom Dashboard

Expand Down
2 changes: 1 addition & 1 deletion adminlteui/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version = '1.3.1'
version = '1.3.2'
default_app_config = 'adminlteui.apps.AdminlteUIConfig'
45 changes: 40 additions & 5 deletions adminlteui/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from django.utils.translation import gettext_lazy as _
from django.utils.html import format_html
from django.conf import settings
from django.http.response import HttpResponse
from django.http.response import HttpResponse, HttpResponseForbidden
from adminlteui.widgets import AdminlteSelect
from treebeard.admin import TreeAdmin
from treebeard.forms import movenodeform_factory
Expand Down Expand Up @@ -69,6 +69,14 @@ class GeneralOptionForm(forms.Form):
help_text=_("Login page welcome sign.")
)

avatar_field = forms.CharField(label=_('Avatar Field'),
widget=widgets.AdminTextInputWidget(),
required=False,
help_text=_(
"which field is avatar."))
show_avatar = forms.BooleanField(
label=_('Show Avatar'), required=False)

def save(self):
try:
# clear site-logo
Expand All @@ -77,6 +85,16 @@ def save(self):
obj.delete()
self.changed_data.remove('site_logo')

if not self.data.get('show_avatar'):
try:
obj = Options.objects.get(option_name='show_avatar')
obj.option_value = 'off'
obj.save()
except Exception:
obj = Options.objects.create(option_name='show_avatar',
option_value='off')
obj.save()

for data_item in self.changed_data:
try:
obj = Options.objects.get(option_name=data_item)
Expand Down Expand Up @@ -144,6 +162,11 @@ def get_urls(self):
return urls + base_urls

def general_option_view(self, request):
if request.user.has_perm('django_admin_settings.add_options') is False \
and request.user.has_perm(
'django_admin_settings.change_options') is False:
return HttpResponseForbidden(format_html('<h1>403 Forbidden</h1>'))

context = dict(
self.admin_site.each_context(request),
)
Expand All @@ -159,7 +182,11 @@ def general_option_view(self, request):
'welcome_sign': get_option(option_name='welcome_sign'),
'site_logo': ImageBox(
get_option(option_name='site_logo')) if get_option(
option_name='site_logo') else ''
option_name='site_logo') else '',
'show_avatar': True if get_option(
option_name='show_avatar') == 'on' else False,
'avatar_field': get_option(
option_name='avatar_field') or 'request.user.head_avatar',
}
form = GeneralOptionForm(initial=initial_value)
else:
Expand All @@ -178,7 +205,11 @@ def general_option_view(self, request):
'welcome_sign': get_option(option_name='welcome_sign'),
'site_logo': ImageBox(
get_option(option_name='site_logo')) if get_option(
option_name='site_logo') else ''
option_name='site_logo') else '',
'show_avatar': True if get_option(
option_name='show_avatar') == 'on' else False,
'avatar_field': get_option(
option_name='avatar_field') or 'request.user.head_avatar',
}
form = GeneralOptionForm(initial=initial_value)
messages.add_message(request, messages.SUCCESS,
Expand Down Expand Up @@ -230,6 +261,8 @@ def get_urls(self):
return urls + base_urls

def exchange_menu_view(self, request):
if request.user.has_perm('django_admin_settings.view_menu') is False:
return HttpResponseForbidden(format_html('<h1>403 Forbidden</h1>'))
if request.is_ajax():
response_data = dict()
response_data['message'] = 'success'
Expand All @@ -244,12 +277,14 @@ def exchange_menu_view(self, request):
if not use_custom_menu or use_custom_menu.option_value == '0':
use_custom_menu.option_value = '1'
use_custom_menu.save()
messages.add_message(request, messages.SUCCESS, _('Menu exchanged, current is `custom menu`.'))
messages.add_message(request, messages.SUCCESS, _(
'Menu exchanged, current is `custom menu`.'))

else:
use_custom_menu.option_value = '0'
use_custom_menu.save()
messages.add_message(request, messages.SUCCESS, _('Menu exchanged, current is `system menu`.'))
messages.add_message(request, messages.SUCCESS, _(
'Menu exchanged, current is `system menu`.'))
return HttpResponse(json.dumps(response_data),
content_type="application/json,charset=utf-8")
return HttpResponse('method not allowed.')
Expand Down
Binary file modified adminlteui/locale/zh-Hans/LC_MESSAGES/django.mo
Binary file not shown.
76 changes: 50 additions & 26 deletions adminlteui/locale/zh-Hans/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-07-09 10:24+0800\n"
"POT-Creation-Date: 2019-07-10 22:14+0800\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down Expand Up @@ -49,35 +49,47 @@ msgstr "欢迎标语"
msgid "Login page welcome sign."
msgstr "登录页面欢迎标语"

#: admin.py:87 admin.py:105
#: admin.py:72
msgid "Avatar Field"
msgstr "头像字段"

#: admin.py:76
msgid "which field is avatar."
msgstr "用户表中头像对应的字段"

#: admin.py:78
msgid "Show Avatar"
msgstr "显示头像"

#: admin.py:105 admin.py:123
msgid "site_logo depends on setting.MEDIA_URL and setting.MEDIA_ROOT."
msgstr "site_logo依赖于setting.MEDIA_URL和setting.MEDIA_ROOT。"

#: admin.py:185
#: admin.py:216
msgid "General Option Saved."
msgstr "基本设置保存成功。"

#: admin.py:188
#: admin.py:219
msgid "General Option Save Failed."
msgstr "基本设置保存失败。"

#: admin.py:217 admin.py:287 models.py:49
#: admin.py:248 admin.py:324 models.py:49
msgid "ContentType"
msgstr "关联Model"

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

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

#: admin.py:271 models.py:41
#: admin.py:308 models.py:41
msgid "Link"
msgstr "链接"

#: admin.py:279 models.py:46
#: admin.py:316 models.py:46
msgid "Icon"
msgstr "图标"

Expand Down Expand Up @@ -227,7 +239,7 @@ msgstr ""
#: templates/admin/auth/user/change_password.html:22
#: templates/admin/auth/user/change_password.html:27
#: templates/admin/auth/user/change_password.html:94
#: templates/admin/base.html:119
#: templates/admin/base.html:151
#: templates/registration/password_change_done.html:3
#: templates/registration/password_change_form.html:7
#: templates/registration/password_change_form.html:102
Expand All @@ -251,66 +263,67 @@ msgstr ""
msgid "Please correct the errors below."
msgstr ""

#: templates/admin/base.html:90
#: templates/admin/base.html:104 templates/admin/base.html:120
msgid "Super manager"
msgstr "超级管理员"

#: templates/admin/base.html:95
#: templates/admin/base.html:109 templates/admin/base.html:125
msgid "Normal"
msgstr "普通用户"

#: templates/admin/base.html:98
#: templates/admin/base.html:112 templates/admin/base.html:128
msgid "Register time"
msgstr "注册时间"

#: templates/admin/base.html:122
#: templates/admin/base.html:154
#: templates/registration/password_change_done.html:3
#: templates/registration/password_change_form.html:7
msgid "Log out"
msgstr ""

#: templates/admin/base.html:146
#: templates/admin/base.html:185
msgid "Online"
msgstr "在线"

#: templates/admin/base.html:152 templates/admin/search_form.html:20
#: templates/admin/base.html:192 templates/admin/search_form.html:20
msgid "Search"
msgstr "搜索"

#: templates/admin/base.html:162
#: templates/admin/base.html:202
msgid "MAIN NAVIGATION"
msgstr "页面导航"

#: templates/admin/base.html:165
#: templates/admin/base.html:205
msgid "Dashboard"
msgstr "仪表盘"

#: templates/admin/base.html:197
#: templates/admin/base.html:237
msgid "System manage"
msgstr ""

#: templates/admin/base.html:203
#: templates/admin/base.html:243
msgid "Log manage"
msgstr ""

#: templates/admin/base.html:204
#: templates/admin/base.html:244
msgid "System config"
msgstr ""

#: templates/admin/base.html:210
#: templates/admin/base.html:250
msgid "Important"
msgstr ""

#: templates/admin/base.html:211
#: templates/admin/base.html:251
msgid "Warning"
msgstr ""

#: templates/admin/base.html:212
#: templates/admin/base.html:252
msgid "Information"
msgstr ""

#: templates/admin/base_site.html:8 templates/admin/login.html:13
#: templates/adminlte/general_option.html:23
#: templates/registration/logged_out.html:13
msgid "Django site admin"
msgstr ""

Expand Down Expand Up @@ -466,7 +479,7 @@ msgstr ""
msgid "Log in"
msgstr "登录"

#: templates/admin/login.html:60
#: templates/admin/login.html:60 templates/registration/logged_out.html:58
msgid "Login and Enjoy"
msgstr "芝麻开门"

Expand Down Expand Up @@ -570,14 +583,25 @@ msgstr ""
#: templates/adminlte/general_option.html:14
#: templates/adminlte/general_option.html:18
#: templates/adminlte/general_option.html:27
#: templates/adminlte/general_option.html:36 templatetags/adminlte_menu.py:139
#: templates/adminlte/general_option.html:36 templatetags/adminlte_menu.py:142
msgid "General Option"
msgstr "基本设置"

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

#: templates/registration/logged_out.html:15
#: templates/registration/logged_out.html:63
#, fuzzy
#| msgid "Log in"
msgid "Log in again"
msgstr "登录"

#: templates/registration/logged_out.html:61
msgid "Thanks for spending some quality time with the Web site today."
msgstr ""

#: templates/registration/password_change_done.html:3
#: templates/registration/password_change_form.html:7
msgid "Documentation"
Expand Down
Binary file modified adminlteui/locale/zh/LC_MESSAGES/django.mo
Binary file not shown.
Loading

0 comments on commit 5e61f33

Please sign in to comment.