Skip to content

Commit

Permalink
Merge pull request #197 from newpanjing/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
newpanjing authored Dec 9, 2019
2 parents 96da90d + d90b4b8 commit eab6e41
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 5 deletions.
5 changes: 4 additions & 1 deletion simpleui/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
default_app_config = 'simpleui.apps.SimpleApp'


def get_version():
return '3.6'
return '3.7'
20 changes: 20 additions & 0 deletions simpleui/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from django.apps import AppConfig


class SimpleApp(AppConfig):
name = 'simpleui'

def ready(self):
# 如果是django3+ 就使用中间件,删除header中的X-Frame-Options

try:
import django
version = django.get_version()
if int(version.split('.')[0]) >= 3:
from django.conf import settings
mname = 'simpleui.middlewares.SimpleMiddleware'
if mname not in settings.MIDDLEWARE:
settings.MIDDLEWARE.append(mname)
except Exception as e:
pass
pass
14 changes: 14 additions & 0 deletions simpleui/middlewares.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import os

try:

from django.utils.deprecation import MiddlewareMixin # Django 1.10.x
except ImportError:
MiddlewareMixin = object # Django 1.4.x - Django 1.9.x


class SimpleMiddleware(MiddlewareMixin):

def process_response(self, request, response):
response['X-Frame-Options'] = 'ALLOW-FROM'
return response
2 changes: 2 additions & 0 deletions simpleui/templates/admin/change_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@

</style>
<div id="content-main" class="form-main">
{% if '_popup' not in request.GET %}
<div class="page-header">
<el-page-header @back="goBack" content="{{title}}"/>
</div>
{% endif %}
{% block object-tools %}
{% if change %}{% if not is_popup %}
<ul class="object-tools">
Expand Down
10 changes: 6 additions & 4 deletions simpleui/templates/admin/submit_line.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
{% load i18n admin_urls simpletags%}
<div class="submit-row">
<el-button type="button" icon="el-icon-arrow-left" @click="prev()"
style="float: left;margin-right: 10px;margin-bottom: 10px;">
<span v-text="getLanuage('Go back')"></span>
</el-button>
{% if '_popup' not in request.GET %}
<el-button type="button" icon="el-icon-arrow-left" @click="prev()"
style="float: left;margin-right: 10px;margin-bottom: 10px;">
<span v-text="getLanuage('Go back')"></span>
</el-button>
{% endif %}
{% if show_delete_link %}
{% url opts|admin_urlname:'delete' original.pk|admin_urlquote as delete_url %}
<el-button icon="el-icon-delete" type="danger" @click="del('{% add_preserved_filters delete_url %}')"
Expand Down

0 comments on commit eab6e41

Please sign in to comment.