-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathutils.py
36 lines (28 loc) · 1014 Bytes
/
utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# Denpointment System - Utils
# github.com/Tzesh/Denpointment
from flask import redirect, url_for, flash, session
from functools import wraps
# Login decorator
def login_required(f):
@wraps(f)
def decorated_function(*args, **kwargs):
if "logged_in" in session:
return f(*args, **kwargs)
else:
flash("You are not authorized!", "danger")
return redirect(url_for("index"))
return decorated_function
# Check if the user is a dentist
def check_is_dentist(ssn, mysql):
cursor = mysql.connection.cursor()
query = "SELECT * FROM dentists WHERE dentist_ssn = %s"
result_set = cursor.execute(query, (ssn,))
cursor.close()
return True if result_set else False
# Check if the user is a patient
def check_is_patient(ssn, mysql):
cursor = mysql.connection.cursor()
query = "SELECT * FROM patients WHERE patient_ssn = %s"
result_set = cursor.execute(query, (ssn,))
cursor.close()
return True if result_set else False