Subnav bar added and some other small changes. Need to figure out CSV upload.
This commit is contained in:
@ -4,4 +4,8 @@ from config import Config
|
|||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
app.config.from_object(Config)
|
app.config.from_object(Config)
|
||||||
|
|
||||||
|
# Upload folder
|
||||||
|
UPLOAD_FOLDER = 'static/files'
|
||||||
|
app.config['UPLOAD_FOLDER'] =UPLOAD_FOLDER
|
||||||
|
|
||||||
from app import routes
|
from app import routes
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@ -8,24 +8,14 @@ from itables import show
|
|||||||
import re
|
import re
|
||||||
|
|
||||||
|
|
||||||
def handle_responses(response):
|
def key_response(response):
|
||||||
print(response.status_code)
|
if "402" in str(response):
|
||||||
print(response.text)
|
error = response.text
|
||||||
try:
|
return render_template("index.html", title="Error Home", error=error)
|
||||||
response.raise_for_status()
|
elif "401" in str(response):
|
||||||
print(response.raise_for_status())
|
|
||||||
except requests.exceptions as err:
|
|
||||||
return render_template("index.html", title="Error Home", error=err)
|
|
||||||
print(err)
|
|
||||||
finally:
|
|
||||||
return correct_key(response)
|
|
||||||
|
|
||||||
|
|
||||||
def temp():
|
|
||||||
if "401" in str(response):
|
|
||||||
error = [
|
error = [
|
||||||
"Unauthorized access error. This can mean a lot of things.",
|
"Unauthorized access error. This can mean a lot of things, such as the key being changed.",
|
||||||
"Has the key changed, recently?",
|
"Remember, they are paired to each educator!",
|
||||||
]
|
]
|
||||||
return render_template("index.html", title="Error Home", error=error)
|
return render_template("index.html", title="Error Home", error=error)
|
||||||
else:
|
else:
|
||||||
@ -51,7 +41,7 @@ def ask_key():
|
|||||||
url = "https://api.northpass.com/v2/properties/school"
|
url = "https://api.northpass.com/v2/properties/school"
|
||||||
headers = {"accept": "application/json", "X-Api-Key": session["key"]}
|
headers = {"accept": "application/json", "X-Api-Key": session["key"]}
|
||||||
response = requests.get(url, headers=headers)
|
response = requests.get(url, headers=headers)
|
||||||
return handle_responses(response)
|
return key_response(response)
|
||||||
else:
|
else:
|
||||||
error = "Hm. That doesn't seem right"
|
error = "Hm. That doesn't seem right"
|
||||||
return render_template("index.html", title="Home", error=error)
|
return render_template("index.html", title="Home", error=error)
|
||||||
@ -60,6 +50,11 @@ def ask_key():
|
|||||||
return render_template("index.html", title="Home")
|
return render_template("index.html", title="Home")
|
||||||
|
|
||||||
|
|
||||||
|
# @app.route("/", method="POST")
|
||||||
|
# def upload_csv():
|
||||||
|
# pass
|
||||||
|
|
||||||
|
|
||||||
@app.route("/", methods=["GET", "POST"])
|
@app.route("/", methods=["GET", "POST"])
|
||||||
def render_home():
|
def render_home():
|
||||||
return render_template("index.html", title="Home")
|
return render_template("index.html", title="Home")
|
||||||
@ -105,10 +100,11 @@ def get_courses():
|
|||||||
course_dict[keys] = values
|
course_dict[keys] = values
|
||||||
array.append(course_dict)
|
array.append(course_dict)
|
||||||
dataframe = pd.DataFrame(array).drop(
|
dataframe = pd.DataFrame(array).drop(
|
||||||
["list_image_url", "permalink"],
|
["list_image_url", "permalink"], axis=1
|
||||||
axis=1
|
)
|
||||||
)
|
dataframe["full_description"] = dataframe[
|
||||||
dataframe['full_description'] = dataframe['full_description'].str.replace(r'<[^<>]*>', '', regex=True)
|
"full_description"
|
||||||
|
].str.replace(r"<[^<>]*>", "", regex=True)
|
||||||
print(dataframe)
|
print(dataframe)
|
||||||
|
|
||||||
if "next" not in nextlink:
|
if "next" not in nextlink:
|
||||||
@ -150,7 +146,6 @@ def get_people():
|
|||||||
break
|
break
|
||||||
|
|
||||||
dfppl = dataframe.to_html()
|
dfppl = dataframe.to_html()
|
||||||
dfshow = show(dfppl)
|
|
||||||
session["dfcsv"] = dataframe.to_csv()
|
session["dfcsv"] = dataframe.to_csv()
|
||||||
return render_template("get.html", table=dfppl, title="List of People")
|
return render_template("get.html", table=dfppl, title="List of People")
|
||||||
else:
|
else:
|
||||||
@ -213,7 +208,29 @@ def bulk_add_ppl():
|
|||||||
"content-type": "application/json",
|
"content-type": "application/json",
|
||||||
"X-Api-Key": session["key"],
|
"X-Api-Key": session["key"],
|
||||||
}
|
}
|
||||||
return payload
|
response = requests.post(url, json=payload, headers=headers)
|
||||||
|
response = str(response)
|
||||||
|
if "202" in response:
|
||||||
|
error = "Success! People have been added successfully."
|
||||||
|
return render_template(
|
||||||
|
"bulk_add_ppl.html",
|
||||||
|
table=session["dfgroups"],
|
||||||
|
title="People Added",
|
||||||
|
error=error,
|
||||||
|
)
|
||||||
|
elif "403" in response:
|
||||||
|
error = "Uh oh. Looks like you're not the admin or don't have appropriate privileges. Please talk to your academy admin."
|
||||||
|
elif "422" in response:
|
||||||
|
error = "Hm. Looks like something was wrong with the names. Reach out to the manager of this app."
|
||||||
|
return render_template(
|
||||||
|
"bulk_add_people.html",
|
||||||
|
table=session["dfgroups"],
|
||||||
|
title="People Added",
|
||||||
|
error=error,
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
error = "Shrug"
|
||||||
|
return render_template("bulk_add_ppl.html", title="Shrug", error=error)
|
||||||
|
|
||||||
|
|
||||||
@app.route("/add_groups_opts", methods=["POST"])
|
@app.route("/add_groups_opts", methods=["POST"])
|
||||||
|
|||||||
@ -97,18 +97,53 @@ img {
|
|||||||
height: 80px;
|
height: 80px;
|
||||||
}
|
}
|
||||||
|
|
||||||
main {
|
.main {
|
||||||
margin: 4px;
|
margin: 4px;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
|
padding: 25px;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.header {
|
.header {
|
||||||
|
margin: 0;
|
||||||
|
padding: 20px;
|
||||||
font-weight: 200;
|
font-weight: 200;
|
||||||
margin-top: 80px;
|
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.header_opts {
|
||||||
|
margin: 0px;
|
||||||
|
--webkit-box-align: center;
|
||||||
|
align-items: center;
|
||||||
|
display: flex;
|
||||||
|
height: 48px;
|
||||||
|
padding: 8px 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-link {
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
li {
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
|
||||||
|
.button-background {
|
||||||
|
margin-right: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navbutton {
|
||||||
|
border-radius: 4px;
|
||||||
|
margin-right: 4px;
|
||||||
|
border: 1px solid #66C92D;
|
||||||
|
white-space: nowrap;
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: 14px;
|
||||||
|
line-height: 16px;
|
||||||
|
text-decoration: none;
|
||||||
|
padding: 8px 16px 8px 12px;
|
||||||
|
}
|
||||||
|
|
||||||
#currentDate {
|
#currentDate {
|
||||||
color: var(--primary);
|
color: var(--primary);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
{% extends 'head.html' %}
|
{% include 'head.html' %}
|
||||||
|
{% include 'header.html' %}
|
||||||
|
{% include 'logo.html' %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h2>Hello! Please enter Group Names below.</h2>
|
<h2>Hello! Please enter Group Names below.</h2>
|
||||||
<p></p>
|
<p></p>
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
{% extends 'head.html' %}
|
{% include 'head.html' %}
|
||||||
|
{% include 'header.html' %}
|
||||||
|
{% include 'logo.html' %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h4>Hello! Please enter the emails below.</h4>
|
<h4>Hello! Please enter the emails below.</h4>
|
||||||
{% if error %}
|
{% if error %}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
{% extends 'head.html' %}
|
{% include 'head.html' %}
|
||||||
|
{% include 'header.html' %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
{% include 'table.html' %}
|
{% include 'table.html' %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
@ -19,20 +19,6 @@
|
|||||||
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
|
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="three-verts">
|
|
||||||
<div class="container">
|
|
||||||
<header class="header">
|
|
||||||
<div class="main">
|
|
||||||
<a href="{{ url_for('render_home')}}">
|
|
||||||
<img
|
|
||||||
src="{{ url_for('static', filename="NP-Logo-Primary-FC.png") }}"
|
|
||||||
alt="Northpass Full Color Logo"
|
|
||||||
>
|
|
||||||
</img></a>
|
|
||||||
</header>
|
|
||||||
</div>
|
|
||||||
{% for message in get_flashed_messages() %}
|
|
||||||
<h2> {{ message }} </h2>
|
|
||||||
{% endfor %}
|
|
||||||
{% block content %} {% endblock %}
|
{% block content %} {% endblock %}
|
||||||
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
48
app/templates/header.html
Normal file
48
app/templates/header.html
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<header class="header">
|
||||||
|
|
||||||
|
<ul class="header_opts">
|
||||||
|
<form class="navbutton" action="{{ url_for('render_home')}}">
|
||||||
|
<a href="{{ url_for('render_home')}}">
|
||||||
|
<div class="icon-background">
|
||||||
|
<i class="ri-home-line"></i>
|
||||||
|
</div>
|
||||||
|
Home
|
||||||
|
</a>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<form class="navbutton"
|
||||||
|
action="{{ url_for('get_people')}}"
|
||||||
|
method="post">
|
||||||
|
<a class="navoption"
|
||||||
|
onclick="document.forms['get_people'].submit()"
|
||||||
|
style="cursor:pointer;">
|
||||||
|
<i class="ri-car-line card__icon"></i>
|
||||||
|
<p class="navselection">Get People</p>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<form class="navbutton"
|
||||||
|
id="get_people"
|
||||||
|
action="{{ url_for('get_people')}}"
|
||||||
|
method="post">
|
||||||
|
<a class="navoption" onclick="document.forms['get_people'].submit()" class="nav-link">
|
||||||
|
<div class="icon-background">
|
||||||
|
<i class="ri-home-line"></i>
|
||||||
|
</div>
|
||||||
|
Get People
|
||||||
|
</a>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<form
|
||||||
|
class="navbutton"
|
||||||
|
id="get_courses"
|
||||||
|
action="{{ url_for('get_courses')}}"
|
||||||
|
method="post">
|
||||||
|
<a onclick="document.forms['get_courses'].submit()" class="nav-link">
|
||||||
|
<div class="icon-background">
|
||||||
|
<i class="ri-briefcase-line"></i>
|
||||||
|
</div>
|
||||||
|
Get Courses
|
||||||
|
</a>
|
||||||
|
</form>
|
||||||
|
</header>
|
||||||
@ -1,5 +1,6 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
{% extends 'head.html' %}
|
{% include 'head.html' %}
|
||||||
|
{% include 'logo.html' %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h4>Hello! Please click below to enter your key.</h4>
|
<h4>Hello! Please click below to enter your key.</h4>
|
||||||
{% for error in error %}
|
{% for error in error %}
|
||||||
@ -12,4 +13,4 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
11
app/templates/logo.html
Normal file
11
app/templates/logo.html
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<div class="main">
|
||||||
|
<a href="{{ url_for('render_home')}}">
|
||||||
|
<img
|
||||||
|
src="{{ url_for('static', filename="NP-Logo-Primary-FC.png") }}"
|
||||||
|
alt="Northpass Full Color Logo"
|
||||||
|
>
|
||||||
|
</img></a>
|
||||||
|
{% for message in get_flashed_messages() %}
|
||||||
|
<h2> {{ message }} </h2>
|
||||||
|
{% endfor %}
|
||||||
@ -1,8 +1,7 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
{% extends 'head.html' %}
|
{% extends 'head.html' %}
|
||||||
|
{% include 'logo.html' %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
|
|
||||||
<h4>Hello! Please find the options for {{ session.school }}.</h4>
|
<h4>Hello! Please find the options for {{ session.school }}.</h4>
|
||||||
<p></p>
|
<p></p>
|
||||||
</div>
|
</div>
|
||||||
@ -11,7 +10,7 @@
|
|||||||
action="{{ url_for('get_people')}}"
|
action="{{ url_for('get_people')}}"
|
||||||
method="post">
|
method="post">
|
||||||
<a class="a-card"
|
<a class="a-card"
|
||||||
onclick="document.forms[0].submit()"
|
onclick="document.forms['get_people'].submit()"
|
||||||
style="cursor:pointer;">
|
style="cursor:pointer;">
|
||||||
<i class="ri-car-line card__icon"></i>
|
<i class="ri-car-line card__icon"></i>
|
||||||
<p class="card__name">Get People</p>
|
<p class="card__name">Get People</p>
|
||||||
@ -61,6 +60,5 @@
|
|||||||
<p class="card__name">Add Active People to Groups</p>
|
<p class="card__name">Add Active People to Groups</p>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</body>
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user