-
Notifications
You must be signed in to change notification settings - Fork 52
Style/weekview #217
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
yammesicka
merged 25 commits into
PythonFreeCourse:develop
from
sagizaidor:style/weekview
Feb 13, 2021
Merged
Style/weekview #217
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
89db157
setup commit
sagizaidor c47402b
Merge branch 'develop' of https://github.com/PythonFreeCourse/calenda…
sagizaidor 2daa574
changed branch name
sagizaidor f23a081
קומיט עצוב ברמות
sagizaidor 3145450
מתחיל הכל מחדש
sagizaidor 4dccf1f
שוב
sagizaidor 18c4a30
after recrate weekviw
sagizaidor f6714f6
titles fix
sagizaidor a1d3785
fixed tests again
sagizaidor 6b61229
before fixing lint
sagizaidor 37aac81
after lint changes before pr
sagizaidor 25b9b36
Merge branch 'develop' into style/weekview
sagizaidor 340875a
after lint fix
sagizaidor 195dfb7
more lint fix
sagizaidor e38474c
taking notes
sagizaidor 863d02e
taking notes
sagizaidor 10f0009
Merge branch 'develop' into style/weekview
sagizaidor 6271761
resolved conflicts
sagizaidor 3fbf101
more notes
sagizaidor dfaadef
with fixed tests
sagizaidor 09945c4
Merge branch 'develop' into style/weekview
sagizaidor 4237b9f
fixed bug after conflict resolved
sagizaidor 42f1abd
fixed one lint was missing
sagizaidor 4894f1a
another lint...
sagizaidor 583ab89
Merge branch 'develop' into style/weekview
yammesicka File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
from datetime import datetime, timedelta | ||
from itertools import accumulate | ||
from typing import Iterator, NamedTuple, Tuple | ||
|
||
from fastapi import APIRouter, Depends, Request | ||
from fastapi.templating import Jinja2Templates | ||
from sqlalchemy.orm.session import Session | ||
|
||
from app.database.models import Event, User | ||
from app.dependencies import get_db, TEMPLATES_PATH | ||
from app.routers.dayview import ( | ||
DivAttributes, dayview, get_events_and_attributes | ||
) | ||
|
||
|
||
templates = Jinja2Templates(directory=TEMPLATES_PATH) | ||
|
||
|
||
router = APIRouter() | ||
|
||
|
||
class DayEventsAndAttrs(NamedTuple): | ||
day: datetime | ||
template: Jinja2Templates.TemplateResponse | ||
events_and_attrs: Tuple[Event, DivAttributes] | ||
|
||
|
||
def get_week_dates(firstday: datetime) -> Iterator[datetime]: | ||
rest_of_days = [timedelta(days=1) for _ in range(6)] | ||
rest_of_days.insert(0, firstday) | ||
return accumulate(rest_of_days) | ||
Comment on lines
+28
to
+31
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can be written as: (outside the function) DAYS_IN_WEEK = 7
SINGLE_DAY = timedelta(days=1) (inside the function) six_days = [SINGLE_DAY] * (DAYS_IN_WEEK - 1)
return accumulate(six_days, initial=first_day) |
||
|
||
|
||
async def get_day_events_and_attributes( | ||
request: Request, day: datetime, session: Session, user: User, | ||
) -> DayEventsAndAttrs: | ||
template = await dayview( | ||
request=request, | ||
date=day.strftime('%Y-%m-%d'), | ||
view='week', | ||
session=session | ||
) | ||
events_and_attrs = get_events_and_attributes( | ||
day=day, session=session, user_id=user.id) | ||
return DayEventsAndAttrs(day, template, events_and_attrs) | ||
|
||
|
||
@router.get('/week/{firstday}') | ||
async def weekview( | ||
request: Request, firstday: str, session=Depends(get_db) | ||
): | ||
user = session.query(User).filter_by(username='test_username').first() | ||
firstday = datetime.strptime(firstday, '%Y-%m-%d') | ||
week_days = get_week_dates(firstday) | ||
week = [await get_day_events_and_attributes( | ||
request, day, session, user | ||
) for day in week_days] | ||
return templates.TemplateResponse("weekview.html", { | ||
"request": request, | ||
"week": week, | ||
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
:root { | ||
--primary:#30465D; | ||
--primary-variant:#FFDE4D; | ||
--secondary:#EF5454; | ||
--borders:#E7E7E7; | ||
--borders-variant:#F7F7F7; | ||
} | ||
|
||
.day { | ||
border-left: 1px solid var(--borders); | ||
width: 100%; | ||
} | ||
|
||
#week-view { | ||
display: grid; | ||
grid-template-rows: 1fr; | ||
grid-template-columns: 2.3em 1fr; | ||
} | ||
|
||
|
||
#week-schedule { | ||
grid-row: 1; | ||
grid-column: 2; | ||
z-index: 10; | ||
} | ||
|
||
#hoursgrid { | ||
grid-row: 1; | ||
grid-column: 1; | ||
margin-top: 2.1em; | ||
margin-left: -0.1em; | ||
z-index: 30; | ||
} | ||
|
||
.hour-top { | ||
color: white; | ||
width: 2.4em; | ||
margin-left: -2; | ||
overflow: hidden; | ||
} | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can
i
somehow be large or equal to it?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes becouse if thr function gets number bigger then the last parmeter it will create an index error... it will give 3.