-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b063126
commit bbfcb2f
Showing
20 changed files
with
89 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/.vscode |
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from django.contrib import admin | ||
from Specialist.models import SpecialistCategory | ||
|
||
# Register your models here. | ||
admin.site.register(SpecialistCategory) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class SpecialistConfig(AppConfig): | ||
name = 'Specialist' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Generated by Django 3.0 on 2019-12-16 03:10 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='SpecialistCategory', | ||
fields=[ | ||
('key', models.CharField(max_length=8, primary_key=True, serialize=False)), | ||
('name', models.CharField(max_length=20)), | ||
], | ||
), | ||
] |
Empty file.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
"""专家信息模型""" | ||
from django.db import models | ||
|
||
# Create your models here. | ||
class SpecialistCategory(models.Model): | ||
"""专家分类 | ||
- 分类key key char 8 | ||
- 分类名 name char 20 | ||
""" | ||
key = models.CharField(max_length=8, primary_key=True) | ||
name = models.CharField(max_length=20) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.test import TestCase | ||
|
||
# Create your tests here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.shortcuts import render | ||
|
||
# Create your views here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
"""自动化生成数据库中的专家分类表""" | ||
#!/usr/bin/env python3 | ||
import re | ||
import docx | ||
|
||
import sys | ||
import os | ||
import django | ||
sys.path.append('../') | ||
os.environ['DJANGO_SETTINGS_MODULE'] = 'specialist_info.settings' | ||
django.setup() | ||
|
||
from Specialist.models import SpecialistCategory | ||
|
||
def save(text): | ||
"""将传入的字符串格式化后存入数据库 | ||
分类ID: 如 A01 A0101 | ||
分类名称: | ||
""" | ||
ret = re.match(r'^\w{1}\d{2,6}', text) | ||
if ret: | ||
key = ret.group() | ||
val = re.split(r'^\w{1}\d{2,6} *', text)[1] | ||
val = val.replace('\n', '').replace('\r', '') | ||
obj = SpecialistCategory(key=key, name=val) | ||
obj.save() | ||
|
||
def main(): | ||
"""main""" | ||
doc = docx.Document('type_info.docx') | ||
for table in doc.tables: | ||
for cell in table.columns[0].cells: | ||
save(cell.text) | ||
for cell in table.columns[1].cells: | ||
save(cell.text) | ||
|
||
if __name__ == "__main__": | ||
main() |
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,7 @@ | |
'django.contrib.messages', | ||
'django.contrib.staticfiles', | ||
'UserInfo', | ||
'Specialist', | ||
] | ||
|
||
MIDDLEWARE = [ | ||
|