Skip to content

Commit d90b4b8

Browse files
committed
fix #193 #196 #189
1 parent ee240e5 commit d90b4b8

File tree

5 files changed

+46
-5
lines changed

5 files changed

+46
-5
lines changed

simpleui/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
1+
default_app_config = 'simpleui.apps.SimpleApp'
2+
3+
14
def get_version():
2-
return '3.6'
5+
return '3.7'

simpleui/apps.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from django.apps import AppConfig
2+
3+
4+
class SimpleApp(AppConfig):
5+
name = 'simpleui'
6+
7+
def ready(self):
8+
# 如果是django3+ 就使用中间件,删除header中的X-Frame-Options
9+
10+
try:
11+
import django
12+
version = django.get_version()
13+
if int(version.split('.')[0]) >= 3:
14+
from django.conf import settings
15+
mname = 'simpleui.middlewares.SimpleMiddleware'
16+
if mname not in settings.MIDDLEWARE:
17+
settings.MIDDLEWARE.append(mname)
18+
except Exception as e:
19+
pass
20+
pass

simpleui/middlewares.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import os
2+
3+
try:
4+
5+
from django.utils.deprecation import MiddlewareMixin # Django 1.10.x
6+
except ImportError:
7+
MiddlewareMixin = object # Django 1.4.x - Django 1.9.x
8+
9+
10+
class SimpleMiddleware(MiddlewareMixin):
11+
12+
def process_response(self, request, response):
13+
response['X-Frame-Options'] = 'ALLOW-FROM'
14+
return response

simpleui/templates/admin/change_form.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@
1919

2020
</style>
2121
<div id="content-main" class="form-main">
22+
{% if '_popup' not in request.GET %}
2223
<div class="page-header">
2324
<el-page-header @back="goBack" content="{{title}}"/>
2425
</div>
26+
{% endif %}
2527
{% block object-tools %}
2628
{% if change %}{% if not is_popup %}
2729
<ul class="object-tools">

simpleui/templates/admin/submit_line.html

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
{% load i18n admin_urls simpletags%}
22
<div class="submit-row">
3-
<el-button type="button" icon="el-icon-arrow-left" @click="prev()"
4-
style="float: left;margin-right: 10px;margin-bottom: 10px;">
5-
<span v-text="getLanuage('Go back')"></span>
6-
</el-button>
3+
{% if '_popup' not in request.GET %}
4+
<el-button type="button" icon="el-icon-arrow-left" @click="prev()"
5+
style="float: left;margin-right: 10px;margin-bottom: 10px;">
6+
<span v-text="getLanuage('Go back')"></span>
7+
</el-button>
8+
{% endif %}
79
{% if show_delete_link %}
810
{% url opts|admin_urlname:'delete' original.pk|admin_urlquote as delete_url %}
911
<el-button icon="el-icon-delete" type="danger" @click="del('{% add_preserved_filters delete_url %}')"

0 commit comments

Comments
 (0)