Skip to content

Feature/messege to share #269

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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
9f12429
adding func to create new event
Jan 25, 2021
83a3f7d
fix linit (except the start of endpoint)
Jan 25, 2021
5e3035b
more fix of linit
Jan 25, 2021
11f89d5
and more linit
Jan 26, 2021
d97d751
delete long line
Jan 26, 2021
1d54aa2
add test for bad new event
Jan 26, 2021
5ec2490
linit fix
Jan 26, 2021
b96f5db
add tests for exception
Jan 26, 2021
fe6eff0
linit
Jan 26, 2021
010bb8b
change check_validation to check_date_validation
Jan 27, 2021
6d876a9
Merge branch 'develop' into develop
Michael-B-D Jan 27, 2021
0591114
linit
Jan 27, 2021
6ce4ad8
Merge branch 'develop' of https://github.com/PythonFreeCourse/calenda…
Jan 27, 2021
86720df
Merge branch 'develop' of https://github.com/Michael-B-D/calendar int…
Jan 27, 2021
538450d
linit
Jan 27, 2021
425462a
add more tests
Jan 27, 2021
54f7eb7
use return early in event.py
Jan 29, 2021
19923eb
delete line
Jan 29, 2021
fb4a125
Merge branch 'develop' of https://github.com/PythonFreeCourse/calenda…
Jan 29, 2021
f498b0f
/
Jan 29, 2021
6438198
pull
Jan 29, 2021
7020d75
delete whitespace
Jan 29, 2021
0b46709
add else
Feb 1, 2021
1e8b415
Merge branch 'develop' of https://github.com/PythonFreeCourse/calenda…
Feb 1, 2021
8bc524a
add logger
Feb 1, 2021
624fb40
lint
Feb 1, 2021
986d056
/
Feb 1, 2021
3f10db9
line
Feb 1, 2021
4f03231
Merge branch 'develop' of https://github.com/PythonFreeCourse/calenda…
Feb 2, 2021
8b41b4d
update
Feb 2, 2021
dfbb0e0
.
Feb 3, 2021
8b9e415
.
Feb 3, 2021
9a2d80d
linit
Feb 3, 2021
8c3f9ed
try to fix linit
Feb 5, 2021
80ce83d
try agein
Feb 5, 2021
8f6dff3
linit
Feb 5, 2021
c5da8e8
remove vc_link from tests
Feb 5, 2021
07b423c
change func is_date_before name
Feb 5, 2021
0b9fd43
.
Feb 5, 2021
b490663
.
Feb 5, 2021
a565433
moving test to test_event
Feb 6, 2021
f3dd91a
linit
Feb 6, 2021
522d68b
add venv to gitignore
Feb 8, 2021
c07fcdc
remove venv
Feb 8, 2021
c0c4033
Merge branch 'develop' of https://github.com/PythonFreeCourse/calenda…
Feb 8, 2021
c9c08bc
LINIT
Feb 8, 2021
b455f73
/
Feb 8, 2021
593d612
/
Feb 8, 2021
860a8e1
add claint in test app
Feb 8, 2021
2606920
/
Feb 8, 2021
b28d1ac
/
Feb 8, 2021
5f222ad
.
Feb 8, 2021
be7279c
separat vc link and location
Feb 11, 2021
4c5d7b8
Merge branch 'develop' of https://github.com/PythonFreeCourse/calenda…
Feb 11, 2021
c7a2d04
add html format and func in event.py
Feb 12, 2021
fd0f61d
correct the html name
Feb 12, 2021
b6b5463
the test is raning add comment
Feb 12, 2021
9a9bc7b
LINIT
Feb 12, 2021
13fa6ae
lint again
Feb 12, 2021
d1d44c4
/
Feb 12, 2021
7314224
add css to the html
Feb 12, 2021
b12aa0e
delete som css
Feb 12, 2021
e9750d8
Merge branch 'develop' of https://github.com/PythonFreeCourse/calenda…
Feb 13, 2021
e17cbe4
Merge branch 'develop' of https://github.com/PythonFreeCourse/calenda…
Feb 14, 2021
31e6432
add evt to fonc in test_event
Feb 14, 2021
776e693
rm pytes - unused
Feb 14, 2021
bd2c1ae
add labaels andsend class object to html
Feb 14, 2021
978f289
Merge branch 'develop' of https://github.com/PythonFreeCourse/calenda…
Feb 14, 2021
32c34df
change font size insted of HTML elemnt
Feb 15, 2021
4817b1f
Merge branch 'develop' of https://github.com/PythonFreeCourse/calenda…
Feb 16, 2021
3407104
add css file for share event
Feb 16, 2021
a3ca76f
Merge branch 'develop' of https://github.com/PythonFreeCourse/calenda…
Feb 17, 2021
054f0d4
add css for subtitle and link to register
Feb 17, 2021
b2e6588
lint
Feb 17, 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
22 changes: 22 additions & 0 deletions app/routers/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,28 @@ def add_new_event(values: dict, db: Session) -> Optional[Event]:
return None


def get_template_to_share_event(event_id: int, user_name: str,
db: Session, request: Request) -> templates:
"""Gives shareable template of the event.

Args:
event_id: Event to share
user_name: The user who shares the event
db: The database to get the event from
request: The request we got from the user using FastAPI.

Returns:
Shareable HTML with data from the database about the event.
"""

event = by_id(db, event_id)
msg_info = {"sender_name": user_name, "event": event}
html_temp = templates.TemplateResponse("event/share_event.html",
{"request": request,
"msg_info": msg_info})
return html_temp


@router.post("/{event_id}")
async def add_comment(request: Request, event_id: int,
session: Session = Depends(get_db)) -> Response:
Expand Down
11 changes: 11 additions & 0 deletions app/static/share_event.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.msg_title{
font-size: 1.5rem;
}

.share_event{
width: 30rem;
}

.card-subtitle{
font-weight: 600;
}
40 changes: 40 additions & 0 deletions app/templates/event/share_event.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta1/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-giJF6kkoqNQ00vy+HMDP7azOuL0xtbfIcaT9wjKHr8RbDVddVHyTfAAsrekwKmP1" crossorigin="anonymous">
<link href="/app/static/share_event.css" rel="stylesheet">

</head>
<body>
<div class="share_event card">
<p class="msg_title">Hi!</p>
<p class="card-subtitle mb-2 text-muted">{{ msg_info.sender_name }} want you to know about event he have,</p>
<div class="event_info card-body">
<div>
The event {{ msg_info.event.title }}
</div>
<div>
will take place from {{ msg_info.event.start_date }} until {{ msg_info.event.end_date }}
</div>
<div>
{% if msg_info.event.location is not none %}
in {{ msg_info.event.location }}
{% endif %}
{% if msg_info.event.vc_link is not none %}
<a href="{{ msg_info.event.vc_link }}" class="card-link">Link to vc here</a>
{% endif %}
<!-- TODO get link to the event -->
<!-- <p>See the event <a href="--" class="card-link">here</a> </p> -->
</div>
<div class="card-footer text-muted">
This app was built by <a href="https://github.com/PythonFreeCourse" class="card-link">"PythonFreeCourse"</a>
<a href="/app/templates/register.html" class="card-link">Join the app!</a>
</div>
</div>
</div>
</body>
1 change: 1 addition & 0 deletions tests/event_fixture.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def event(sender: User, category: Category, session: Session) -> Event:
content='test event',
owner_id=sender.id,
location="Some random location",
vc_link=None,
category_id=category.id,
)

Expand Down
9 changes: 8 additions & 1 deletion tests/test_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
import json
import pytest

from fastapi import HTTPException
from fastapi import HTTPException, Request
from fastapi.testclient import TestClient
from sqlalchemy.orm.session import Session
from starlette import status


from app.database.models import Comment, Event
from app.dependencies import get_db
from app.internal.utils import delete_instance
Expand Down Expand Up @@ -424,6 +425,12 @@ def test_deleting_an_event_does_not_exist(event_test_client, event):
assert response.status_code == status.HTTP_404_NOT_FOUND


def test_get_tamplate_to_share_event(event, session):
html_template = evt.get_template_to_share_event(
event_id=1, user_name='michael', db=session, request=Request.get)
assert html_template is not None


def test_add_comment(event_test_client: TestClient, session: Session,
event: Event) -> None:
assert session.query(Comment).first() is None
Expand Down