def post(self):
     data = task.parse_args()
     conn = mysql.connect()
     cursor = conn.cursor()
     id_respone = randomString()
     id_user = data['id_user']
     result = cursor.execute(
         """INSERT INTO Respone ( 
             id_user,  
             alamat,
             nama_konsument,
             sumber_respone,
             tgl,
             catatan,
             status,
             minat_lokasi,
             jadwal
         ) 
         VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s)""",
         (id_user, data['alamat'], data['nama_konsument'],
          data['sumber_respone'], data['tgl'], data['catatan'],
          data['status'], data['minat_lokasi'], data['jadwal']))
     conn.commit()
     conn.close()
     ##level='boss'
     if (result):
         return {"success": "success"}
         ##return JoinTask_Create(id_task,id_user,level, data['description'], data['name_location'])
     else:
         return {"success": "false"}
def insert(uniqe_name, uniqe_name_data):
    conn = mysql.connect()
    cursor = conn.cursor()
    cursor.execute(
        """INSERT INTO Gambar (related_id,name_gambar) 
    VALUES (%s,%s)""", (uniqe_name_data, uniqe_name))
    conn.commit()
    conn.close()
Exemple #3
0
def insert_data(id_task,geolocation,keterangan,uniqe_name_data):
    conn = mysql.connect()
    cursor = conn.cursor()
    cursor.execute(
    """INSERT INTO Data (id_task,geolocation,keterangan,related_gambar) 
    VALUES (%s,%s,%s,%s)""",(id_task,geolocation,keterangan,uniqe_name_data))
    conn.commit()
    conn.close()
 def get(self, id_respone=None):
     conn = mysql.connect()
     cursor = conn.cursor()
     result = cursor.execute("DELETE FROM Respone WHERE id_respone = %s",
                             int(id_respone))
     conn.commit()
     conn.close()
     if (result):
         return {'success': 'true'}
     else:
         return {'success': 'false'}
Exemple #5
0
 def post(self, id_task=None):
     data = edittask.parse_args()            
     conn = mysql.connect()
     cursor = conn.cursor()
     result = cursor.execute("UPDATE Task SET description = %s, name_location = %s WHERE id_task = %s",
                     (data['description'],data['name_location'],int(id_task)))
     conn.commit()
     conn.close()
     if(result):
         return {'success':'true'}
     else:
         return {'success':'false'}
 def post(self, id_respone=None):
     data = edittask.parse_args()
     conn = mysql.connect()
     cursor = conn.cursor()
     result = cursor.execute(
         "UPDATE Respone SET alamat = %s, nama_konsument = %s, sumber_respone = %s, tgl = %s, catatan = %s, status = %s, minat_lokasi = %s, jadwal = %s WHERE id_respone = %s",
         (data['alamat'], data['nama_konsument'], data['sumber_respone'],
          data['tgl'], data['catatan'], data['status'],
          data['minat_lokasi'], data['jadwal'], int(id_respone)))
     conn.commit()
     conn.close()
     if (result):
         return {'success': 'true'}
     else:
         return {'success': 'false'}
Exemple #7
0
def JoinTask_Create(id_task, id_user, level, descriptions, name_location):
        conn = mysql.connect()
        cursor = conn.cursor()
        cursor.execute(
        """INSERT INTO Join_task (
                id_task,
                id_user,
                roles
            ) 
            VALUES (%s,%s,%s)""",(id_task,id_user,level))
        conn.commit()
        conn.close()
        return {'success':'true',
                'data':{
                'id_task':id_task,
                'description':descriptions,
                'name_location':name_location
                }
                }
Exemple #8
0
 def get(self, id_user=None):
     conn = mysql.connect()
     cursor = conn.cursor()
     result = cursor.execute("SELECT Task.id_task, Join_task.id_user, Task.description, Join_task.roles FROM Join_task JOIN User JOIN Task WHERE Join_task.id_task=Task.id_task AND Join_task.id_user=User.id_user AND Join_task.id_user= %s ",int(id_user))
     data = cursor.fetchall()
     results = []
     if(result):
         for item in data:
             dataResponse = {
             'id_task'     : item[0],
             'id_user'     : item[1],
             'descriptions'   : item[2],
             'roles'  : item[3],
         }
             results.append(dataResponse)
         return ({'success':'true',
                 'data':results})
     else:
         return json.dumps({'data':'null'})
Exemple #9
0
 def post(self):
     data = task.parse_args()
     conn = mysql.connect()
     cursor = conn.cursor()
     id_task=randomString()
     id_user=data['id_user']
     result = cursor.execute(
     """INSERT INTO Task (
             id_task,    
             description,
             name_location
         ) 
         VALUES (%s,%s,%s)""",(id_task,data['description'],data['name_location']))
     conn.commit()
     conn.close()
     level='boss'
     if(result): 
         return JoinTask_Create(id_task,id_user,level, data['description'], data['name_location'])
     else:
         return {"success":"false"}
Exemple #10
0
 def get(self, id_user=None):
     conn = mysql.connect()
     cursor = conn.cursor()
     result = cursor.execute("SELECT * from Respone WHERE id_user= %s ",
                             int(id_user))
     data = cursor.fetchall()
     results = []
     if (result):
         for item in data:
             dataResponse = {
                 'id_respone': item[0],
                 'alamat': item[2],
                 'nama_konsumen': item[3],
                 'sumber_respone': item[4],
                 'catatan': item[6],
                 ##'tgl': datetime.datetime(item[4])
             }
             results.append(dataResponse)
         return ({'success': 'true', 'data': results})
     else:
         return json.dumps({'data': 'null'})
Exemple #11
0
    def post(self):
        data = join.parse_args()
        conn = mysql.connect()
        cursor = conn.cursor()

        result=cursor.execute("SELECT * from Join_task where id_task = %s AND id_user = %s", (data['id_task'], data['id_user']))
        
        if (result):
                return {'success':'false',
                        'message': 'Task already join'}
        else:  

                cursor.execute(
                """INSERT INTO Join_task (
                id_task,
                id_user,
                roles
                ) 
                VALUES (%s,%s,%s)""",(data['id_task'],data['id_user'],data['roles']))
                conn.commit()
                conn.close()
                return {'success':'true'}