Exemplo n.º 1
0
 def update(data):
     """ 更新数据库用户信息 """
     with db.auto_commit():
         user = Apply.query.filter_by(
             student_id=data.pop('student_id')).first()
         user.update_time = user.generate_datetime
         process_data(user, data)
Exemplo n.º 2
0
 def delete(data):
     """ 删除数据 """
     with db.auto_commit():
         if isinstance(data, list):
             for t in data:
                 db.session.delete(t)
         else:
             db.session.delete(data)
Exemplo n.º 3
0
 def delete(self):
     """ 删除数据 """
     with db.auto_commit():
         if isinstance(self, list):
             for data in self:
                 db.session.delete(data)
         else:
             db.session.delete(self)
Exemplo n.º 4
0
 def insert(o, name):
     """ 填写部门信息 """
     with db.auto_commit():
         section = Section()
         # print(generate_id("{0}-{1}".format(o.name, name)))
         section.id = generate_id("{0}-{1}".format(o.name, name))
         section.name = name
         section.society_id = o.id
         db.session.add(section)
Exemplo n.º 5
0
 def register(id, account, password):
     """ 社团管理员注册 """
     with db.auto_commit():
         admin = Admin()
         admin.id = id
         admin.account = account
         admin.password = generate_password_hash(password)
         admin.auth = 1
         db.session.add(admin)
Exemplo n.º 6
0
 def update(self, data):
     with db.auto_commit():
         self.avatar_url = data['avatarUrl']
         self.city = data['city']
         self.country = data['country']
         self.province = data['province']
         self.nickName = data['nickName']
         self.gender = data['gender']
         self.language = data['language']
         self.update_time = self.generate_datetime
Exemplo n.º 7
0
 def insert(id, data):
     with db.auto_commit():
         user = User()
         user.openid = id
         user.avatar_url = data['avatarUrl']
         user.city = data['city']
         user.country = data['country']
         user.province = data['province']
         user.nickName = data['nickName']
         user.gender = data['gender']
         user.language = data['language']
         db.session.add(user)
Exemplo n.º 8
0
 def insert(name):
     with db.auto_commit():
         society = Society()
         society.id = generate_id(name)
         society.name = name
         db.session.add(society)
Exemplo n.º 9
0
 def insert(data):
     """ 向数据库写入用户信息 """
     with db.auto_commit():
         user = Apply()
         user = process_data(user, data)
         db.session.add(user)
Exemplo n.º 10
0
 def update(id, body):
     with db.auto_commit():
         rich_text = RichText.query.get_or_404(id)
         rich_text.body = body
         rich_text.update_time = rich_text.generate_datetime
Exemplo n.º 11
0
 def insert(id, body):
     with db.auto_commit():
         rich_text = RichText()
         rich_text.id = id
         rich_text.body = body
         db.session.add(rich_text)
Exemplo n.º 12
0
# -*- coding: utf8 -*-
from flask import Flask
from werkzeug.security import generate_password_hash
from models.admin import Admin
from init import create_app
from models import db, generate_id


app = create_app(Flask(__name__))


with app.app_context():
    with db.auto_commit():
        # 创建一个超级管理员
        user = Admin()
        user.account = 'super'
        user.password = generate_password_hash('123456')
        user.id = generate_id(u'超级管理员')
        user.auth = 2
        db.session.add(user)