django-app-metadata 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- django-app-metadata-0.1.0/LICENSE +201 -0
- django-app-metadata-0.1.0/MANIFEST.in +8 -0
- django-app-metadata-0.1.0/PKG-INFO +47 -0
- django-app-metadata-0.1.0/README.md +30 -0
- django-app-metadata-0.1.0/django_app_metadata/__init__.py +10 -0
- django-app-metadata-0.1.0/django_app_metadata/admin.py +102 -0
- django-app-metadata-0.1.0/django_app_metadata/apps.py +7 -0
- django-app-metadata-0.1.0/django_app_metadata/exceptions.py +2 -0
- django-app-metadata-0.1.0/django_app_metadata/migrations/0001_initial.py +165 -0
- django-app-metadata-0.1.0/django_app_metadata/migrations/0002_alter_config_key.py +20 -0
- django-app-metadata-0.1.0/django_app_metadata/migrations/__init__.py +0 -0
- django-app-metadata-0.1.0/django_app_metadata/models.py +311 -0
- django-app-metadata-0.1.0/django_app_metadata/settings.py +32 -0
- django-app-metadata-0.1.0/django_app_metadata/tests.py +0 -0
- django-app-metadata-0.1.0/django_app_metadata/version.py +1 -0
- django-app-metadata-0.1.0/django_app_metadata/views.py +3 -0
- django-app-metadata-0.1.0/django_app_metadata.egg-info/PKG-INFO +47 -0
- django-app-metadata-0.1.0/django_app_metadata.egg-info/SOURCES.txt +23 -0
- django-app-metadata-0.1.0/django_app_metadata.egg-info/dependency_links.txt +1 -0
- django-app-metadata-0.1.0/django_app_metadata.egg-info/not-zip-safe +1 -0
- django-app-metadata-0.1.0/django_app_metadata.egg-info/requires.txt +5 -0
- django-app-metadata-0.1.0/django_app_metadata.egg-info/top_level.txt +1 -0
- django-app-metadata-0.1.0/requirements.txt +5 -0
- django-app-metadata-0.1.0/setup.cfg +4 -0
- django-app-metadata-0.1.0/setup.py +47 -0
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: django-app-metadata
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Django数据字典管理应用。
|
|
5
|
+
Author: rRR0VrFP
|
|
6
|
+
Maintainer: rRR0VrFP
|
|
7
|
+
License: Apache License, Version 2.0
|
|
8
|
+
Keywords: django-app-metadata,django
|
|
9
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
12
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
License-File: LICENSE
|
|
17
|
+
|
|
18
|
+
# django-app-metadata
|
|
19
|
+
|
|
20
|
+
Django数据字典管理应用。
|
|
21
|
+
|
|
22
|
+
## 安装
|
|
23
|
+
|
|
24
|
+
```shell
|
|
25
|
+
pip install django-app-metadata
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## 使用
|
|
29
|
+
|
|
30
|
+
*app/views.py*
|
|
31
|
+
|
|
32
|
+
```python
|
|
33
|
+
from django_app_metadata.models import Config
|
|
34
|
+
|
|
35
|
+
def get_config(request):
|
|
36
|
+
key = reqeust.GET.get("key")
|
|
37
|
+
value = Config.get(key, default=None, default_published=True, frontend_flag=True)
|
|
38
|
+
return value
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## 版本记录
|
|
42
|
+
|
|
43
|
+
### v0.1.0
|
|
44
|
+
|
|
45
|
+
- 版本首发。
|
|
46
|
+
- 数据字典管理。
|
|
47
|
+
- 数据字典获取支持缓存。
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# django-app-metadata
|
|
2
|
+
|
|
3
|
+
Django数据字典管理应用。
|
|
4
|
+
|
|
5
|
+
## 安装
|
|
6
|
+
|
|
7
|
+
```shell
|
|
8
|
+
pip install django-app-metadata
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## 使用
|
|
12
|
+
|
|
13
|
+
*app/views.py*
|
|
14
|
+
|
|
15
|
+
```python
|
|
16
|
+
from django_app_metadata.models import Config
|
|
17
|
+
|
|
18
|
+
def get_config(request):
|
|
19
|
+
key = reqeust.GET.get("key")
|
|
20
|
+
value = Config.get(key, default=None, default_published=True, frontend_flag=True)
|
|
21
|
+
return value
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## 版本记录
|
|
25
|
+
|
|
26
|
+
### v0.1.0
|
|
27
|
+
|
|
28
|
+
- 版本首发。
|
|
29
|
+
- 数据字典管理。
|
|
30
|
+
- 数据字典获取支持缓存。
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
from django.contrib import admin
|
|
2
|
+
from import_export.admin import ImportExportModelAdmin
|
|
3
|
+
from .models import Category
|
|
4
|
+
from .models import Config
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class CategoryAdmin(admin.ModelAdmin):
|
|
8
|
+
list_display = [
|
|
9
|
+
"title",
|
|
10
|
+
"display_order",
|
|
11
|
+
]
|
|
12
|
+
search_fields = [
|
|
13
|
+
"title",
|
|
14
|
+
]
|
|
15
|
+
list_editable = [
|
|
16
|
+
"display_order",
|
|
17
|
+
]
|
|
18
|
+
readonly_fields = [
|
|
19
|
+
"add_time",
|
|
20
|
+
"mod_time",
|
|
21
|
+
]
|
|
22
|
+
fieldsets = [
|
|
23
|
+
(
|
|
24
|
+
None,
|
|
25
|
+
{
|
|
26
|
+
"fields": ["title", "display_order"],
|
|
27
|
+
},
|
|
28
|
+
)
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class ConfigAdmin(ImportExportModelAdmin, admin.ModelAdmin):
|
|
33
|
+
list_display = [
|
|
34
|
+
"key",
|
|
35
|
+
"description",
|
|
36
|
+
"category",
|
|
37
|
+
"published",
|
|
38
|
+
"enabled",
|
|
39
|
+
"deleted",
|
|
40
|
+
"is_valid",
|
|
41
|
+
"enabled",
|
|
42
|
+
]
|
|
43
|
+
list_filter = [
|
|
44
|
+
"is_valid",
|
|
45
|
+
"published",
|
|
46
|
+
"enabled",
|
|
47
|
+
"deleted",
|
|
48
|
+
"category",
|
|
49
|
+
]
|
|
50
|
+
search_fields = [
|
|
51
|
+
"key",
|
|
52
|
+
"description",
|
|
53
|
+
"data_raw",
|
|
54
|
+
]
|
|
55
|
+
fieldsets = [
|
|
56
|
+
(
|
|
57
|
+
"基础信息",
|
|
58
|
+
{
|
|
59
|
+
"fields": [
|
|
60
|
+
"category",
|
|
61
|
+
"key",
|
|
62
|
+
"description",
|
|
63
|
+
"type",
|
|
64
|
+
"is_valid",
|
|
65
|
+
"data_raw",
|
|
66
|
+
"enabled",
|
|
67
|
+
"published",
|
|
68
|
+
]
|
|
69
|
+
},
|
|
70
|
+
),
|
|
71
|
+
(
|
|
72
|
+
"其它信息",
|
|
73
|
+
{
|
|
74
|
+
"fields": [
|
|
75
|
+
"add_time",
|
|
76
|
+
"mod_time",
|
|
77
|
+
"enabled_time",
|
|
78
|
+
"disabled_time",
|
|
79
|
+
"published_time",
|
|
80
|
+
"unpublished_time",
|
|
81
|
+
"deleted_time",
|
|
82
|
+
]
|
|
83
|
+
},
|
|
84
|
+
),
|
|
85
|
+
]
|
|
86
|
+
readonly_fields = [
|
|
87
|
+
"add_time",
|
|
88
|
+
"mod_time",
|
|
89
|
+
"enabled_time",
|
|
90
|
+
"disabled_time",
|
|
91
|
+
"published_time",
|
|
92
|
+
"unpublished_time",
|
|
93
|
+
"deleted_time",
|
|
94
|
+
"is_valid",
|
|
95
|
+
]
|
|
96
|
+
autocomplete_fields = [
|
|
97
|
+
"category",
|
|
98
|
+
]
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
admin.site.register(Config, ConfigAdmin)
|
|
102
|
+
admin.site.register(Category, CategoryAdmin)
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
# Generated by Django 4.2.17 on 2024-12-23 07:36
|
|
2
|
+
|
|
3
|
+
from django.db import migrations, models
|
|
4
|
+
import django.db.models.deletion
|
|
5
|
+
import django_safe_fields.fields
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class Migration(migrations.Migration):
|
|
9
|
+
|
|
10
|
+
initial = True
|
|
11
|
+
|
|
12
|
+
dependencies = []
|
|
13
|
+
|
|
14
|
+
operations = [
|
|
15
|
+
migrations.CreateModel(
|
|
16
|
+
name="Category",
|
|
17
|
+
fields=[
|
|
18
|
+
(
|
|
19
|
+
"id",
|
|
20
|
+
models.BigAutoField(
|
|
21
|
+
auto_created=True,
|
|
22
|
+
primary_key=True,
|
|
23
|
+
serialize=False,
|
|
24
|
+
verbose_name="ID",
|
|
25
|
+
),
|
|
26
|
+
),
|
|
27
|
+
(
|
|
28
|
+
"add_time",
|
|
29
|
+
models.DateTimeField(
|
|
30
|
+
blank=True, null=True, verbose_name="添加时间"
|
|
31
|
+
),
|
|
32
|
+
),
|
|
33
|
+
(
|
|
34
|
+
"mod_time",
|
|
35
|
+
models.DateTimeField(
|
|
36
|
+
blank=True, null=True, verbose_name="修改时间"
|
|
37
|
+
),
|
|
38
|
+
),
|
|
39
|
+
(
|
|
40
|
+
"display_order",
|
|
41
|
+
models.IntegerField(blank=True, null=True, verbose_name="显示排序"),
|
|
42
|
+
),
|
|
43
|
+
("title", models.CharField(max_length=64, verbose_name="名称")),
|
|
44
|
+
],
|
|
45
|
+
options={
|
|
46
|
+
"verbose_name": "配置项分类",
|
|
47
|
+
"verbose_name_plural": "配置项分类",
|
|
48
|
+
},
|
|
49
|
+
),
|
|
50
|
+
migrations.CreateModel(
|
|
51
|
+
name="Config",
|
|
52
|
+
fields=[
|
|
53
|
+
(
|
|
54
|
+
"id",
|
|
55
|
+
models.BigAutoField(
|
|
56
|
+
auto_created=True,
|
|
57
|
+
primary_key=True,
|
|
58
|
+
serialize=False,
|
|
59
|
+
verbose_name="ID",
|
|
60
|
+
),
|
|
61
|
+
),
|
|
62
|
+
(
|
|
63
|
+
"add_time",
|
|
64
|
+
models.DateTimeField(
|
|
65
|
+
blank=True, null=True, verbose_name="添加时间"
|
|
66
|
+
),
|
|
67
|
+
),
|
|
68
|
+
(
|
|
69
|
+
"mod_time",
|
|
70
|
+
models.DateTimeField(
|
|
71
|
+
blank=True, null=True, verbose_name="修改时间"
|
|
72
|
+
),
|
|
73
|
+
),
|
|
74
|
+
("enabled", models.BooleanField(null=True, verbose_name="启用")),
|
|
75
|
+
(
|
|
76
|
+
"enabled_time",
|
|
77
|
+
models.DateTimeField(
|
|
78
|
+
blank=True, null=True, verbose_name="启用时间"
|
|
79
|
+
),
|
|
80
|
+
),
|
|
81
|
+
(
|
|
82
|
+
"disabled_time",
|
|
83
|
+
models.DateTimeField(
|
|
84
|
+
blank=True, null=True, verbose_name="禁用时间"
|
|
85
|
+
),
|
|
86
|
+
),
|
|
87
|
+
(
|
|
88
|
+
"deleted",
|
|
89
|
+
models.BooleanField(default=False, verbose_name="是否已删除"),
|
|
90
|
+
),
|
|
91
|
+
(
|
|
92
|
+
"deleted_time",
|
|
93
|
+
models.DateTimeField(
|
|
94
|
+
blank=True, null=True, verbose_name="删除时间"
|
|
95
|
+
),
|
|
96
|
+
),
|
|
97
|
+
("published", models.BooleanField(null=True, verbose_name="发布")),
|
|
98
|
+
(
|
|
99
|
+
"published_time",
|
|
100
|
+
models.DateTimeField(
|
|
101
|
+
blank=True, null=True, verbose_name="发布时间"
|
|
102
|
+
),
|
|
103
|
+
),
|
|
104
|
+
(
|
|
105
|
+
"unpublished_time",
|
|
106
|
+
models.DateTimeField(
|
|
107
|
+
blank=True, null=True, verbose_name="收回时间"
|
|
108
|
+
),
|
|
109
|
+
),
|
|
110
|
+
("key", models.CharField(max_length=64, verbose_name="配置项标识")),
|
|
111
|
+
(
|
|
112
|
+
"description",
|
|
113
|
+
models.CharField(
|
|
114
|
+
blank=True, max_length=64, null=True, verbose_name="配置项说明"
|
|
115
|
+
),
|
|
116
|
+
),
|
|
117
|
+
(
|
|
118
|
+
"type",
|
|
119
|
+
models.IntegerField(
|
|
120
|
+
choices=[
|
|
121
|
+
(10, "YAML格式"),
|
|
122
|
+
(20, "JSON格式"),
|
|
123
|
+
(30, "字符串"),
|
|
124
|
+
(40, "数值型"),
|
|
125
|
+
],
|
|
126
|
+
default=10,
|
|
127
|
+
verbose_name="内容数据类型",
|
|
128
|
+
),
|
|
129
|
+
),
|
|
130
|
+
(
|
|
131
|
+
"data_raw",
|
|
132
|
+
django_safe_fields.fields.SafeTextField(
|
|
133
|
+
blank=True,
|
|
134
|
+
help_text="如果设置的值与指定的类型不匹配,将视为NULL。",
|
|
135
|
+
null=True,
|
|
136
|
+
verbose_name="配置项数据",
|
|
137
|
+
),
|
|
138
|
+
),
|
|
139
|
+
(
|
|
140
|
+
"is_valid",
|
|
141
|
+
models.BooleanField(
|
|
142
|
+
editable=False,
|
|
143
|
+
help_text="这里显示的是上一次保存时的数据解析结果。保存时会更新更新该字段。",
|
|
144
|
+
null=True,
|
|
145
|
+
verbose_name="数据解析是否正确",
|
|
146
|
+
),
|
|
147
|
+
),
|
|
148
|
+
(
|
|
149
|
+
"category",
|
|
150
|
+
models.ForeignKey(
|
|
151
|
+
blank=True,
|
|
152
|
+
null=True,
|
|
153
|
+
on_delete=django.db.models.deletion.SET_NULL,
|
|
154
|
+
to="django_app_metadata.category",
|
|
155
|
+
verbose_name="分类",
|
|
156
|
+
),
|
|
157
|
+
),
|
|
158
|
+
],
|
|
159
|
+
options={
|
|
160
|
+
"verbose_name": "配置项",
|
|
161
|
+
"verbose_name_plural": "配置项",
|
|
162
|
+
"permissions": [("can_export_configs", "允许导出配置项")],
|
|
163
|
+
},
|
|
164
|
+
),
|
|
165
|
+
]
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Generated by Django 4.2.17 on 2024-12-23 07:41
|
|
2
|
+
|
|
3
|
+
from django.db import migrations, models
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class Migration(migrations.Migration):
|
|
7
|
+
|
|
8
|
+
dependencies = [
|
|
9
|
+
("django_app_metadata", "0001_initial"),
|
|
10
|
+
]
|
|
11
|
+
|
|
12
|
+
operations = [
|
|
13
|
+
migrations.AlterField(
|
|
14
|
+
model_name="config",
|
|
15
|
+
name="key",
|
|
16
|
+
field=models.CharField(
|
|
17
|
+
max_length=64, unique=True, verbose_name="配置项标识"
|
|
18
|
+
),
|
|
19
|
+
),
|
|
20
|
+
]
|
|
File without changes
|
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
import yaml
|
|
3
|
+
import json
|
|
4
|
+
from zenutils import typingutils
|
|
5
|
+
from zenutils import jsonutils
|
|
6
|
+
from null_object import Null
|
|
7
|
+
|
|
8
|
+
from django.db import models
|
|
9
|
+
from django.db.models.signals import post_save
|
|
10
|
+
from django.db.models.signals import pre_save
|
|
11
|
+
from django.db.models.signals import post_delete
|
|
12
|
+
from django.dispatch import receiver
|
|
13
|
+
from django.core.cache import caches
|
|
14
|
+
|
|
15
|
+
from django_safe_fields.fields import SafeTextField
|
|
16
|
+
from django_model_helper.models import WithAddModTimeFields
|
|
17
|
+
from django_model_helper.models import WithEnabledStatusFields
|
|
18
|
+
from django_model_helper.models import WithDeletedStatusFields
|
|
19
|
+
from django_model_helper.models import WithDisplayOrderFields
|
|
20
|
+
from django_model_helper.models import WithPublishStatusFields
|
|
21
|
+
|
|
22
|
+
from .exceptions import AccessToUnpublishedConfigIsForbidden
|
|
23
|
+
from .settings import DJANGO_APP_METADATA_USE_CACHE
|
|
24
|
+
from .settings import DJANGO_APP_METADATA_CACHE_TIMEOUT
|
|
25
|
+
from .settings import DJANGO_APP_METADATA_MISSING_CONFIG_CACHE_TIMEOUT
|
|
26
|
+
from .settings import DJANGO_APP_METADATA_CACHE_NAME
|
|
27
|
+
from .settings import DJANGO_APP_METADATA_CACHE_KEY_TEMPLATE
|
|
28
|
+
|
|
29
|
+
_logger = logging.getLogger(__name__)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class Category(
|
|
33
|
+
WithAddModTimeFields,
|
|
34
|
+
WithDisplayOrderFields,
|
|
35
|
+
):
|
|
36
|
+
title = models.CharField(
|
|
37
|
+
max_length=64,
|
|
38
|
+
verbose_name="名称",
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
class Meta:
|
|
42
|
+
verbose_name = "配置项分类"
|
|
43
|
+
verbose_name_plural = "配置项分类"
|
|
44
|
+
|
|
45
|
+
def __str__(self):
|
|
46
|
+
return self.title
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
class ConfigManager(models.Manager):
|
|
50
|
+
pass
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
class ConfigQuerySet(models.QuerySet):
|
|
54
|
+
def bulk_update(self, objs, fields, batch_size=None):
|
|
55
|
+
# 对配置项执行bulk_update时需要删除所有key值对应的缓存
|
|
56
|
+
cache = caches[DJANGO_APP_METADATA_CACHE_NAME]
|
|
57
|
+
for obj in objs:
|
|
58
|
+
cache_key = DJANGO_APP_METADATA_CACHE_KEY_TEMPLATE.format(key=obj.key)
|
|
59
|
+
cache.delete(cache_key)
|
|
60
|
+
_logger.debug(
|
|
61
|
+
"config_bulk_update_delete_cache_key: id=%s, key=%s, cache_key=%s",
|
|
62
|
+
obj.id,
|
|
63
|
+
obj.key,
|
|
64
|
+
cache_key,
|
|
65
|
+
)
|
|
66
|
+
# 如果key值也参与了批量更新
|
|
67
|
+
# 需要查找出所有旧的key值并删除对应的缓存
|
|
68
|
+
if "key" in fields:
|
|
69
|
+
obj_ids = [obj.id for obj in objs]
|
|
70
|
+
old_objs = Config.objects.filter(id__in=obj_ids)
|
|
71
|
+
for obj in old_objs:
|
|
72
|
+
cache_key = DJANGO_APP_METADATA_CACHE_KEY_TEMPLATE.format(key=obj.key)
|
|
73
|
+
cache.delete(cache_key)
|
|
74
|
+
_logger.debug(
|
|
75
|
+
"config_bulk_update_delete_cache_key: id=%s, key=%s, cache_key=%s",
|
|
76
|
+
obj.id,
|
|
77
|
+
obj.key,
|
|
78
|
+
cache_key,
|
|
79
|
+
)
|
|
80
|
+
return super().bulk_update(objs, fields, batch_size)
|
|
81
|
+
|
|
82
|
+
bulk_update.alters_data = True
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
class Config(
|
|
86
|
+
WithAddModTimeFields,
|
|
87
|
+
WithEnabledStatusFields,
|
|
88
|
+
WithDeletedStatusFields,
|
|
89
|
+
WithPublishStatusFields,
|
|
90
|
+
):
|
|
91
|
+
objects = ConfigManager.from_queryset(ConfigQuerySet)()
|
|
92
|
+
|
|
93
|
+
YAML = 10
|
|
94
|
+
JSON = 20
|
|
95
|
+
STRING = 30
|
|
96
|
+
NUMBER = 40
|
|
97
|
+
TYPE_CHOICES = [
|
|
98
|
+
(YAML, "YAML格式"),
|
|
99
|
+
(JSON, "JSON格式"),
|
|
100
|
+
(STRING, "字符串"),
|
|
101
|
+
(NUMBER, "数值型"),
|
|
102
|
+
]
|
|
103
|
+
category = models.ForeignKey(
|
|
104
|
+
Category,
|
|
105
|
+
on_delete=models.SET_NULL,
|
|
106
|
+
null=True,
|
|
107
|
+
blank=True,
|
|
108
|
+
verbose_name="分类",
|
|
109
|
+
)
|
|
110
|
+
key = models.CharField(
|
|
111
|
+
max_length=64,
|
|
112
|
+
unique=True,
|
|
113
|
+
verbose_name="配置项标识",
|
|
114
|
+
)
|
|
115
|
+
description = models.CharField(
|
|
116
|
+
max_length=64,
|
|
117
|
+
null=True,
|
|
118
|
+
blank=True,
|
|
119
|
+
verbose_name="配置项说明",
|
|
120
|
+
)
|
|
121
|
+
type = models.IntegerField(
|
|
122
|
+
choices=TYPE_CHOICES,
|
|
123
|
+
default=YAML,
|
|
124
|
+
verbose_name="内容数据类型",
|
|
125
|
+
)
|
|
126
|
+
data_raw = SafeTextField(
|
|
127
|
+
null=True,
|
|
128
|
+
blank=True,
|
|
129
|
+
verbose_name="配置项数据",
|
|
130
|
+
help_text="如果设置的值与指定的类型不匹配,将视为NULL。",
|
|
131
|
+
)
|
|
132
|
+
is_valid = models.BooleanField(
|
|
133
|
+
null=True,
|
|
134
|
+
verbose_name="数据解析是否正确",
|
|
135
|
+
editable=False,
|
|
136
|
+
help_text="这里显示的是上一次保存时的数据解析结果。保存时会更新更新该字段。",
|
|
137
|
+
)
|
|
138
|
+
|
|
139
|
+
class Meta:
|
|
140
|
+
verbose_name = "配置项"
|
|
141
|
+
verbose_name_plural = "配置项"
|
|
142
|
+
permissions = [
|
|
143
|
+
("can_export_configs", "允许导出配置项"),
|
|
144
|
+
]
|
|
145
|
+
|
|
146
|
+
def __str__(self):
|
|
147
|
+
return self.key
|
|
148
|
+
|
|
149
|
+
def save(self, *args, **kwargs):
|
|
150
|
+
self.is_valid = self.validate()
|
|
151
|
+
return super().save(*args, **kwargs)
|
|
152
|
+
|
|
153
|
+
def get_type_code(self):
|
|
154
|
+
return self.type
|
|
155
|
+
|
|
156
|
+
def parse_data_raw(self):
|
|
157
|
+
if not self.data_raw:
|
|
158
|
+
return None
|
|
159
|
+
if self.type == self.NUMBER:
|
|
160
|
+
return typingutils.cast_numeric(self.data_raw)
|
|
161
|
+
elif self.type == self.STRING:
|
|
162
|
+
return self.data_raw
|
|
163
|
+
elif self.type == self.JSON:
|
|
164
|
+
return json.loads(self.data_raw)
|
|
165
|
+
else:
|
|
166
|
+
return yaml.safe_load(self.data_raw)
|
|
167
|
+
|
|
168
|
+
def get_data(self):
|
|
169
|
+
try:
|
|
170
|
+
return self.parse_data_raw()
|
|
171
|
+
except Exception as error:
|
|
172
|
+
_logger.error(
|
|
173
|
+
"字典数据解析失败:key=%s, data_raw=%s, error=%s",
|
|
174
|
+
self.key,
|
|
175
|
+
self.data_raw,
|
|
176
|
+
error,
|
|
177
|
+
)
|
|
178
|
+
return None
|
|
179
|
+
|
|
180
|
+
def set_data(self, data):
|
|
181
|
+
if not data:
|
|
182
|
+
self.data_raw = None
|
|
183
|
+
if self.type == self.NUMBER:
|
|
184
|
+
self.data_raw = data
|
|
185
|
+
elif self.type == self.STRING:
|
|
186
|
+
self.data_raw = data
|
|
187
|
+
elif self.type == self.JSON:
|
|
188
|
+
self.data_raw = jsonutils.simple_json_dumps(data, ensure_ascii=False)
|
|
189
|
+
else:
|
|
190
|
+
self.data_raw = yaml.safe_dump(data)
|
|
191
|
+
self.type = self.YAML
|
|
192
|
+
|
|
193
|
+
data = property(get_data, set_data)
|
|
194
|
+
|
|
195
|
+
def info(self):
|
|
196
|
+
return {
|
|
197
|
+
"id": self.pk,
|
|
198
|
+
"key": self.key,
|
|
199
|
+
"data": self.data,
|
|
200
|
+
"published": self.published,
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
def validate(self):
|
|
204
|
+
try:
|
|
205
|
+
data = self.parse_data_raw()
|
|
206
|
+
return True
|
|
207
|
+
except:
|
|
208
|
+
return False
|
|
209
|
+
|
|
210
|
+
@classmethod
|
|
211
|
+
def get(
|
|
212
|
+
cls,
|
|
213
|
+
key, # 配置项键名
|
|
214
|
+
default=None, # 如果数据库未设置该配置项时,该配置项的默认值。
|
|
215
|
+
default_published=False, # 如果数据库未设置该配置项时,该配置项的默认可访问性。
|
|
216
|
+
use_cache=None, # 是否使用缓存
|
|
217
|
+
cache_timeout=None, # 缓存超时时长
|
|
218
|
+
missing_config_cache_timeout=None,
|
|
219
|
+
frontend_flag=False, # 是否前端查询
|
|
220
|
+
):
|
|
221
|
+
if use_cache is None:
|
|
222
|
+
use_cache = DJANGO_APP_METADATA_USE_CACHE
|
|
223
|
+
if cache_timeout is None:
|
|
224
|
+
cache_timeout = DJANGO_APP_METADATA_CACHE_TIMEOUT
|
|
225
|
+
if missing_config_cache_timeout is None:
|
|
226
|
+
missing_config_cache_timeout = (
|
|
227
|
+
DJANGO_APP_METADATA_MISSING_CONFIG_CACHE_TIMEOUT
|
|
228
|
+
)
|
|
229
|
+
|
|
230
|
+
info = Null
|
|
231
|
+
if (info is Null) and use_cache:
|
|
232
|
+
if DJANGO_APP_METADATA_CACHE_NAME in caches:
|
|
233
|
+
cache = caches[DJANGO_APP_METADATA_CACHE_NAME]
|
|
234
|
+
cache_key = DJANGO_APP_METADATA_CACHE_KEY_TEMPLATE.format(key=key)
|
|
235
|
+
info = cache.get(cache_key, Null)
|
|
236
|
+
|
|
237
|
+
if info is Null:
|
|
238
|
+
try:
|
|
239
|
+
obj = cls.objects.get(key=key, enabled=True, deleted=False)
|
|
240
|
+
info = obj.info()
|
|
241
|
+
except cls.DoesNotExist:
|
|
242
|
+
obj = None
|
|
243
|
+
info = {
|
|
244
|
+
"id": 0,
|
|
245
|
+
"key": key,
|
|
246
|
+
"data": default,
|
|
247
|
+
"published": default_published,
|
|
248
|
+
}
|
|
249
|
+
cache_timeout = missing_config_cache_timeout
|
|
250
|
+
if use_cache:
|
|
251
|
+
if DJANGO_APP_METADATA_CACHE_NAME in caches:
|
|
252
|
+
cache = caches[DJANGO_APP_METADATA_CACHE_NAME]
|
|
253
|
+
cache_key = DJANGO_APP_METADATA_CACHE_KEY_TEMPLATE.format(key=key)
|
|
254
|
+
cache.set(cache_key, value=info, timeout=cache_timeout)
|
|
255
|
+
|
|
256
|
+
if frontend_flag and (not info.get("published", False)):
|
|
257
|
+
raise AccessToUnpublishedConfigIsForbidden(403, "禁止访问未发布的配置项。")
|
|
258
|
+
return info.get("data", default)
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
@receiver(signal=pre_save, sender=Config)
|
|
262
|
+
def config_pre_save_to_delete_cache_key(*args, **kwargs):
|
|
263
|
+
# 保存前配置项前判断key值是否变化
|
|
264
|
+
# 如果有变化,则删除旧key对应的缓存
|
|
265
|
+
instance = kwargs.get("instance", None)
|
|
266
|
+
if instance and instance.id:
|
|
267
|
+
old_instance = Config.objects.get(id=instance.id)
|
|
268
|
+
if old_instance.key != instance.key:
|
|
269
|
+
cache = caches[DJANGO_APP_METADATA_CACHE_NAME]
|
|
270
|
+
cache_key = DJANGO_APP_METADATA_CACHE_KEY_TEMPLATE.format(
|
|
271
|
+
key=old_instance.key
|
|
272
|
+
)
|
|
273
|
+
cache.delete(cache_key)
|
|
274
|
+
_logger.debug(
|
|
275
|
+
"config_pre_save_to_delete_cache_key: id=%s, key=%s, cache_key=%s",
|
|
276
|
+
instance.id,
|
|
277
|
+
instance.key,
|
|
278
|
+
cache_key,
|
|
279
|
+
)
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
@receiver(signal=post_save, sender=Config)
|
|
283
|
+
def config_post_save_to_delete_cache_key(*args, **kwargs):
|
|
284
|
+
# 保存配置项后删除key对应的缓存
|
|
285
|
+
instance = kwargs.get("instance", None)
|
|
286
|
+
if instance:
|
|
287
|
+
cache = caches[DJANGO_APP_METADATA_CACHE_NAME]
|
|
288
|
+
cache_key = DJANGO_APP_METADATA_CACHE_KEY_TEMPLATE.format(key=instance.key)
|
|
289
|
+
cache.delete(cache_key)
|
|
290
|
+
_logger.debug(
|
|
291
|
+
"config_post_save_to_delete_cache_key: id=%s, key=%s, cache_key=%s",
|
|
292
|
+
instance.id,
|
|
293
|
+
instance.key,
|
|
294
|
+
cache_key,
|
|
295
|
+
)
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
@receiver(signal=post_delete, sender=Config)
|
|
299
|
+
def config_post_delete_to_delete_cache_key(*args, **kwargs):
|
|
300
|
+
# 删除配置项后删除key对应的缓存
|
|
301
|
+
instance = kwargs.get("instance", None)
|
|
302
|
+
if instance:
|
|
303
|
+
cache = caches[DJANGO_APP_METADATA_CACHE_NAME]
|
|
304
|
+
cache_key = DJANGO_APP_METADATA_CACHE_KEY_TEMPLATE.format(key=instance.key)
|
|
305
|
+
cache.delete(cache_key)
|
|
306
|
+
_logger.debug(
|
|
307
|
+
"config_post_delete_to_delete_cache_key: id=%s, key=%s, cache_key=%s",
|
|
308
|
+
instance.id,
|
|
309
|
+
instance.key,
|
|
310
|
+
cache_key,
|
|
311
|
+
)
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
from django.conf import settings
|
|
2
|
+
|
|
3
|
+
# 是否启用缓存。默认:启用。
|
|
4
|
+
DJANGO_APP_METADATA_USE_CACHE = getattr(
|
|
5
|
+
settings,
|
|
6
|
+
"DJANGO_APP_METADATA_USE_CACHE",
|
|
7
|
+
True,
|
|
8
|
+
)
|
|
9
|
+
# 缓存时长。默认:1小时。
|
|
10
|
+
DJANGO_APP_METADATA_CACHE_TIMEOUT = getattr(
|
|
11
|
+
settings,
|
|
12
|
+
"DJANGO_APP_METADATA_CACHE_TIMEOUT",
|
|
13
|
+
60 * 60,
|
|
14
|
+
)
|
|
15
|
+
# 缺失配置项缓存时长。默认:5分钟。
|
|
16
|
+
DJANGO_APP_METADATA_MISSING_CONFIG_CACHE_TIMEOUT = getattr(
|
|
17
|
+
settings,
|
|
18
|
+
"DJANGO_APP_METADATA_MISSING_CONFIG_CACHE_TIMEOUT",
|
|
19
|
+
5 * 60,
|
|
20
|
+
)
|
|
21
|
+
# 缓存数据库名称。默认为:default。
|
|
22
|
+
DJANGO_APP_METADATA_CACHE_NAME = getattr(
|
|
23
|
+
settings,
|
|
24
|
+
"DJANGO_APP_METADATA_CACHE_NAME",
|
|
25
|
+
"default",
|
|
26
|
+
)
|
|
27
|
+
# 缓存项模板。默认为:"django_app_metadata_cache:{key}"
|
|
28
|
+
DJANGO_APP_METADATA_CACHE_KEY_TEMPLATE = getattr(
|
|
29
|
+
settings,
|
|
30
|
+
"DJANGO_APP_METADATA_CACHE_KEY_TEMPLATE",
|
|
31
|
+
"django_app_metadata_cache:{key}",
|
|
32
|
+
)
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
VERSION = "0.1.0"
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: django-app-metadata
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Django数据字典管理应用。
|
|
5
|
+
Author: rRR0VrFP
|
|
6
|
+
Maintainer: rRR0VrFP
|
|
7
|
+
License: Apache License, Version 2.0
|
|
8
|
+
Keywords: django-app-metadata,django
|
|
9
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
12
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
License-File: LICENSE
|
|
17
|
+
|
|
18
|
+
# django-app-metadata
|
|
19
|
+
|
|
20
|
+
Django数据字典管理应用。
|
|
21
|
+
|
|
22
|
+
## 安装
|
|
23
|
+
|
|
24
|
+
```shell
|
|
25
|
+
pip install django-app-metadata
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## 使用
|
|
29
|
+
|
|
30
|
+
*app/views.py*
|
|
31
|
+
|
|
32
|
+
```python
|
|
33
|
+
from django_app_metadata.models import Config
|
|
34
|
+
|
|
35
|
+
def get_config(request):
|
|
36
|
+
key = reqeust.GET.get("key")
|
|
37
|
+
value = Config.get(key, default=None, default_published=True, frontend_flag=True)
|
|
38
|
+
return value
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## 版本记录
|
|
42
|
+
|
|
43
|
+
### v0.1.0
|
|
44
|
+
|
|
45
|
+
- 版本首发。
|
|
46
|
+
- 数据字典管理。
|
|
47
|
+
- 数据字典获取支持缓存。
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
MANIFEST.in
|
|
3
|
+
README.md
|
|
4
|
+
requirements.txt
|
|
5
|
+
setup.py
|
|
6
|
+
django_app_metadata/__init__.py
|
|
7
|
+
django_app_metadata/admin.py
|
|
8
|
+
django_app_metadata/apps.py
|
|
9
|
+
django_app_metadata/exceptions.py
|
|
10
|
+
django_app_metadata/models.py
|
|
11
|
+
django_app_metadata/settings.py
|
|
12
|
+
django_app_metadata/tests.py
|
|
13
|
+
django_app_metadata/version.py
|
|
14
|
+
django_app_metadata/views.py
|
|
15
|
+
django_app_metadata.egg-info/PKG-INFO
|
|
16
|
+
django_app_metadata.egg-info/SOURCES.txt
|
|
17
|
+
django_app_metadata.egg-info/dependency_links.txt
|
|
18
|
+
django_app_metadata.egg-info/not-zip-safe
|
|
19
|
+
django_app_metadata.egg-info/requires.txt
|
|
20
|
+
django_app_metadata.egg-info/top_level.txt
|
|
21
|
+
django_app_metadata/migrations/0001_initial.py
|
|
22
|
+
django_app_metadata/migrations/0002_alter_config_key.py
|
|
23
|
+
django_app_metadata/migrations/__init__.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
django_app_metadata
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
import os
|
|
3
|
+
from io import open
|
|
4
|
+
from setuptools import setup
|
|
5
|
+
from setuptools import find_packages
|
|
6
|
+
from django_app_metadata import version
|
|
7
|
+
|
|
8
|
+
here = os.path.abspath(os.path.dirname(__file__))
|
|
9
|
+
|
|
10
|
+
with open(os.path.join(here, "README.md"), "r", encoding="utf-8") as fobj:
|
|
11
|
+
long_description = fobj.read()
|
|
12
|
+
|
|
13
|
+
with open(os.path.join(here, "requirements.txt"), "r", encoding="utf-8") as fobj:
|
|
14
|
+
requires = fobj.readlines()
|
|
15
|
+
requires = [x.strip() for x in requires if x.strip()]
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
setup(
|
|
19
|
+
name="django-app-metadata",
|
|
20
|
+
version=version.VERSION,
|
|
21
|
+
description="Django数据字典管理应用。",
|
|
22
|
+
long_description=long_description,
|
|
23
|
+
long_description_content_type="text/markdown",
|
|
24
|
+
author="rRR0VrFP",
|
|
25
|
+
maintainer="rRR0VrFP",
|
|
26
|
+
license="Apache License, Version 2.0",
|
|
27
|
+
classifiers=[
|
|
28
|
+
"Development Status :: 5 - Production/Stable",
|
|
29
|
+
"Intended Audience :: Developers",
|
|
30
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
31
|
+
"License :: OSI Approved :: Apache Software License",
|
|
32
|
+
"Programming Language :: Python :: 3",
|
|
33
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
34
|
+
],
|
|
35
|
+
keywords=["django-app-metadata", "django"],
|
|
36
|
+
install_requires=requires,
|
|
37
|
+
packages=find_packages(
|
|
38
|
+
".",
|
|
39
|
+
exclude=[
|
|
40
|
+
"django_app_metadata_demo",
|
|
41
|
+
"django_app_metadata_example",
|
|
42
|
+
"django_app_metadata_example.migrations",
|
|
43
|
+
],
|
|
44
|
+
),
|
|
45
|
+
zip_safe=False,
|
|
46
|
+
include_package_data=True,
|
|
47
|
+
)
|