示例#1
0
  def post(self):
    if (request.form.get("session_token") != None):
        session_token = request.form.get("session_token")
    else:
        session_token = ""

    conn, cur = ConnectDB()
    try:
        if (session_token == '$2y$12$/Am4ByLydvLE4ra2pvGDUOkDWYRi5XObtfqH/SWpRJAnJY8/dzDsS'):

            cur.execute("select pesan, aktif from info where aktif = 1 limit 1")
            row = cur.fetchone()

            if (row != None):
                v_pesan = row[0]
                v_aktif = row[1]

                result = { responseCode:"200", responseText:"success", "pesan":str(v_pesan), "aktif":str(v_aktif) }
            else:
                result = {responseCode:"401", responseText:"Ooppss..."}
        else:
            result = {responseCode:"401", responseText:"Ooppss..."}
    except Exception as e:
        result = {responseCode:"404", responseText:"Not found", detail:str(e)}
    finally:
        CloseDB(conn, cur)
    return result
示例#2
0
  def post(self):
    if (request.form.get("id_kajian") != None):
        id_kajian = request.form.get("id_kajian")
    else:
        id_kajian = ""

    if (request.form.get("session_token") != None):
        session_token = request.form.get("session_token")
    else:
        session_token = ""

    conn, cur = ConnectDB()
    try:
        if (session_token == '$2y$12$/Am4ByLydvLE4ra2pvGDUOkDWYRi5XObtfqH/SWpRJAnJY8/dzDsS'):
            now = datetime.now()
            FMT_1 = '%Y'
            year = str(now.strftime(FMT_1))
            FMT_2 = '%m'
            month = str(now.strftime(FMT_2))

            cur.execute("select id_kajian, tanggal, deskripsi, nama_pemateri, poster_path, tempat, judul, p.panggilan, resume " +
            "from kajian " +
            "inner join kajian_pemateri using (id_kajian) " +
            "inner join kajian_poster using (id_kajian) " +
            "inner join pemateri p using (id_pemateri) " +
            "where resume is not null and extract(year from tanggal) = %s and extract(month from tanggal) = %s", [year, month])

            data = []
            
            for row in cur:
                v_id = row[0]
                v_tanggal = row[1]
                v_deskripsi = row[2]
                v_poster_path = row[4]
                v_tempat = row[5]
                v_judul = row[6]
                v_pemateri = row[7] + ' ' + row[3]
                v_resume = row[8]

                data.append({
                    _id: str(v_id),
                    tanggal: str(v_tanggal),
                    deskripsi: v_deskripsi,
                    poster_path: v_poster_path,
                    tempat: v_tempat,
                    judul: v_judul,
                    pemateri: v_pemateri,
                    resume: v_resume
                })

            result = {responseCode:"200", responseText:"success", responseList:data}
        else:
            result = {responseCode:"401", responseText:"Ooppss..."}
    except Exception as e:
        result = {responseCode:"404", responseText:"Not found", detail:str(e)}
    finally:
        CloseDB(conn, cur)
    return result
示例#3
0
  def post(self):
    if (request.form.get("session_token") != None):
        session_token = request.form.get("session_token")
    else:
        session_token = ""

    conn, cur = ConnectDB()
    try:
        if (session_token == '$2y$12$/Am4ByLydvLE4ra2pvGDUOkDWYRi5XObtfqH/SWpRJAnJY8/dzDsS'):
            now = datetime.now()
            FMT_1 = '%Y'
            year = str(now.strftime(FMT_1))
            FMT_2 = '%m'
            month = str(now.strftime(FMT_2))
            # day_name = str(now.strftime("%A"))
            month_name = str(now.strftime("%B"))

            cur.execute("select distinct(date_part('day', tanggal)) as day_, date(tanggal) as full_date " + 
            "from kajian " +
            "where extract(year from tanggal) = %s and extract(month from tanggal) = %s", [year, month])
            data = []
            for row in cur:
                v_tanggal = row[0]
                v_full_date = row[1]

                day = str(v_full_date.strftime("%A"))

                day_name = ""
                if (day == 'Sunday'):
                    day_name = 'Minggu'
                elif (day == 'Monday'):
                    day_name = 'Senin'
                elif (day == 'Tuesday'):
                    day_name = 'Selasa'
                elif (day == 'Wednesday'):
                    day_name = 'Rabu'
                elif (day == 'Thursday'):
                    day_name = 'Kamis'
                elif (day == 'Friday'):
                    day_name = 'Jumat'
                elif (day == 'Saturday'):
                    day_name = 'Sabtu'

                data.append({
                    bulan: month_name,
                    tanggal: str(int(v_tanggal)),
                    hari: str(day_name),
                    full_date: str(v_full_date)
                })

            result = {responseCode:"200", responseText:"success", responseList:data}
        else:
            result = {responseCode:"401", responseText:"Ooppss..."}
    except Exception as e:
        result = {responseCode:"404", responseText:"Not found", detail:str(e)}
    finally:
        CloseDB(conn, cur)
    return result
示例#4
0
  def post(self):
    if (request.form.get("date") != None):
        date = request.form.get("date")
    else:
        date = ""

    if (request.form.get("session_token") != None):
        session_token = request.form.get("session_token")
    else:
        session_token = ""

    if (request.form.get("id_pemateri") != None):
        id_pemateri = request.form.get("id_pemateri")
    else:
        id_pemateri = ""

    conn, cur = ConnectDB()
    try:
        if (id_pemateri != ""):
            query = date + " and id_pemateri = " + id_pemateri
        else:
            query = date

        if (session_token == '$2y$12$/Am4ByLydvLE4ra2pvGDUOkDWYRi5XObtfqH/SWpRJAnJY8/dzDsS'):
            cur.execute("select id_kajian, TO_CHAR(tanggal :: TIMESTAMP, 'dd Mon yyyy - HH24:MI'), deskripsi, nama_pemateri, poster_path " +
            "from kajian " +
            "inner join kajian_pemateri using (id_kajian) " +
            "inner join kajian_poster using (id_kajian) " +
            "inner join pemateri using (id_pemateri) " +
            "where date(tanggal) = %s order by tanggal", [query])
            
            data = []

            for row in cur:
                v_id = row[0]
                v_tanggal = row[1]
                v_deskripsi = row[2]
                v_pemateri = row[3]
                v_poster_path = row[4]

                data.append({
                    _id:str(v_id),
                    tanggal:str(v_tanggal),
                    deskripsi:str(v_deskripsi),
                    pemateri:str(v_pemateri),
                    poster_path:str(v_poster_path)
                })

            result = {responseCode:"200", responseText:"success", responseList:data}
        else:
            result = {responseCode:"401", responseText:"Ooppss..."}
    except Exception as e:
        result = {responseCode:"404", responseText:"Not found", detail:str(e)}
    finally:
        CloseDB(conn, cur)
    return result
示例#5
0
    def post(self):

        if (request.form.get("session_token") != None):
            session_token = request.form.get("session_token")
        else:
            session_token = ""

        if (request.form.get("pesan") != None):
            pesan = request.form.get("pesan")
        else:
            pesan = ""

        if (request.form.get("aktif") != None):
            aktif = request.form.get("aktif")
        else:
            aktif = ""

        conn, cur = ConnectDB()
        try:
            if (session_token ==
                    '$2y$12$/Am4ByLydvLE4ra2pvGDUOkDWYRi5XObtfqH/SWpRJAnJY8/dzDsS'
                ):
                cur.execute(
                    "insert into info (pesan, aktif) values (%s, %s) RETURNING id_info",
                    [pesan, aktif])
                id_info = cur.fetchone()[0]

                if (id_info != None):
                    conn.commit()
                    result = {
                        responseCode: "200",
                        responseText: "success",
                        _id: str(id_info)
                    }
                else:
                    result = {
                        responseCode: "401",
                        responseText: "Please try again"
                    }
            else:
                result = {responseCode: "401", responseText: "Ooppss..."}

        except Exception as e:
            result = {
                responseCode: "404",
                responseText: "Not found",
                detail: str(e)
            }
            conn.rollback()
        finally:
            CloseDB(conn, cur)
        return result
示例#6
0
    def post(self):
        if (request.form.get("session_token") != None):
            session_token = request.form.get("session_token")
        else:
            session_token = ""

        if (request.form.get("query") != None):
            query = request.form.get("query")
        else:
            query = ""

        conn, cur = ConnectDB()
        try:
            name = '%' + query + '%'

            if (session_token ==
                    '$2y$12$/Am4ByLydvLE4ra2pvGDUOkDWYRi5XObtfqH/SWpRJAnJY8/dzDsS'
                ):
                cur.execute(
                    "select id_pemateri, nama_pemateri, panggilan from pemateri "
                    + "where lower(nama_pemateri) like lower(%s)", [name])

                data = []
                for row in cur:
                    v_id = row[0]
                    v_nama = row[1]
                    v_panggilan = row[2]

                    data.append({
                        _id: str(v_id),
                        nama: str(v_nama),
                        panggilan: str(v_panggilan)
                    })

                result = {
                    responseCode: "200",
                    responseText: "success",
                    responseList: data
                }
            else:
                result = {responseCode: "401", responseText: "Ooppss..."}
        except Exception as e:
            result = {
                responseCode: "404",
                responseText: "Not found",
                detail: str(e)
            }
        finally:
            CloseDB(conn, cur)
        return result
示例#7
0
    def post(self):
        if (request.form.get("session_token") != None):
            session_token = request.form.get("session_token")
        else:
            session_token = ""

        conn, cur = ConnectDB()
        try:
            if (session_token ==
                    '$2y$12$/Am4ByLydvLE4ra2pvGDUOkDWYRi5XObtfqH/SWpRJAnJY8/dzDsS'
                ):
                cur.execute(
                    "select id_kolaborasi, aktif, nama, poster_path, deskripsi, ig_akun from kolaborasi"
                )
                data = []
                for row in cur:
                    v_id = row[0]
                    v_aktif = row[1]
                    v_nama = row[2]
                    v_poster_path = row[3]
                    v_deskripsi = row[4]
                    v_ig_akun = row[5]

                    data.append({
                        _id: str(v_id),
                        aktif: str(v_aktif),
                        nama: str(v_nama),
                        poster_path: str(v_poster_path),
                        deskripsi: str(v_deskripsi),
                        ig_akun: str(v_ig_akun)
                    })

                result = {
                    responseCode: "200",
                    responseText: "success",
                    responseList: data
                }
            else:
                result = {responseCode: "401", responseText: "Ooppss..."}
        except Exception as e:
            result = {
                responseCode: "404",
                responseText: "Not found",
                detail: str(e)
            }
        finally:
            CloseDB(conn, cur)
        return result
示例#8
0
    def post(self):
        if (request.form.get("session_token") != None):
            session_token = request.form.get("session_token")
        else:
            session_token = ""

        conn, cur = ConnectDB()
        try:
            if (session_token ==
                    '$2y$12$/Am4ByLydvLE4ra2pvGDUOkDWYRi5XObtfqH/SWpRJAnJY8/dzDsS'
                ):
                FMT_1 = '%Y-%m-%d'
                date_now = str(datetime.now().strftime(FMT_1))

                cur.execute(
                    "select id_quote, poster_path, deskripsi, tanggal from quote where date(tanggal) = %s limit 1",
                    [date_now])
                val = cur.fetchone()

                if (val != None):
                    v_id = val[0]
                    v_poster_path = val[1]
                    v_deskripsi = val[2]
                    v_tanggal = val[3]

                    result = {
                        responseCode: "200",
                        responseText: "success",
                        poster_path: v_poster_path
                    }
                else:
                    result = {
                        responseCode: "200",
                        responseText: "success",
                        poster_path: "null"
                    }
            else:
                result = {responseCode: "401", responseText: "Ooppss..."}
        except Exception as e:
            result = {
                responseCode: "404",
                responseText: "Not found",
                detail: str(e)
            }
        finally:
            CloseDB(conn, cur)
        return result
示例#9
0
    def post(self):
        if (request.form.get("session_token") != None):
            session_token = request.form.get("session_token")
        else:
            session_token = ""

        conn, cur = ConnectDB()
        try:
            if (session_token ==
                    '$2y$12$/Am4ByLydvLE4ra2pvGDUOkDWYRi5XObtfqH/SWpRJAnJY8/dzDsS'
                ):
                FMT_1 = '%Y-%m-%d'
                date_now = str(datetime.now().strftime(FMT_1))

                cur.execute(
                    "select id_quote, poster_path, tanggal, deskripsi from quote"
                )
                data = []
                for row in cur:
                    v_id = row[0]
                    v_poster_path = row[1]
                    v_tanggal = row[2]
                    v_deskripsi = row[3]

                    data.append({
                        _id: str(v_id),
                        poster_path: str(v_poster_path),
                        tanggal: str(v_tanggal),
                        deskripsi: str(v_deskripsi)
                    })

                result = {
                    responseCode: "200",
                    responseText: "success",
                    responseList: data
                }
            else:
                result = {responseCode: "401", responseText: "Ooppss..."}
        except Exception as e:
            result = {
                responseCode: "404",
                responseText: "Not found",
                detail: str(e)
            }
        finally:
            CloseDB(conn, cur)
        return result
示例#10
0
    def post(self):

        if (request.form.get("session_token") != None):
            session_token = request.form.get("session_token")
        else:
            session_token = ""

        if (request.form.get("id_info") != None):
            id_info = request.form.get("id_info")
        else:
            id_info = ""

        if (request.form.get("aktif") != None):
            aktif = request.form.get("aktif")
        else:
            aktif = ""

        conn, cur = ConnectDB()
        try:
            if (session_token ==
                    '$2y$12$/Am4ByLydvLE4ra2pvGDUOkDWYRi5XObtfqH/SWpRJAnJY8/dzDsS'
                ):
                cur.execute("update info set aktif = %s where id_info = %s ",
                            [aktif, id_info])
                cur.execute("update info set aktif = %s where id_info != %s ",
                            [0, id_info])
                conn.commit()
                result = {
                    responseCode: "200",
                    responseText: "success",
                    _id: str(id_info)
                }
            else:
                result = {responseCode: "401", responseText: "Ooppss..."}

        except Exception as e:
            result = {
                responseCode: "404",
                responseText: "Not found",
                detail: str(e)
            }
            conn.rollback()
        finally:
            CloseDB(conn, cur)
        return result
示例#11
0
  def post(self):
    if (request.form.get("id_kajian") != None):
        id_kajian = request.form.get("id_kajian")
    else:
        id_kajian = ""

    if (request.form.get("session_token") != None):
        session_token = request.form.get("session_token")
    else:
        session_token = ""

    conn, cur = ConnectDB()
    try:
        if (session_token == '$2y$12$/Am4ByLydvLE4ra2pvGDUOkDWYRi5XObtfqH/SWpRJAnJY8/dzDsS'):
            cur.execute("select id_kajian, TO_CHAR(tanggal :: TIMESTAMP, 'dd Mon yyyy - HH24:MI'), deskripsi, nama_pemateri, poster_path, tempat, judul, p.panggilan, coalesce(alamat,'-'), geo " +
            "from kajian " +
            "inner join kajian_pemateri using (id_kajian) " +
            "inner join kajian_poster using (id_kajian) " +
            "inner join pemateri p using (id_pemateri) " +
            "where id_kajian = %s", [id_kajian])
            
            row = cur.fetchone()

            if (row != None):
                v_id = row[0]
                v_tanggal = row[1]
                v_deskripsi = row[2]
                v_poster_path = row[4]
                v_tempat = row[5]
                v_judul = row[6]
                v_pemateri = row[7] + ' ' + row[3]
                v_alamat = row[8]
                v_geo = row[9]

                result = {responseCode:"200", responseText:"success", _id:str(v_id), tanggal:str(v_tanggal), deskripsi:v_deskripsi, poster_path:v_poster_path, tempat:v_tempat, judul:v_judul, pemateri:str(v_pemateri), alamat:str(v_alamat), geo:str(v_geo)}
            else:
                result = {responseCode:"401", responseText:"Not found"}
        else:
            result = {responseCode:"401", responseText:"Ooppss..."}
    except Exception as e:
        result = {responseCode:"404", responseText:"Not found", detail:str(e)}
    finally:
        CloseDB(conn, cur)
    return result
示例#12
0
    def post(self):

        if (request.form.get("session_token") != None):
            session_token = request.form.get("session_token")
        else:
            session_token = ""

        if (request.form.get("judul") != None):
            judul = request.form.get("judul")
        else:
            judul = ""

        if (request.form.get("tempat") != None):
            tempat = request.form.get("tempat")
        else:
            tempat = ""

        if (request.form.get("waktu") != None):
            waktu = request.form.get("waktu")
        else:
            waktu = ""

        if (request.form.get("geo") != None):
            geo = request.form.get("geo")
        else:
            geo = ""

        if (request.form.get("deskripsi") != None):
            deskripsi = request.form.get("deskripsi")
        else:
            deskripsi = ""

        if (request.form.get("id_pemateri") != None):
            id_pemateri = request.form.get("id_pemateri")
        else:
            id_pemateri = ""

        if (request.form.get("poster_path") != None):
            poster_path = request.form.get("poster_path")
        else:
            poster_path = ""

        if (request.form.get("alamat") != None):
            alamat = request.form.get("alamat")
        else:
            alamat = ""

        conn, cur = ConnectDB()
        try:
            if (session_token ==
                    '$2y$12$/Am4ByLydvLE4ra2pvGDUOkDWYRi5XObtfqH/SWpRJAnJY8/dzDsS'
                ):
                cur.execute(
                    "insert into kajian (tanggal, judul, tempat, geo, deskripsi, alamat) values (%s, %s, %s, %s, %s, %s) RETURNING id_kajian",
                    [waktu, judul, tempat, geo, deskripsi, alamat])
                id_kajian = cur.fetchone()[0]

                if (id_kajian != None):
                    cur.execute(
                        "insert into kajian_pemateri (id_kajian, id_pemateri) values (%s, %s)",
                        [id_kajian, id_pemateri])
                    cur.execute(
                        "insert into kajian_poster (id_kajian, poster_path) values (%s, %s)",
                        [id_kajian, poster_path])

                    conn.commit()
                    result = {
                        responseCode: "200",
                        responseText: "success",
                        _id: str(id_kajian)
                    }
                else:
                    result = {
                        responseCode: "401",
                        responseText: "Please try again"
                    }
            else:
                result = {responseCode: "401", responseText: "Ooppss..."}

        except Exception as e:
            result = {
                responseCode: "404",
                responseText: "Not found",
                detail: str(e)
            }
            conn.rollback()
        finally:
            CloseDB(conn, cur)
        return result