branch admin 增加user_id 和微信建立连接

FFIB 4 years ago
parent
commit
b11bb54ffd
2 changed files with 24 additions and 0 deletions
  1. 23 0
      api/branch_campus_admin_views.py
  2. 1 0
      registration/models.py

+ 23 - 0
api/branch_campus_admin_views.py

@@ -78,6 +78,29 @@ def delete_branch_campus_admin(request):
78 78
 
79 79
     return response()
80 80
 
81
+def apply_branch_campus_admin(request):
82
+    user_id = request.POST.get('user_id', '')
83
+    campus_id = request.POST.get('campus_id', '')
84
+    campus_name = request.POST.get('campus_name', '')
85
+    name = request.POST.get('name', '')
86
+    phone = request.POST.get('phone', '')
87
+
88
+    password = phone[-6:]
89
+    encryption = make_password(password, settings.MAKE_PASSWORD_SALT, settings.MAKE_PASSWORD_HASHER)
90
+
91
+    admin = BranchCampusAdministratorInfo.objects.create(
92
+        user_id=user_id,
93
+        campus_id=campus_id,
94
+        campus_name=campus_name,
95
+        name=name,
96
+        phone=phone,
97
+        password=password,
98
+        encryption=encryption,
99
+    )
100
+
101
+    return response(data={
102
+        'admin': admin.admin_id,
103
+    })
81 104
 
82 105
 def login_branch_campus_admin(request):
83 106
     phone = request.POST.get('phone', '')

+ 1 - 0
registration/models.py

@@ -41,6 +41,7 @@ class BranchCampusAdministratorInfo(BaseModelMixin):
41 41
         (DELETED, '已删除'),
42 42
     )
43 43
 
44
+    user_id = models.CharField(_('user_id'), max_length=32, blank=True, null=True, help_text='用户ID', db_index=True, unique=True)
44 45
     admin_id = ShortUUIDField(_('admin_id'), max_length=32, blank=True, null=True, help_text='管理员唯一标识', db_index=True, unique=True)
45 46
 
46 47
     campus_id = models.CharField(_('campus_id'), max_length=32, blank=True, null=True, help_text='分院唯一标识', db_index=True)