Skip to content

Feature/HebrewView #280

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
wants to merge 71 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 52 commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
33723a7
add hebrew dates to calendar-nre feature
elor555 Feb 14, 2021
0d296f3
add test to hebrew dates
elor555 Feb 14, 2021
970534d
edit flake8
elor555 Feb 14, 2021
f0bc588
edit flake8
elor555 Feb 14, 2021
7282e00
fix after pull
elor555 Feb 15, 2021
861587a
edit flake8
elor555 Feb 15, 2021
8426167
edit
elor555 Feb 15, 2021
6b28e84
Merge branch 'develop' of https://github.com/PythonFreeCourse/calenda…
elor555 Feb 15, 2021
fbdd7f5
edit
elor555 Feb 15, 2021
442a640
edit
elor555 Feb 15, 2021
e4720c8
check
elor555 Feb 16, 2021
fcefcbe
check
elor555 Feb 16, 2021
9e6742e
edit
elor555 Feb 17, 2021
c63471a
edit
elor555 Feb 17, 2021
97a1d8c
edit after flake8
elor555 Feb 17, 2021
201b1d8
edit after flake8
elor555 Feb 17, 2021
739729e
Merge branch 'develop' of https://github.com/PythonFreeCourse/calenda…
elor555 Feb 17, 2021
d79b1c3
edit after flake8
elor555 Feb 17, 2021
f488161
edit after flake8
elor555 Feb 17, 2021
3d2c150
edit after flake8
elor555 Feb 17, 2021
d873fd6
edit after flake8
elor555 Feb 17, 2021
7593c11
edit after pull
elor555 Feb 19, 2021
3dd122b
edit after pull
elor555 Feb 19, 2021
b06b7be
edit after pull
elor555 Feb 19, 2021
4dd3ac5
edit
elor555 Feb 20, 2021
6c2d65c
edit
elor555 Feb 20, 2021
f6b8607
edit
elor555 Feb 20, 2021
3c70a58
edit
elor555 Feb 20, 2021
6a34a33
edit
elor555 Feb 20, 2021
822ac9d
edit
elor555 Feb 20, 2021
0ae1726
edit
elor555 Feb 20, 2021
9e9ee25
edit
elor555 Feb 20, 2021
0a8b157
Merge branch 'develop' of https://github.com/PythonFreeCourse/calenda…
elor555 Feb 21, 2021
ac73386
edit
elor555 Feb 21, 2021
426da0a
edit
elor555 Feb 21, 2021
63c437a
Merge branch 'develop' of https://github.com/PythonFreeCourse/calenda…
elor555 Feb 21, 2021
4ae0595
edit
elor555 Feb 21, 2021
f2323d6
edit
elor555 Feb 22, 2021
9fd7cbc
Merge branch 'develop' of https://github.com/PythonFreeCourse/calenda…
elor555 Feb 23, 2021
1c52fbd
edit
elor555 Feb 23, 2021
0abd915
edit
elor555 Feb 23, 2021
ad7ea1a
Merge branch 'develop' of https://github.com/PythonFreeCourse/calenda…
elor555 Feb 23, 2021
78278bc
edit
elor555 Feb 23, 2021
e8c1776
Merge branch 'develop' of https://github.com/PythonFreeCourse/calenda…
elor555 Feb 23, 2021
d2573b1
edit
elor555 Feb 23, 2021
d6b58f0
edit
elor555 Feb 23, 2021
7af9582
edit
elor555 Feb 23, 2021
a3b0b95
edit
elor555 Feb 23, 2021
be3ce04
Merge branch 'develop' of https://github.com/PythonFreeCourse/calenda…
elor555 Feb 24, 2021
408de5d
edit
elor555 Feb 24, 2021
848368f
edit
elor555 Feb 24, 2021
3e96b8b
edit
elor555 Feb 24, 2021
34ebe6e
edit
elor555 Feb 24, 2021
4fa9da5
Merge branch 'develop' of https://github.com/PythonFreeCourse/calenda…
elor555 Feb 24, 2021
a64fcd9
Merge branch 'develop' of https://github.com/PythonFreeCourse/calenda…
elor555 Feb 25, 2021
3b1a6be
Details Message
elor555 Feb 25, 2021
ed58474
Details Message
elor555 Feb 25, 2021
22f0bcc
fix: flake8
elor555 Feb 25, 2021
1a1eb3d
fix: flake8
elor555 Feb 25, 2021
7d6ec9b
fix: bug fix
elor555 Feb 25, 2021
18a0195
fix: bug fix
elor555 Feb 25, 2021
c022096
fix: bug fix
elor555 Feb 25, 2021
44f9d61
fix: fix translation files
elor555 Feb 25, 2021
76726e1
Merge remote-tracking branch 'upstream/develop' into feature/hebrewview
elor555 Feb 27, 2021
a2449d2
fix: bugfix
elor555 Mar 1, 2021
c7d3b7d
fix: bugfix
elor555 Mar 1, 2021
11fc0d6
fix: bugfix
elor555 Mar 1, 2021
377e82d
fix: bugfix
elor555 Mar 1, 2021
9b0c629
fix: styling
elor555 Mar 1, 2021
0a9a4fb
fix: bugfix
elor555 Mar 2, 2021
c48a270
fix: bugfix
elor555 Mar 2, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions app/internal/hebrew_date_view.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
from datetime import datetime

from hebrew_numbers import int_to_gematria
from pyluach import dates, hebrewcal


EN_TO_HEB_MONTH_NAMES = {
'Tishrei': 'תשרי',
'Cheshvan': 'חשוון',
'Kislev': 'כסלו',
'Teves': 'טבת',
'Shvat': 'שבט',
'Adar': 'אדר',
'Adar Rishon': "אדר(א')",
'Adar Sheni': "אדר(ב')",
'Nissan': 'ניסן',
'Iyar': 'אייר',
'Sivan': 'סיוון',
'Tamuz': 'תמוז',
'Av': 'אב',
'Elul': 'אלול',
}


def get_month_name_by_num(date: datetime) -> str:
"""Returns the Hebrew name date for the specific day.

Args:
date: The requested date.

Returns:
A Hebrew name date.
"""
for month in hebrewcal.Year(date.year).itermonths():
if date.month == month.month:
return EN_TO_HEB_MONTH_NAMES[month.name]


def from_greogian_to_hebrew_date(date: datetime) -> str:
"""Returns the Hebrew date for the specific greogian date.

Args:
date: The requested date.

Returns:
A Hebrew date string.
"""
gregorian_date = dates.GregorianDate(date.year, date.month, date.day)
return gregorian_date.to_heb()


def get_hebrew_date_in_words(date: datetime) -> str:
"""Returns the Hebrew date for the specific day.

Args:
date: The requested date.

Returns:
A Hebrew date string.
"""

hebrew_date_object = from_greogian_to_hebrew_date(date)
return ' '.join((
int_to_gematria(hebrew_date_object.day),
get_month_name_by_num(hebrew_date_object),
int_to_gematria(hebrew_date_object.year % 1000)
))
1 change: 1 addition & 0 deletions app/routers/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
)
from app.internal.security.dependencies import current_user


router = APIRouter(
prefix="/audio",
tags=["audio"],
Expand Down
23 changes: 13 additions & 10 deletions app/routers/calendar.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from http import HTTPStatus

from fastapi import APIRouter, Request
from fastapi import APIRouter, Request, Depends
from fastapi.responses import HTMLResponse
from starlette.responses import Response

from app.dependencies import templates
from app.routers import calendar_grid as cg
from app.dependencies import get_db, templates
from app.routers import calendar_grid


router = APIRouter(
prefix="/calendar/month",
Expand All @@ -16,16 +17,16 @@


@router.get("/")
async def calendar(request: Request) -> Response:
user_local_time = cg.Day.get_user_local_time()
day = cg.create_day(user_local_time)
async def calendar(request: Request, db_session=Depends(get_db)) -> Response:
user_local_time = calendar_grid.Day.get_user_local_time()
day = calendar_grid.create_day(user_local_time)
return templates.TemplateResponse(
"calendar_monthly_view.html",
{
"request": request,
"day": day,
"week_days": cg.Week.DAYS_OF_THE_WEEK,
"weeks_block": cg.get_month_block(day)
"week_days": calendar_grid.Week.DAYS_OF_THE_WEEK,
"weeks_block": calendar_grid.get_month_block(day),
}
)

Expand All @@ -34,8 +35,10 @@ async def calendar(request: Request) -> Response:
async def update_calendar(
request: Request, date: str, days: int
) -> HTMLResponse:
last_day = cg.Day.convert_str_to_date(date)
next_weeks = cg.create_weeks(cg.get_n_days(last_day, days))
last_day = calendar_grid.Day.convert_str_to_date(date)
next_weeks = calendar_grid.create_weeks(
calendar_grid.get_n_days(last_day, days)
)
template = templates.get_template(
'partials/calendar/monthly_view/add_week.html')
content = template.render(weeks_block=next_weeks)
Expand Down
4 changes: 3 additions & 1 deletion app/routers/dayview.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from app.database.models import Event, User
from app.dependencies import get_db, templates
from app.internal import international_days, zodiac
from app.internal import hebrew_date_view, international_days, zodiac
from app.routers.user import get_all_user_events

router = APIRouter()
Expand Down Expand Up @@ -177,6 +177,7 @@ async def dayview(
except ValueError as err:
raise HTTPException(status_code=404, detail=f"{err}")
zodiac_obj = zodiac.get_zodiac_of_day(session, day)
hebrew_obj = hebrew_date_view.get_hebrew_date_in_words(day.date())
events_n_attrs = get_events_and_attributes(
day=day,
session=session,
Expand All @@ -200,5 +201,6 @@ async def dayview(
"international_day": inter_day,
"zodiac": zodiac_obj,
"view": view,
"hebrew_view": hebrew_obj,
},
)
21 changes: 21 additions & 0 deletions app/static/dayview.css
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,24 @@ body {
width: 1.2rem;
height: 1.2rem;
}

.hebrew-dates {
position: absolute;
right: 1.2rem;
top: 5rem;
padding-right: var(--space_xs);
padding-left: var(--space_xs);
padding-bottom: var(--space_xxs);
border: solid 0.1px var(--primary);
background-color: var(--surface-variant);
box-shadow: 1px 1px 2px #999;
line-height: 1;
height: 3.5rem;
width: 3.5rem;
display: flex;
align-items: center;
justify-content: center;
font-size: 0.8rem;
font-weight: bold;
}

117 changes: 51 additions & 66 deletions app/templates/calendar_day_view.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,82 +14,67 @@
class="month-title fw-bold text-white">{{month}}</span>
<span id="day-num" class="day-title fw-bold text-white">{{day}}</span>
{% if zodiac %}
<div class="zodiac-sign">
<a href="https://www.horoscope.com/zodiac-signs/{{zodiac.name}}"
title="Zodiac-sign: {{zodiac.name}}"
target="_blank"><img
src="{{ url_for('static', path='/images/zodiac/' + zodiac.name + '.svg') }}"
alt="zodiac sign" width="14em" height="13em"></a>
</div>
{% endif %}
{% else %}
<span class="fw-bold text-white date-nums">{{day}} / {{month}}</span>
{% endif %}
<div class="zodiac-sign">
<a href="https://www.horoscope.com/zodiac-signs/{{zodiac.name}}" title="Zodiac-sign: {{zodiac.name}}"
target="_blank"><img src="{{ url_for('static', path='/images/zodiac/' + zodiac.name + '.svg') }}"
alt="zodiac sign" width="14em" height="13em"></a>
</div>
{% if international_day %}
<div class="international-days">
The International days are: "{{ international_day.international_day }}"
{% endif %}
{% if hebrew_view %}
<div class="hebrew-dates">
{{ hebrew_view }}
</div>
{% endif %}
<div class="all_day_events">
{% for event in all_day_events %}
<p class="text-truncate my-0 {{size}}">{{ event.title }}</p>
{% else %}
<span class="fw-bold text-white date-nums">{{day}} / {{month}}</span>
{% endif %}
</div>
<div class="schedule">
<div class="container times bg-primeary position">
{% for hour in range(25)%}
<div class='hour-block'>
<div class="row bg-transparent hour-mark">
{% if view == 'day'%}
{% set hour = hour|string() %}
{{hour.zfill(2)}}:00
{% endif %}
</div>
<div class="hour-bar row text-white border-bottom"></div>
</div>
{% endfor %}
</div>
<div class="schedule">
<div class="container times bg-primeary position">
{% for hour in range(25)%}
<div class='hour-block'>
<div class="row bg-transparent hour-mark">
{% if view == 'day'%}
{% set hour = hour|string() %}
{{hour.zfill(2)}}:00
{% endif %}
</div>
<div class="hour-bar row text-white border-bottom"></div>
</div>
{% endfor %}
<div class="event-grid">
{% for event, attr in events %}
<div id="event{{event.id}}" class="d-flex flex-column text-truncate px-2 event"
style="background-color: {{attr.color}}; grid-row: {{attr.grid_position}}; max-hight:1.5rem;">
<div class="d-flex flex-column justify-content-evenly event-details">
<p class="text-truncate my-0 {{attr.title_size_class}}">{{ event.title }}</p>
{% if attr.total_time_visible %}
<p class="total-time text-truncate fw-light my-0">{{attr.total_time}}</p>
{% endif %}
</div>
<div class="event-grid">
{% for event, attr in events %}
<div id="event{{event.id}}"
class="d-flex flex-column text-truncate px-2 event"
style="background-color: {{attr.color}}; grid-row: {{attr.grid_position}}; max-hight:1.5rem;">
<div class="d-flex flex-column justify-content-evenly event-details">
<p class="text-truncate my-0 {{attr.title_size_class}}">{{
event.title }}</p>
{% if attr.total_time_visible %}
<p class="total-time text-truncate fw-light my-0">
{{attr.total_time}}</p>
{% endif %}
</div>
<div class="d-flex flex-row justify-content-around align-items-end action-container"
style="grid-row: {{attr.grid_position}};">
<a href="/edit/{{event.id}}" title="Edit event"
class="action-icon"><img class="pb-1"
src="{{ url_for('static', path='/images/icons/pencil.svg')}}"></a>
<a href="/delete/{{event.id}}" title="Delete event"
class="action-icon"><img class="pb-1"
src="{{ url_for('static', path='/images/icons/trash-can.svg')}}"></a>
<a href="/event/{{event.id}}" title="See full event"
class="action-icon"><img class="pb-1"
src="{{ url_for('static', path='/images/icons/view.svg')}}"></a>
</div>
</div>
{% endfor %}
<div class="d-flex flex-row justify-content-around align-items-end action-container"
style="grid-row: {{attr.grid_position}};">
<a href="/edit/{{event.id}}" title="Edit event" class="action-icon"><img class="pb-1"
src="{{ url_for('static', path='/images/icons/pencil.svg')}}"></a>
<a href="/delete/{{event.id}}" title="Delete event" class="action-icon"><img class="pb-1"
src="{{ url_for('static', path='/images/icons/trash-can.svg')}}"></a>
<a href="/event/{{event.id}}" title="See full event" class="action-icon"><img class="pb-1"
src="{{ url_for('static', path='/images/icons/view.svg')}}"></a>
</div>
</div>
{% endfor %}
</div>
{% if view == 'day'%}
<button title="Add Event" class="event-btn add-event-icon">
<ion-icon name="add"></ion-icon>
</button>
{% endif %}
</div>
{% if view == 'day'%}
<button title="Add Event" class="event-btn add-event-icon">
<ion-icon name="add"></ion-icon>
</button>
{% endif %}
</div>
{% if view == 'day'%}
<div id="event_block"></div>{% endif %}
{% if view == 'day'%}<div id="event_block"></div>{% endif %}
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
integrity="sha384-ygbV9kiqUc6oa4msXn9868pTtWMgiQaeYH7/t7LECLbyPA2x65Kgf80OJFdroafW"
crossorigin="anonymous"></script>
<script type="text/javascript"
src="{{ url_for('static', path='/eventdisplay.js') }}"></script>
<script type="text/javascript" src="{{ url_for('static', path='/eventdisplay.js') }}"></script>
{% endblock body %}
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ google-auth-oauthlib==0.4.2
googleapis-common-protos==1.52.0
h11==0.12.0
h2==4.0.0
python-hebrew-numbers==0.2.3
hiredis==1.1.0
hpack==4.0.0
httpcore==0.12.2
Expand Down Expand Up @@ -104,6 +105,7 @@ pycparser==2.20
pydantic==1.7.3
pyflakes==2.2.0
PyJWT==2.0.0
pyluach==1.2.1
pyparsing==2.4.7
pytest==6.2.1
pytest-asyncio==0.12.0
Expand Down
Loading