From a2ace63a3bb81f0e9660b9d4b0a915a4b574a801 Mon Sep 17 00:00:00 2001 From: Odelia Yechiel Date: Wed, 13 Jan 2021 00:04:09 +0200 Subject: [PATCH 1/5] new page for event editting --- app/templates/eventedit.html | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 app/templates/eventedit.html diff --git a/app/templates/eventedit.html b/app/templates/eventedit.html new file mode 100644 index 00000000..4bdcfcb8 --- /dev/null +++ b/app/templates/eventedit.html @@ -0,0 +1,10 @@ + + + + + $Title$ + + +$END$ + + \ No newline at end of file From 55b06c04bf17a01eb4d46d19aa7f0ea5003a6793 Mon Sep 17 00:00:00 2001 From: Odelia Yechiel Date: Sat, 16 Jan 2021 14:15:24 +0200 Subject: [PATCH 2/5] Added a form to edit the event details Added navigation tabs as base for event features Created eventedit endpoint to render the form page --- app/main.py | 7 +++- app/static/eventedit.css | 55 ++++++++++++++++++++++++++ app/templates/eventdetailsformtab.html | 48 ++++++++++++++++++++++ app/templates/eventedit.html | 44 +++++++++++++++++---- 4 files changed, 145 insertions(+), 9 deletions(-) create mode 100644 app/static/eventedit.css create mode 100644 app/templates/eventdetailsformtab.html diff --git a/app/main.py b/app/main.py index 3050a284..4069087a 100644 --- a/app/main.py +++ b/app/main.py @@ -2,7 +2,6 @@ from fastapi.staticfiles import StaticFiles from fastapi.templating import Jinja2Templates - app = FastAPI() app.mount("/static", StaticFiles(directory="static"), name="static") @@ -20,7 +19,6 @@ def home(request: Request): @app.get("/profile") def profile(request: Request): - # Get relevant data from database upcouming_events = range(5) current_username = "Chuck Norris" @@ -30,3 +28,8 @@ def profile(request: Request): "username": current_username, "events": upcouming_events }) + + +@app.get("/eventedit") +def eventedit(request: Request): + return templates.TemplateResponse("eventedit.html", {"request": request}) diff --git a/app/static/eventedit.css b/app/static/eventedit.css new file mode 100644 index 00000000..25fb651c --- /dev/null +++ b/app/static/eventedit.css @@ -0,0 +1,55 @@ +html, +body { + height: 100%; + min-width: 265px; +} + +body { + display: flex; + flex-direction: column; +} + +#event_edit_tabs { + height: 100%; + flex: 1; +} + +.tab-pane { + height: 100%; + display: flex; + flex-direction: column; +} + +form { + display: flex; + flex-direction: column; + height: 100%; +} + +.form_row, +.form_row_start, +.form_row_end { + display: flex +} + +.form_row { + flex: 1; + min-height: 35px; + max-height: 50px; +} + +.form_row.textarea { + flex: 4; + max-height: 300px; +} + +input[type="text"], +input[type="date"], +textarea, +.form_row_start { + flex: 1; +} + +input[type="submit"] { + width: 100%; +} \ No newline at end of file diff --git a/app/templates/eventdetailsformtab.html b/app/templates/eventdetailsformtab.html new file mode 100644 index 00000000..4c682c3e --- /dev/null +++ b/app/templates/eventdetailsformtab.html @@ -0,0 +1,48 @@ +
+ +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ +
+ +
+
+ +
+ + +
+ + +
+
\ No newline at end of file diff --git a/app/templates/eventedit.html b/app/templates/eventedit.html index 4bdcfcb8..2c523b58 100644 --- a/app/templates/eventedit.html +++ b/app/templates/eventedit.html @@ -1,10 +1,40 @@ - - - $Title$ - - -$END$ - + + + Edit Event + + + +
+ + +
+
+ {% include "eventdetailsformtab.html" %} +
+ + + + +
+
+ +
+
+ \ No newline at end of file From b9ec7f64884822807eaf2002539645160f3d599d Mon Sep 17 00:00:00 2001 From: Odelia Yechiel Date: Sat, 16 Jan 2021 16:33:04 +0200 Subject: [PATCH 3/5] Added eventedit test Fixed static and templates path to be compatible with testing --- app/main.py | 9 +++++++-- tests/test_app.py | 9 +++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/app/main.py b/app/main.py index 4069087a..433c137b 100644 --- a/app/main.py +++ b/app/main.py @@ -1,12 +1,17 @@ +import os + from fastapi import FastAPI, Request from fastapi.staticfiles import StaticFiles from fastapi.templating import Jinja2Templates app = FastAPI() -app.mount("/static", StaticFiles(directory="static"), name="static") +app_path = os.path.dirname(os.path.realpath(__file__)) +static_path = os.path.join(app_path, "static") +templates_path = os.path.join(app_path, "templates") -templates = Jinja2Templates(directory="templates") +app.mount("/static", StaticFiles(directory=static_path), name="static") +templates = Jinja2Templates(directory=templates_path) @app.get("/") diff --git a/tests/test_app.py b/tests/test_app.py index e69de29b..9ebeb88b 100644 --- a/tests/test_app.py +++ b/tests/test_app.py @@ -0,0 +1,9 @@ +from fastapi.testclient import TestClient +from app.main import app + +client = TestClient(app) + +def test_eventedit(): + response = client.get("/eventedit") + assert response.status_code == 200 + assert b"Edit Event" in response.content From 185a8abff40a86f4d2c4b07148b6923157c97453 Mon Sep 17 00:00:00 2001 From: Odelia Yechiel Date: Sat, 16 Jan 2021 16:37:50 +0200 Subject: [PATCH 4/5] Updated requirements.txt --- requirements.txt | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/requirements.txt b/requirements.txt index ffed4ae5..00afd2eb 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,13 +1,17 @@ aiofiles==0.6.0 atomicwrites==1.4.0 attrs==20.3.0 +certifi==2020.12.5 +chardet==4.0.0 click==7.1.2 colorama==0.4.4 +coverage==5.3.1 fastapi==0.63.0 h11==0.12.0 h2==4.0.0 hpack==4.0.0 hyperframe==6.0.0 +idna==2.10 importlib-metadata==3.3.0 iniconfig==1.1.1 Jinja2==2.11.2 @@ -19,10 +23,17 @@ py==1.10.0 pydantic==1.7.3 pyparsing==2.4.7 pytest==6.2.1 +pytest-cov==2.10.1 +python-dotenv==0.15.0 +PyYAML==5.3.1 +requests==2.25.1 SQLAlchemy==1.3.22 starlette==0.13.6 toml==0.10.2 typing-extensions==3.7.4.3 +urllib3==1.26.2 uvicorn==0.13.3 +watchgod==0.6 +websockets==8.1 wsproto==1.0.0 zipp==3.4.0 From 55bf387e017a116ab68674adb61100bc3775ff69 Mon Sep 17 00:00:00 2001 From: Odelia Yechiel Date: Mon, 18 Jan 2021 15:28:25 +0200 Subject: [PATCH 5/5] Changed route to /event/edit Moved to route to routers Moved event test to test_event.py --- app/dependencies.py | 5 +++++ app/main.py | 17 ++++++----------- app/routers/event.py | 17 +++++++++++++++++ app/static/eventedit.css | 11 +++++++---- ...formtab.html => event_details_form_tab.html} | 0 app/templates/eventedit.html | 2 +- tests/test_app.py | 9 --------- tests/test_event.py | 11 +++++++++++ 8 files changed, 47 insertions(+), 25 deletions(-) create mode 100644 app/routers/event.py rename app/templates/{eventdetailsformtab.html => event_details_form_tab.html} (100%) create mode 100644 tests/test_event.py diff --git a/app/dependencies.py b/app/dependencies.py index e69de29b..77f528fb 100644 --- a/app/dependencies.py +++ b/app/dependencies.py @@ -0,0 +1,5 @@ +import os + +APP_PATH = os.path.dirname(os.path.realpath(__file__)) +STATIC_PATH = os.path.join(APP_PATH, "static") +TEMPLATES_PATH = os.path.join(APP_PATH, "templates") diff --git a/app/main.py b/app/main.py index 433c137b..9d9f1078 100644 --- a/app/main.py +++ b/app/main.py @@ -1,17 +1,14 @@ -import os - from fastapi import FastAPI, Request from fastapi.staticfiles import StaticFiles from fastapi.templating import Jinja2Templates -app = FastAPI() +from routers import event +from dependencies import STATIC_PATH, TEMPLATES_PATH -app_path = os.path.dirname(os.path.realpath(__file__)) -static_path = os.path.join(app_path, "static") -templates_path = os.path.join(app_path, "templates") +app = FastAPI() -app.mount("/static", StaticFiles(directory=static_path), name="static") -templates = Jinja2Templates(directory=templates_path) +templates = Jinja2Templates(directory=TEMPLATES_PATH) +app.mount("/static", StaticFiles(directory=STATIC_PATH), name="static") @app.get("/") @@ -35,6 +32,4 @@ def profile(request: Request): }) -@app.get("/eventedit") -def eventedit(request: Request): - return templates.TemplateResponse("eventedit.html", {"request": request}) +app.include_router(event.router) diff --git a/app/routers/event.py b/app/routers/event.py new file mode 100644 index 00000000..ea965db8 --- /dev/null +++ b/app/routers/event.py @@ -0,0 +1,17 @@ +from fastapi import APIRouter, Request +from fastapi.templating import Jinja2Templates + +from dependencies import TEMPLATES_PATH + +templates = Jinja2Templates(directory=TEMPLATES_PATH) + +router = APIRouter( + prefix="/event", + tags=["event"], + responses={404: {"description": "Not found"}}, +) + + +@router.get("/edit") +async def eventedit(request: Request): + return templates.TemplateResponse("eventedit.html", {"request": request}) diff --git a/app/static/eventedit.css b/app/static/eventedit.css index 25fb651c..483c219f 100644 --- a/app/static/eventedit.css +++ b/app/static/eventedit.css @@ -1,7 +1,10 @@ html, body { height: 100%; - min-width: 265px; + min-width: max-content; + max-width: -moz-available; + max-width: -webkit-fill-available; + max-width: fill-available; } body { @@ -34,13 +37,13 @@ form { .form_row { flex: 1; - min-height: 35px; - max-height: 50px; + min-height: 2.25em; + max-height: 3.25em; } .form_row.textarea { flex: 4; - max-height: 300px; + max-height: 19em; } input[type="text"], diff --git a/app/templates/eventdetailsformtab.html b/app/templates/event_details_form_tab.html similarity index 100% rename from app/templates/eventdetailsformtab.html rename to app/templates/event_details_form_tab.html diff --git a/app/templates/eventedit.html b/app/templates/eventedit.html index 2c523b58..620da005 100644 --- a/app/templates/eventedit.html +++ b/app/templates/eventedit.html @@ -25,7 +25,7 @@
- {% include "eventdetailsformtab.html" %} + {% include "event_details_form_tab.html" %}
diff --git a/tests/test_app.py b/tests/test_app.py index 9ebeb88b..e69de29b 100644 --- a/tests/test_app.py +++ b/tests/test_app.py @@ -1,9 +0,0 @@ -from fastapi.testclient import TestClient -from app.main import app - -client = TestClient(app) - -def test_eventedit(): - response = client.get("/eventedit") - assert response.status_code == 200 - assert b"Edit Event" in response.content diff --git a/tests/test_event.py b/tests/test_event.py new file mode 100644 index 00000000..aa07ebe0 --- /dev/null +++ b/tests/test_event.py @@ -0,0 +1,11 @@ +from fastapi.testclient import TestClient + +from app.main import app + +client = TestClient(app) + + +def test_eventedit(): + response = client.get("/event/edit") + assert response.status_code == 200 + assert b"Edit Event" in response.content