From b3a44ce92920bd95b14136a4c7b27c50d38067c3 Mon Sep 17 00:00:00 2001 From: Norm Rasmussen Date: Wed, 1 Mar 2023 17:05:16 -0500 Subject: [PATCH] Subnav bar added and some other small changes. Need to figure out CSV upload. --- app/__init__.py | 4 ++ app/__pycache__/__init__.cpython-311.pyc | Bin 459 -> 536 bytes app/__pycache__/routes.cpython-311.pyc | Bin 15932 -> 15835 bytes app/routes.py | 65 ++++++++++++++--------- app/static/css/styles.css | 39 +++++++++++++- app/templates/bulk_add_groups.html | 4 +- app/templates/bulk_add_ppl.html | 4 +- app/templates/get.html | 3 +- app/templates/head.html | 16 +----- app/templates/header.html | 48 +++++++++++++++++ app/templates/index.html | 5 +- app/templates/logo.html | 11 ++++ app/templates/options.html | 6 +-- 13 files changed, 155 insertions(+), 50 deletions(-) create mode 100644 app/templates/header.html create mode 100644 app/templates/logo.html diff --git a/app/__init__.py b/app/__init__.py index f5b34f4..b04e3b2 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -4,4 +4,8 @@ from config import Config app = Flask(__name__) app.config.from_object(Config) +# Upload folder +UPLOAD_FOLDER = 'static/files' +app.config['UPLOAD_FOLDER'] =UPLOAD_FOLDER + from app import routes diff --git a/app/__pycache__/__init__.cpython-311.pyc b/app/__pycache__/__init__.cpython-311.pyc index fbf19c7f0f77fd5fa021d7c80facba358b2f92e1..37714d5318701ac6e9eb056ecd04f058b27d13c8 100644 GIT binary patch delta 167 zcmX@jJcEUIIWI340}xC;{XhBkL|#e8o{8!in#@t`sqCq&Sxg`)5J+LM0g((TtU0W? z98nyM3@L2E44Ui{7f5JT@f4RNmSiUDr)B1(7T@9x4e;@IbcuKK_i=Fz(qz2FR+L{_ zl3MJi$vN?;6;l!0#6OW-{6Nzffw;JQay+BI@CP;qLHP#W8?ssr%q?6U_7@qXC$D3a JWZ?xW0RYRmD!Bjv delta 112 zcmbQia+;ZUIWI340}v#Iyi0DF$ScWMGEqIlj3I?Nhc%Zyik*=mg(a9lll3J?jV9wQ zR=1qQ;%p#;%{f0WEi)a&D#|Y{NiFu%4qa+It GkP84w`y5>W diff --git a/app/__pycache__/routes.cpython-311.pyc b/app/__pycache__/routes.cpython-311.pyc index 294ccbd1e78c6c9551b6becf569dc857237aab19..155c7fe1ddf5318ece18441dffca175acaa70f82 100644 GIT binary patch delta 4085 zcmb7Gdu&tJ8NbJGCwA;OiDSokToVEql8`vB62h|)pq6xu1j-o9TzoH%iDR2{uLFdz z(5>BIQ(MBJ1F4!uS1G{A`cS&5nksGDAJe2xlcVL2=x*!Sw11|dF4dSeMcdf-9p{1b zkk%vLpYQ!%=bZ2R&i9>iwtJ<$v zp%+-D7m#hEtH!Nzg=*z8)v7fXTfIWFYMEwDp5~FIWD!@WR?9&}h}0}(fg;N52Dm(R zfYFlt)FOgx?B!3WmVM1A7nniM2+!Yt&fd3{FuU2^IV4d3h;Vi>uPze}rRIlhkc}f` z!ZZ$A4^Wd2uxZu^dt#~(LES4`WNXZ@x+43pwG!tk?-fF}7j$E5Q+Tc*o|Kgfjs4nS zVwk;Z4p@=gJbaApwmoyaUQ{#Deo<0ItzQubl#AkNC7z6l(S9izQ{=|sEr*psW$?5@ z>rvvOC{aaBOL3~mqLvaB36vE%6P2_S4Tem*QPrq!(v%Atdt|OQQ#b5@xh&5~4zL}e zikeO(RfU!Vxey+e0$dShtd2K~*AI+2Z#uKqD)`N~eK(y~&A)e5-yV6d>t~s)t7pp9 zGwtfh+InW}MQ_wz?;mTp*^sr@!0(~s%#33j`;RS1ZcoNcvJ%P6X*@@0oi zd{eqHLld+aZJ>G81R%oTwsotd4n$zbbUTvSiK3r4Ywp;lNav@b9oHWv(8dT^`Aa}A~xvGhe{nhpT zzz!5!k~M46>4ZYNfx3&`b8iNz-?)E7*0XEHr*^iWtR2CIfIA5h-6p5bCle`2Rxw5A zcjH(fMxyEvJphbuw$XDKTsG`^*9b1#>}{{BM=K$O281R6-JFOg2UPBQ-4K^)fW6}F zBm0={4U%s5Z|~6^d=-2F+fb_wA;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WdaY1c&$r&Z1Tl`glf3N@uS@<3gWtqZ#Mv%~ywT~GFFtibS~!Uk*@dm#X$Dn731 z>9J^RBBsY!6kYfT4nBx5gzz1JDbG+s)8+JW`I~Aw1FrNC5*?GHF#KvlBR!MA(I}Wa{FPQbU|-RS5#>b3$P~{v1x(ZMXw&oW1@_X4>s8gy zsk4FS0~f6PUVlBWZGcFf?`imhw4`+^_Z<3fwO&2K(&L$^nqui>atxAT6a%D8^Hcm$ zxjlxp^j-Q+#2pftczc6-F*b}L(wg*MLUF{ zdQit=i6na*hnCbkXJUBQO}XOfln(0a*3V>Awh2gKr|`d`TDGCkAb)LrYgV`!<`*bH z>|)9oV}@PW0eb8_vWi7^LC=7R$BrdZF;Q>&?&;lz%hg&}5a{Bzb zz-4EVc{xXQSv>ZVi-q58Ji+AzZUOchTpjNc@ z3&8iu{NKAdSo`&JJtiw2jy=x5*ZVEHmw(pVMC&;1>!&upsW0r1aqtNM{!H)TMsa2R z07)+cthkb2MV`vOR-co?@DGtkMrcL))z+3saSz2jfLZMpB|ZtCaM$BiBCKbadLzC3 zq5jB*=aGbJn{wTa(WuG06-8CTCUH+POcRUudVi#Eioe=6!QbnTW(~{mC>tLs7A)>n z&W2J?A&3lzt|AHr!<+`uUM45 z1*4nz_ASG(&)F?^&}RPoEuC3${R?wF4daG21I2wz6Isu&B}5^k6|aizxES7)q7oD} zn_&S<>Z&NRL{U_UQ2X`ny=P@->%au+`{c+l^o@P`8c#|HAWzaSx{ Ni+?tF(=5a8{tY!5-+BN5 diff --git a/app/routes.py b/app/routes.py index 29a0558..a00e0f3 100644 --- a/app/routes.py +++ b/app/routes.py @@ -8,24 +8,14 @@ from itables import show import re -def handle_responses(response): - print(response.status_code) - print(response.text) - try: - response.raise_for_status() - 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): +def key_response(response): + if "402" in str(response): + error = response.text + return render_template("index.html", title="Error Home", error=error) + elif "401" in str(response): error = [ - "Unauthorized access error. This can mean a lot of things.", - "Has the key changed, recently?", + "Unauthorized access error. This can mean a lot of things, such as the key being changed.", + "Remember, they are paired to each educator!", ] return render_template("index.html", title="Error Home", error=error) else: @@ -51,7 +41,7 @@ def ask_key(): url = "https://api.northpass.com/v2/properties/school" headers = {"accept": "application/json", "X-Api-Key": session["key"]} response = requests.get(url, headers=headers) - return handle_responses(response) + return key_response(response) else: error = "Hm. That doesn't seem right" return render_template("index.html", title="Home", error=error) @@ -60,6 +50,11 @@ def ask_key(): return render_template("index.html", title="Home") +# @app.route("/", method="POST") +# def upload_csv(): +# pass + + @app.route("/", methods=["GET", "POST"]) def render_home(): return render_template("index.html", title="Home") @@ -105,10 +100,11 @@ def get_courses(): course_dict[keys] = values array.append(course_dict) dataframe = pd.DataFrame(array).drop( - ["list_image_url", "permalink"], - axis=1 - ) - dataframe['full_description'] = dataframe['full_description'].str.replace(r'<[^<>]*>', '', regex=True) + ["list_image_url", "permalink"], axis=1 + ) + dataframe["full_description"] = dataframe[ + "full_description" + ].str.replace(r"<[^<>]*>", "", regex=True) print(dataframe) if "next" not in nextlink: @@ -150,7 +146,6 @@ def get_people(): break dfppl = dataframe.to_html() - dfshow = show(dfppl) session["dfcsv"] = dataframe.to_csv() return render_template("get.html", table=dfppl, title="List of People") else: @@ -213,7 +208,29 @@ def bulk_add_ppl(): "content-type": "application/json", "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"]) diff --git a/app/static/css/styles.css b/app/static/css/styles.css index abfe11d..d48a86f 100644 --- a/app/static/css/styles.css +++ b/app/static/css/styles.css @@ -97,18 +97,53 @@ img { height: 80px; } -main { +.main { margin: 4px; flex-wrap: wrap; + padding: 25px; justify-content: center; } .header { + margin: 0; + padding: 20px; font-weight: 200; - margin-top: 80px; 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 { color: var(--primary); } diff --git a/app/templates/bulk_add_groups.html b/app/templates/bulk_add_groups.html index 9db73a5..ee787b8 100644 --- a/app/templates/bulk_add_groups.html +++ b/app/templates/bulk_add_groups.html @@ -1,5 +1,7 @@ -{% extends 'head.html' %} +{% include 'head.html' %} +{% include 'header.html' %} +{% include 'logo.html' %} {% block content %}

Hello! Please enter Group Names below.

diff --git a/app/templates/bulk_add_ppl.html b/app/templates/bulk_add_ppl.html index 4df30be..372c4c8 100644 --- a/app/templates/bulk_add_ppl.html +++ b/app/templates/bulk_add_ppl.html @@ -1,5 +1,7 @@ -{% extends 'head.html' %} +{% include 'head.html' %} +{% include 'header.html' %} +{% include 'logo.html' %} {% block content %}

Hello! Please enter the emails below.

{% if error %} diff --git a/app/templates/get.html b/app/templates/get.html index baf0756..b93befb 100644 --- a/app/templates/get.html +++ b/app/templates/get.html @@ -1,5 +1,6 @@ -{% extends 'head.html' %} +{% include 'head.html' %} +{% include 'header.html' %} {% block content %} {% include 'table.html' %} {% endblock %} diff --git a/app/templates/head.html b/app/templates/head.html index 36c24e2..9246ba5 100644 --- a/app/templates/head.html +++ b/app/templates/head.html @@ -19,20 +19,6 @@ -
-
-
-
- - Northpass Full Color Logo - -
-
- {% for message in get_flashed_messages() %} -

{{ message }}

- {% endfor %} {% block content %} {% endblock %} + diff --git a/app/templates/header.html b/app/templates/header.html new file mode 100644 index 0000000..02e0494 --- /dev/null +++ b/app/templates/header.html @@ -0,0 +1,48 @@ + +
+ +
diff --git a/app/templates/index.html b/app/templates/index.html index f0f4ecc..f8949b0 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -1,5 +1,6 @@ -{% extends 'head.html' %} +{% include 'head.html' %} +{% include 'logo.html' %} {% block content %}

Hello! Please click below to enter your key.

{% for error in error %} @@ -12,4 +13,4 @@
- {% endblock %} +{% endblock %} diff --git a/app/templates/logo.html b/app/templates/logo.html new file mode 100644 index 0000000..43495e2 --- /dev/null +++ b/app/templates/logo.html @@ -0,0 +1,11 @@ + +
+ + Northpass Full Color Logo + + {% for message in get_flashed_messages() %} +

{{ message }}

+ {% endfor %} diff --git a/app/templates/options.html b/app/templates/options.html index a840815..a5715be 100644 --- a/app/templates/options.html +++ b/app/templates/options.html @@ -1,8 +1,7 @@ {% extends 'head.html' %} +{% include 'logo.html' %} {% block content %} - -

Hello! Please find the options for {{ session.school }}.

@@ -11,7 +10,7 @@ action="{{ url_for('get_people')}}" method="post">

Get People

@@ -61,6 +60,5 @@

Add Active People to Groups

- {% endblock %}