def update_funeral():
    conn = None
    cursor = None
    try:
        print(request.form)
        status = request.form['status']
        date = request.form['date']

        cemetery_id = request.form['cemeteries']
        client_id = request.form['clients']
        id = request.form['id']

        conn = mysql.connect()
        cursor = conn.cursor()

        sql = "UPDATE funeral SET " \
              "FuneralDate=%s, funeralstatus=%s, " \
              "CemeteryId=%s, DeceasedId=%s" \
              "WHERE funeralid=%s"
        cursor.execute(sql, (date, status, cemetery_id, client_id, id));
        conn.commit()
        flash('Funeral has been successfully updated');
        return redirect(url_for('.funerals'));

    finally:
        if cursor is not None:
            cursor.close()

        if conn is not None:
            cursor.close()
Ejemplo n.º 2
0
def create_client():
    conn = None
    cursor = None
    try:
        fullname = request.form['fullname']
        passport_number = request.form['passport_number']
        birthday = request.form['birthday']
        deathday = request.form['deathday']
        size = request.form['size']
        weight = request.form['weight']
        cemetery_id = request.form['cemeteries']
        mortuary_id = request.form['mortuaries']

        conn = mysql.connect()
        cursor = conn.cursor()

        sql = "INSERT INTO deceased (" \
              "DeceasedFullName, DeceasedPassportNumber, " \
              "DeceasedBirthDate, DeceasedDeathDate, " \
              "DeceasedSizeMeasurements, DeceasedWeight, " \
              "CemeteryId, MortuaryId ) " \
              "VALUES (%s, %s,%s,%s,%s,%s,%s,%s)"
        cursor.execute(sql, (fullname, passport_number, birthday, deathday,
                             size, weight, cemetery_id, mortuary_id))
        conn.commit()
        flash('Client has been successfully updated')
        return redirect(url_for('.clients'))

    finally:
        if cursor is not None:
            cursor.close()

        if conn is not None:
            cursor.close()
Ejemplo n.º 3
0
def create_worker():
    conn = None
    cursor = None
    try:
        passport_number = request.form['inputPassportNumber']
        fullname = request.form['inputFullname']

        error_validation = ""
        if len(passport_number) > 10:
            error_validation += "Passport number must be a string with number of symbols up to 10"

        if len(fullname) > 100:
            error_validation += "Fullname of car must be a string with number of symbols up to 100"

        if error_validation:
            worker = Worker(id, fullname, passport_number)
            flash("Server validation failed: " + error_validation)
            return render_template("edit_worker.html", worker=worker)

        conn = mysql.connect()
        cursor = conn.cursor()

        sql = "INSERT INTO worker (WorkerPassportNumber, WorkerFullName) VALUES(%s, %s)"
        cursor.execute(sql, (passport_number, fullname))
        conn.commit()
        flash('Worker has been successfully created')
        return redirect(url_for('.workers'))

    finally:
        if cursor is not None:
            cursor.close()

        if conn is not None:
            cursor.close()
def create_funeral():
    conn = None
    cursor = None
    try:
        status = request.form['status']
        date = request.form['date']

        client_id = request.form['clients']
        cemetery_id = request.form['cemeteries']
        id = request.form['id']

        conn = mysql.connect()
        cursor = conn.cursor()

        sql = "INSERT INTO funeral (" \
              "funeralDate, funeralstatus, " \
              "CemeteryId, DeceasedId ) " \
              "VALUES (%s, %s, %s, %s)"
        cursor.execute(sql,
                       (date, status, cemetery_id, client_id));
        conn.commit()
        flash('Funeral has been successfully updated');
        return redirect(url_for('.funerals'));

    finally:
        if cursor is not None:
            cursor.close()

        if conn is not None:
            cursor.close()
Ejemplo n.º 5
0
def create_mortuary():
    conn = None
    cursor = None
    try:
        address = request.form['inputAddress']
        name = request.form['inputName']

        error_validation = ""
        if len(address) > 10:
            error_validation += "Passport number must be a string with number of symbols up to 10"

        if len(name) > 100:
            error_validation += "Name of car must be a string with number of symbols up to 100"

        if error_validation:
            mortuary = Mortuary(12, name, address)
            flash("Server validation failed: " + error_validation)
            return render_template("edit_mortuary.html", mortuary=mortuary)

        conn = mysql.connect()
        cursor = conn.cursor()

        sql = "INSERT INTO mortuary (MortuaryAdress, MortuaryName) VALUES(%s, %s)"
        cursor.execute(sql, (address, name))
        conn.commit()
        flash('Mortuary has been successfully created')
        return redirect(url_for('.mortuaries'))

    finally:
        if cursor is not None:
            cursor.close()

        if conn is not None:
            cursor.close()
def update_cemetery():
    conn = None
    cursor = None
    try:
        address = request.form['inputAddress']
        name = request.form['inputName']
        places = request.form['inputPlaces']
        phone = request.form['inputPhone']
        id = request.form['id']

        error_validation = ""
        if len(name) > 45 :
            error_validation += "Passport number must be a string with number of symbols up to 10"

        if len(address) > 100:
            error_validation += "Name of car must be a string with number of symbols up to 100"

        if len(phone) > 100:
            error_validation += "Phone must be a string with number of symbols up to 20"

        if error_validation:
            cemetery = Cemetery(id, name, address, places, phone)
            flash("Server validation failed: " + error_validation)
            return render_template("edit_cemetery.html", cemetery=cemetery)

        conn = mysql.connect()
        cursor = conn.cursor()
        sql = "SELECT * FROM cemetery WHERE cemeteryid=%s";
        cursor.execute(sql, (id,))
        row = cursor.fetchone()  # tuples
        if row is None:
            return render_template("500.html", e="Server cannot find cemetery is being updated")

        sql = "UPDATE cemetery SET CemeteryAdress=%s, CemeteryName=%s, CemeteryFreePlacesNumber=%s, CemeteryPhoneNumber=%s WHERE cemeteryid=%s"
        cursor.execute(sql, (address, name, places, phone, id));
        conn.commit()
        flash('Cemetery has been successfully updated');
        return redirect(url_for('.cemeteries'));

    finally:
        if cursor is not None:
            cursor.close()

        if conn is not None:
            cursor.close()
Ejemplo n.º 7
0
def update_car():
    conn = None
    cursor = None
    try:
        registration_number = request.form['inputRegistrationNumber']
        type = request.form['inputType']
        model = request.form['inputModel']
        id = request.form['id']

        error_validation = ""
        if len(registration_number) > 20 or len(registration_number) < 5:
            error_validation += "Registration number must be a string with number of symbols from 5 to 20"

        if len(type) > 45:
            error_validation += "Type of car must be a string with number of symbols up to 45"

        if len(model) > 45:
            error_validation += "Type of car must be a string with number of symbols up to 45"

        if error_validation:
            car = Car(id, registration_number, type, model)
            flash("Server validation failed: " + error_validation)
            return render_template("edit_car.html", car=car)

        conn = mysql.connect()
        cursor = conn.cursor()
        sql = "SELECT * FROM car WHERE carid=%s"
        cursor.execute(sql, (id, ))
        row = cursor.fetchone()  # tuples
        if row is None:
            return render_template("500.html",
                                   e="Server cannot find car is being updated")

        sql = "UPDATE car SET RegistrationNumber=%s, CarType=%s, CarModel=%s WHERE carid=%s"
        cursor.execute(sql, (registration_number, type, model, id))
        conn.commit()
        flash('Car has been successfully updated')
        return redirect(url_for('.cars'))

    finally:
        if cursor is not None:
            cursor.close()

        if conn is not None:
            cursor.close()
Ejemplo n.º 8
0
def delete_client(id):
    conn = None
    cursor = None
    try:
        conn = mysql.connect()
        cursor = conn.cursor()

        sql = "DELETE FROM deceased WHERE deceasedid=%s"
        cursor.execute(sql, (id))
        conn.commit()
        flash('Client has been successfully deleted')
        return redirect(url_for('.clients'))

    finally:
        if cursor is not None:
            cursor.close()

        if conn is not None:
            cursor.close()
def delete_cemetery(id):
    conn = None
    cursor = None
    try:
        conn = mysql.connect()
        cursor = conn.cursor()

        sql = "DELETE FROM cemetery WHERE cemeteryid=%s"
        cursor.execute(sql, (id))
        conn.commit()
        flash('Cemetery has been successfully deleted')
        return redirect(url_for('.cemeteries'))

    finally:
        if cursor is not None:
            cursor.close()

        if conn is not None:
            cursor.close()
Ejemplo n.º 10
0
def delete_funeral(id):
    conn = None
    cursor = None
    try:
        conn = mysql.connect()
        cursor = conn.cursor()

        sql = "DELETE FROM funeral WHERE funeralid=%s"
        cursor.execute(sql, (id))
        conn.commit()
        flash('Funeral has been successfully deleted')
        return redirect(url_for('.funerals'))

    finally:
        if cursor is not None:
            cursor.close()

        if conn is not None:
            cursor.close()
Ejemplo n.º 11
0
def delete_worker(id):
    conn = None
    cursor = None
    try:
        conn = mysql.connect()
        cursor = conn.cursor()

        sql = "DELETE FROM worker WHERE workerid=%s"
        cursor.execute(sql, (id))
        conn.commit()
        flash('Worker has been successfully deleted')
        return redirect(url_for('.workers'))

    finally:
        if cursor is not None:
            cursor.close()

        if conn is not None:
            cursor.close()
Ejemplo n.º 12
0
def update_mortuary():
    conn = None
    cursor = None
    try:
        address = request.form['inputAddress']
        name = request.form['inputName']
        id = request.form['id']

        error_validation = ""
        if len(address) > 10:
            error_validation += "Passport number must be a string with number of symbols up to 10"

        if len(name) > 100:
            error_validation += "Name of car must be a string with number of symbols up to 100"

        if error_validation:
            mortuary = Mortuary(id, name, address)
            flash("Server validation failed: " + error_validation)
            return render_template("edit_mortuary.html", mortuary=mortuary)

        conn = mysql.connect()
        cursor = conn.cursor()
        sql = "SELECT * FROM mortuary WHERE mortuaryid=%s"
        cursor.execute(sql, (id, ))
        row = cursor.fetchone()  # tuples
        if row is None:
            return render_template(
                "500.html", e="Server cannot find mortuary is being updated")

        sql = "UPDATE mortuary SET MortuaryAdress=%s, MortuaryName=%s WHERE mortuaryid=%s"
        cursor.execute(sql, (address, name, id))
        conn.commit()
        flash('Mortuary has been successfully updated')
        return redirect(url_for('.mortuaries'))

    finally:
        if cursor is not None:
            cursor.close()

        if conn is not None:
            cursor.close()
Ejemplo n.º 13
0
def update_worker():
    conn = None
    cursor = None
    try:
        passport_number = request.form['inputPassportNumber']
        fullname = request.form['inputFullname']
        id = request.form['id']

        error_validation = ""
        if len(passport_number) > 10 :
            error_validation += "Passport number must be a string with number of symbols up to 10"

        if len(fullname) > 100:
            error_validation += "Fullname of car must be a string with number of symbols up to 100"

        if error_validation:
            worker = Worker(id, fullname, passport_number)
            flash("Server validation failed: " + error_validation)
            return render_template("edit_worker.html", worker=worker)

        conn = mysql.connect()
        cursor = conn.cursor()
        sql = "SELECT * FROM worker WHERE workerid=%s";
        cursor.execute(sql, (id,))
        row = cursor.fetchone()  # tuples
        if row is None:
            return render_template("500.html", e="Server cannot find worker is being updated")

        sql = "UPDATE worker SET WorkerPassportNumber=%s, WorkerFullName=%s WHERE workerid=%s"
        cursor.execute(sql, (passport_number, fullname, id));
        conn.commit()
        flash('Worker has been successfully updated');
        return redirect(url_for('.workers'));

    finally:
        if cursor is not None:
            cursor.close()

        if conn is not None:
            cursor.close()
def create_cemetery():
    conn = None
    cursor = None
    try:
        address = request.form['inputAddress']
        name = request.form['inputName']
        places = request.form['inputPlaces']
        phone = request.form['inputPhone']

        error_validation = ""
        if len(address) > 10:
            error_validation += "Passport number must be a string with number of symbols up to 10"

        if len(name) > 100:
            error_validation += "Name of car must be a string with number of symbols up to 100"

        if len(phone) > 100:
            error_validation += "Phone must be a string with number of symbols up to 20"

        if error_validation:
            cemetery = Cemetery(12, name, address, places, phone)
            flash("Server validation failed: " + error_validation)
            return render_template("edit_cemetery.html", cemetery=cemetery)

        conn = mysql.connect()
        cursor = conn.cursor()

        sql = "INSERT INTO cemetery (CemeteryAdress, CemeteryName, CemeteryFreePlacesNumber, CemeteryPhoneNumber) VALUES(%s, %s, %s, %s)"
        cursor.execute(sql, (address, name, places, phone))
        conn.commit()
        flash('Cemetery has been successfully created')
        return redirect(url_for('.cemeteries'))

    finally:
        if cursor is not None:
            cursor.close()

        if conn is not None:
            cursor.close()
Ejemplo n.º 15
0
def create_car():
    conn = None
    cursor = None
    try:
        registration_number = request.form['inputRegistrationNumber']
        type = request.form['inputType']
        model = request.form['inputModel']

        error_validation = ""
        if len(registration_number) > 20 or len(registration_number) < 5:
            error_validation += "Registration number must be a string with number of symbols from 5 to 20"

        if len(type) > 45:
            error_validation += "Type of car must be a string with number of symbols up to 45"

        if len(model) > 45:
            error_validation += "Type of car must be a string with number of symbols up to 45"

        if error_validation:
            car = Car(id, registration_number, type, model)
            flash("Server validation failed: " + error_validation)
            return render_template("new_car.html", car=car)

        conn = mysql.connect()
        cursor = conn.cursor()

        sql = "INSERT INTO car (RegistrationNumber, CarType, CarModel) VALUES(%s, %s, %s)"
        cursor.execute(sql, (registration_number, type, model))
        conn.commit()
        flash('Car has been successfully created')
        return redirect(url_for('.cars'))

    finally:
        if cursor is not None:
            cursor.close()

        if conn is not None:
            cursor.close()
Ejemplo n.º 16
0
def update_client():
    conn = None
    cursor = None
    try:
        print(request.form)
        fullname = request.form['fullname']
        passport_number = request.form['passport_number']
        birthday = request.form['birthday']
        deathday = request.form['deathday']
        size = request.form['size']
        weight = request.form['weight']
        cemetery_id = request.form['cemeteries']
        mortuary_id = request.form['mortuaries']
        id = request.form['id']

        conn = mysql.connect()
        cursor = conn.cursor()

        sql = "UPDATE deceased SET " \
              "DeceasedFullName=%s, DeceasedPassportNumber=%s, " \
              "DeceasedBirthDate=%s, DeceasedDeathDate=%s, " \
              "DeceasedSizeMeasurements=%s, DeceasedWeight=%s, " \
              "CemeteryId=%s, MortuaryId=%s " \
              "WHERE deceasedid=%s"
        cursor.execute(sql, (fullname, passport_number, birthday, deathday,
                             size, weight, cemetery_id, mortuary_id, id))
        conn.commit()
        flash('Client has been successfully updated')
        return redirect(url_for('.clients'))

    finally:
        if cursor is not None:
            cursor.close()

        if conn is not None:
            cursor.close()