-
Notifications
You must be signed in to change notification settings - Fork 52
Feature/shabbatime #333
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
Open
elor555
wants to merge
44
commits into
PythonFreeCourse:develop
Choose a base branch
from
elor555:feature/shabbatime
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Feature/shabbatime #333
Changes from 5 commits
Commits
Show all changes
44 commits
Select commit
Hold shift + click to select a range
6952f62
new featue-shabbat time
elor555 c745b37
edit
elor555 58d8fba
edit
elor555 4d2e3d3
edit
elor555 f4451ca
edit
elor555 03f8200
edit
elor555 09f3447
Merge branch 'develop' of https://github.com/PythonFreeCourse/calenda…
elor555 ad29c3b
edit
elor555 e82ad81
edit
elor555 5805579
Merge branch 'develop' of https://github.com/PythonFreeCourse/calenda…
elor555 e2612a9
Merge branch 'develop' of https://github.com/PythonFreeCourse/calenda…
elor555 55e82fa
Details Message
elor555 c422398
Details Message
elor555 a027151
Details Message
elor555 d07f516
Details Message
elor555 e49b624
Merge remote-tracking branch 'upstream/develop' into feature/shabbatime
elor555 d1da1f3
fix: flake8
elor555 00450c3
fix: many code improvements
elor555 1d21cd2
fix: many code improvements
elor555 10e5b04
fix: style improvements
elor555 5ef54f1
Merge remote-tracking branch 'upstream/develop' into feature/shabbatime
elor555 48cae11
fix: improvments
elor555 2e8be84
fix: improvments
elor555 7a4c32c
fix: improvments
elor555 e519138
fix: BUGFIX
elor555 6c580dd
fix: BUGFIX
elor555 ea4e41b
fix: STYLE
elor555 b0bb745
fix: bugfix
elor555 8fea1f5
fix: bugfix
elor555 bc9f14f
Merge remote-tracking branch 'upstream/develop' into feature/shabbatime
elor555 50c42d2
fix: improvment
elor555 1c743c3
fix: bugfix
elor555 935a9de
fix: bugfix
elor555 4c6a434
fix: bugfix
elor555 c8cf12f
fix: bugfix
elor555 bf56e9b
fix : adding information
elor555 f89ea45
fix : bugfix
elor555 ba2f35c
fix : bugfix
elor555 421e70b
fix : bugfix
elor555 8d3e106
fix : bugfix
elor555 9e22801
fix : bugfix
elor555 7313c85
fix : bugfix
elor555 855a871
fix : bugfix
elor555 b7c8067
fix : bugfix
elor555 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
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,54 @@ | ||
import requests | ||
from typing import Dict | ||
|
||
from sqlalchemy.orm import Session | ||
|
||
from app.database.models import Location | ||
|
||
|
||
def create_location_object(location_: Dict[str, str]) -> Location: | ||
"""Returns a Zodiac object from the dictionary data. | ||
|
||
Args: | ||
location_: A dictionary location related information. | ||
|
||
Returns: | ||
A new Location object. | ||
""" | ||
return Location( | ||
country=location_['country'], | ||
city=location_['city'], | ||
zip_number=location_['zip_number'], | ||
) | ||
|
||
|
||
def return_zip_to_location(session: Session) -> str: | ||
"""Returns the zip number of the user IP location that match location object. | ||
|
||
Args: | ||
session: The database connection. | ||
|
||
Returns: | ||
A zip number for the user location. | ||
""" | ||
ip_and_location = requests.get('http://ipinfo.io/json').json() | ||
for location in session.query(Location).all(): | ||
if location.city == ip_and_location['city'] and \ | ||
location.country == ip_and_location['country']: | ||
elor555 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return location.zip_number | ||
|
||
|
||
def get_user_location(session: Session) -> str: | ||
"""Returns the user location. | ||
|
||
Args: | ||
session: The database connection. | ||
|
||
Returns: | ||
A user location string. | ||
""" | ||
my_location = return_zip_to_location(session) | ||
location_details = requests.get( | ||
f"https://www.hebcal.com/shabbat?cfg=json&geonameid={my_location}" | ||
) | ||
return location_details.json() |
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 @@ | ||
from typing import Dict | ||
from datetime import datetime | ||
|
||
|
||
def shabbat_time_by_user_location(shabbat_time: Dict[str, str]) -> Dict: | ||
elor555 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"""Returns the shabbat time of the user location.. | ||
|
||
Args: | ||
Shabbat details. | ||
|
||
Returns: | ||
Shabbat start end ending time. | ||
""" | ||
shabbat_limit = { | ||
'start_hour': shabbat_time['items'][5]['title'].split(': ')[1], | ||
'start_date': datetime.strptime( | ||
shabbat_time['items'][5]['date'].split('T')[0], "%Y-%m-%d" | ||
).date(), | ||
'end_hour': shabbat_time['items'][7]['title'].split(': ')[1], | ||
'end_date': datetime.strptime( | ||
shabbat_time['items'][7]['date'].split('T')[0], "%Y-%m-%d" | ||
).date()} | ||
return shabbat_limit | ||
|
||
|
||
def get_shabbat_if_date_friday( | ||
shabbat_time: Dict[str, str], | ||
date: datetime) -> Dict: | ||
elor555 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"""Returns shabbat start end ending time if specific date | ||
is Saturday, else None. | ||
|
||
Args: | ||
Shabbat details and date. | ||
|
||
Returns: | ||
Shabbat start end ending time if specific date | ||
is Saturday, else None | ||
""" | ||
shabbat_obj = shabbat_time_by_user_location(shabbat_time) | ||
if date == shabbat_obj['start_date']: | ||
return shabbat_obj |
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.
Uh oh!
There was an error while loading. Please reload this page.