Example #1
0
 def deletedoreh(data):
     try:
         conadmin().deletefrom('doreh',
                               'id={id}'.format(id=data)).runquery()
         return True
     except Exception as error:
         return {"error": error}
Example #2
0
 def addnewdoreh(data):
     try:
         conadmin().insertinto('doreh', tuple([*data]),
                               tuple(data.values())).runquery()
         return True
     except Exception as error:
         return {"error": error}
Example #3
0
 def userlevelset(data):
     try:
         conadmin().insertinto('level', tuple([*data]),
                               tuple(data.values())).runquery()
         return True
     except Exception as error:
         return {"error": error}
Example #4
0
 def updatedoreh(data):
     try:
         conadmin().updateit(
             'doreh', data['newdata'],
             "id={id}".format(id=data['condition'])).runquery()
         return True
     except Exception as error:
         return {"error": error}
Example #5
0
    def addusertodoreh(data):
        users = [str(key) for key, value in data.items() if value == 'on']
        try:

            for item in users:
                conadmin().insertinto(
                    'classregister', "(userid,doreh)",
                    "({thisitem}, {doreh})".format(doreh=data['doreh'],
                                                   thisitem=item)).runquery()
            return True
        except Exception as error:
            return {"error": error}
Example #6
0
 def selectuserswaitinglevel():
     return conadmin().select(
         """
                                   user."melli-code",
                                   user.name,
                                   user.fname,
                                   user.grade,
                                   user.tel,
                                   user.address,
                                   level.mellicode
         """, 'user').joinit('LEFT', 'level',
                             ' level.mellicode = user."melli-code"').where(
                                 ' level.mellicode IS NULL').fetchall()
Example #7
0
 def show_admin():
     # data = request.headers.get('Authorization')
     # data = "TOKEN123"
     # واکشی اطلاعات مورد نیاز صفحه داشبورد
     content = {
         'manager':
         current_user.username,
         'user':
         mydb.selectuserswaitinglevel(),
         'doreh':
         conadmin().select('*', 'doreh').where("date > '{todey}'".format(
             todey=JalaliDate.today())).orderby('id', 'DESC').fetchall()
     }
     # چک میشود اگر توکن ارسالی توسط کاربری معتبر است یا خیر
     # if str(data) == "TOKEN123":
     return render_template('admin/dashboard.html', content=content)
Example #8
0
 def selectalldoreh():
     return conadmin().select('*', 'doreh').orderby('id', 'DESC').fetchall()
Example #9
0
 def selectalluser():
     return conadmin().select('*', 'user').fetchall()