Exemplo n.º 1
0
    def create(self, data):

        with db.auto_commit():
            self.set_attrs(data)
            self.active = 1
            self.created_at = time_now()
            self.updated_at = time_now()
            db.session.add(self)
Exemplo n.º 2
0
 def create(self, data):
     with db.auto_commit():
         self.column = Column.query.filter_by(id=data['column_id']).api_first_or_404()
         self.set_attrs(data)
         self.active = 1
         self.created_at = time_now()
         self.updated_at = time_now()
         db.session.add(self)
Exemplo n.º 3
0
 def create(self, data):
     attributes = request.form.getlist('attribute[]')
     with db.auto_commit():
         self.set_attrs(data)
         self.active = 1
         self.admin = current_user
         self.attribute = ",".join(attributes)
         self.created_at = time_now()
         self.updated_at = time_now()
         db.session.add(self)
Exemplo n.º 4
0
 def create(self, data):
     permission_ids = request.form.getlist('permissions[]')
     # 添加时把权限添加进去
     with db.auto_commit():
         self.set_attrs(data)
         self.active = 1
         self.created_at = time_now()
         self.updated_at = time_now()
         if permission_ids:
             self.permissions = self._get_permissions(permission_ids)
         db.session.add(self)
Exemplo n.º 5
0
 def create(self, data):
     with db.auto_commit():
         self.set_attrs(data)
         self.active = 1
         self.open_comment = 1
         self.ip = get_client_ip()
         self.user_id = current_user.id
         self.username = current_user.name
         self.user_type = 'admin'
         self.published_at = time_now()
         self.created_at = time_now()
         self.updated_at = time_now()
         db.session.add(self)
Exemplo n.º 6
0
 def update(self, data, edit_one_field=None):
     with db.auto_commit():
         if not edit_one_field:
             if not data['password']:
                 data.pop('password')
             self.set_attrs(data)
         else:
             self.set_attr(data)
         self.updated_at = time_now()
Exemplo n.º 7
0
 def update(self, data, edit_one_field=None):
     """
     edit_one_field 是否表内单个编辑 标识
     :param data:
     :param flag:
     :return:
     """
     with db.auto_commit():
         if not edit_one_field:
             self.set_attrs(data)
         else:
             self.set_attr(data)
         self.updated_at = time_now()
Exemplo n.º 8
0
 def update(self, data, edit_one_field=None):
     """
     edit_one_field 是否表内单个编辑 标识
     :param data:
     :param flag:
     :return:
     """
     with db.auto_commit():
         if not edit_one_field:
             self.column = Column.query.filter_by(id=data['column_id']).api_first_or_404()
             self.set_attrs(data)
         else:
             self.set_attr(data)
         self.updated_at = time_now()
Exemplo n.º 9
0
 def update(self, data, edit_one_field=None):
     """
     edit_one_field 是否表内单个编辑 标识
     :param data:
     :param flag:
     :return:
     """
     attributes = request.form.getlist('attribute[]')
     with db.auto_commit():
         if not edit_one_field:
             self.set_attrs(data)
             self.attribute = ",".join(attributes)
         else:
             self.set_attr(data)
         self.updated_at = time_now()