示例#1
0
文件: views.py 项目: yigelaoliu/fm-ai
def machine_orders(m_id):
    m = Machine.query.get_or_404(m_id)
    if m.admin_id == current_user.id or current_user.is_super():
        o_list = m.orders
        return render_template('orders.html', m=m, o_list=o_list)
    else:
        abort(403)
示例#2
0
 def only_id(self, id):
     super(BusinessApi, self).get()
     business_list = []
     if current_user.is_super():
         query = BusinessModel.query.all()
     else:
         query = UserModel.query.filter_by(
             id=current_user.id).first().business
     for data in query:
         business_list.append({'id': data.id, 'name': data.name})
     return self.render_json(data=business_list)
示例#3
0
文件: task.py 项目: ccg6458/ops
 def get_tasks(self):
     task_id_list = []
     if current_user.is_super():
         tasks = TaskModel.query.all()
         for task in tasks:
             task_id_list.append(task.id)
         return task_id_list
     query = BusinessModel.query.filter_by(user_id=current_user.id).all()
     # query = UserModel
     for business in query:
         for task in business.task:
             task_id_list.append(task.id)
     return task_id_list
示例#4
0
 def get(self):
     super(SideBarApi, self).get()
     if current_user.is_super():
         super_sidebar_list = []
         super_sidebars = SideBarModel.query.all()
         for side in super_sidebars:
             super_sidebar_list.append(side.to_json())
         return self.render_json(data=super_sidebar_list)
     common_sidebar_list = []
     common_sidebars = SideBarModel.query.filter_by(is_super=0).all()
     for side in common_sidebars:
         common_sidebar_list.append(side.to_json())
     return self.render_json(data=common_sidebar_list)
示例#5
0
 def get(self, tag=None, id=None):
     if tag:
         func = getattr(self, tag, 'only_id')
         return func(id)
     super(BusinessApi, self).get()
     if current_user.is_super():
         query = BusinessModel.query.all()
     else:
         query = UserModel.query.filter_by(
             id=current_user.id).first().business
     business_list = []
     for data in query:
         business_list.append(data.to_json())
     return self.render_json(data=business_list)
示例#6
0
文件: task.py 项目: ccg6458/ops
    def get(self, id=None):
        if id:
            task = TaskModel.query.filter_by(id=id).first().to_json()
            return self.render_json(data=task)

        super(TaskApi, self).get()
        task_list = []
        if current_user.is_super():
            tasks = TaskModel.query.all()
            for task in tasks:
                task_list.append(task.to_json())
            return TaskApi.render_json(data=task_list)

        query = UserModel.query.filter_by(id=current_user.id).first().business
        for business in query:
            for task in business.task:
                task_list.append(task.to_json())
        return self.render_json(data=task_list)
示例#7
0
文件: views.py 项目: yigelaoliu/fm-ai
def machine_qrcode(m_id):
    m = Machine.query.get_or_404(m_id)
    if m.admin_id == current_user.id or current_user.is_super():
        if request.method == 'POST':
            if 'file' not in request.files:
                flash('未选择图片。')
                return redirect(request.url)
            file = request.files['file']
            if file:
                file_path = os.path.join(current_app.config['MACHINE_QRCODE_PATH'] + 'mid_' + str(m.id) + '.png')
                try:
                    os.remove(file_path)
                except OSError:
                    pass
                file.save(file_path)
                flash('二维码上传成功。如果图片没有更换,是浏览器缓存问题。')
        qrcode_s = gen_qrcode_string(m)
        return render_template('machine_qrcode.html', m=m, qrcode_s=qrcode_s)
    else:
        abort(403)
示例#8
0
文件: workorder.py 项目: ccg6458/ops
    def get(self, tag=None):

        if tag:
            func = getattr(self, tag, 'database')
            return func()
        super(WorkOrderApi, self).get()

        work_list = []
        data = {}
        if current_user.is_super():
            works = WorkOrderModel.query.all()
            for work in works:
                work_list.append(work.to_json())
            data['super'] = 1
            data['work'] = work_list
            return self.render_json(data=data)

        query = UserModel.query.filter_by(id=current_user.id).first().work
        for work in query:
            work_list.append(work.to_json())
        data['super'] = 0
        data['work'] = work_list
        return self.render_json(data=data)
示例#9
0
 def decorated_function(*args, **kwargs):
     if (not current_user.is_anonymous) and current_user.is_super():
         return f(*args, **kwargs)
     else:
         abort(403)
示例#10
0
文件: __init__.py 项目: ccg6458/ops
 def is_super_role():
     if current_user.is_super():
         return True
     return False
示例#11
0
文件: views.py 项目: yigelaoliu/fm-ai
def machine(m_id):
    m = Machine.query.get_or_404(m_id)
    if m.admin_id == current_user.id or current_user.is_super():
        return render_template('machine.html', m=m)
    else:
        abort(403)