Example #1
0
    def _update(self, obj):
        if hasattr(obj, 'update_at'):
            obj.update_at = datetime.utcnow()
        if hasattr(obj, 'update_by'):
            obj.update_by = self._current_username()

        db.commit()
Example #2
0
    def _insert(self, obj):
        if hasattr(obj, 'is_active'):
            obj.is_active = Status.Y
        if hasattr(obj, 'create_by'):
            obj.create_by = self._current_username()

        db.add(obj)
        db.commit()
Example #3
0
    def _delete(self, obj):
        if hasattr(obj, 'delete_by'):
            obj.delete_by = self._current_username()
        if hasattr(obj, 'delete_at'):
            obj.delete_at = datetime.utcnow()
        if hasattr(obj, 'is_active'):
            obj.is_active = Status.N
        else:
            db.remove(obj)

        db.commit()