Delete metadata.jsonl
Browse files- metadata.jsonl +0 -38
metadata.jsonl
DELETED
@@ -1,38 +0,0 @@
|
|
1 |
-
{"file_name": "94977984-81b4-474d-8739-ae37897c0939.png", "code": "def create_like(session: Session, activity: CreateActivity) -> Like:\r\n with session() as db:\r\n like: Like = Like(\r\n author_id=activity.user_id,\r\n post_id=activity.post_id\r\n )\r\n db.add(like)\r\n db.commit()\r\n db.refresh(like)\r\n return like"}
|
2 |
-
{"file_name": "66166aa0-8b0e-4ea6-b35c-942dd167fe09.png", "code": "def create_like(session: Session, activity: CreateActivity) -> Like:\r\n with session() as db:\r\n like: Like = Like(\r\n author_id=activity.user_id,\r\n post_id=activity.post_id\r\n )\r\n db.add(like)\r\n db.commit()\r\n db.refresh(like)\r\n return like"}
|
3 |
-
{"file_name": "214cccaa-a48a-458c-9143-1808d6214029.png", "code": "def create_like(session: Session, activity: CreateActivity) -> Like:\r\n with session() as db:\r\n like: Like = Like(\r\n author_id=activity.user_id,\r\n post_id=activity.post_id\r\n )\r\n db.add(like)\r\n db.commit()\r\n db.refresh(like)\r\n return like"}
|
4 |
-
{"file_name": "d895922a-a590-4ce0-9306-5bceaadcb047.png", "code": "def create_like(session: Session, activity: CreateActivity) -> Like:\r\n with session() as db:\r\n like: Like = Like(\r\n author_id=activity.user_id,\r\n post_id=activity.post_id\r\n )\r\n db.add(like)\r\n db.commit()\r\n db.refresh(like)\r\n return like"}
|
5 |
-
{"file_name": "35862378-8b62-40c0-832c-3b91946265ab.png", "code": "def create_like(session: Session, activity: CreateActivity) -> Like:\r\n with session() as db:\r\n like: Like = Like(\r\n author_id=activity.user_id,\r\n post_id=activity.post_id\r\n )\r\n db.add(like)\r\n db.commit()\r\n db.refresh(like)\r\n return like"}
|
6 |
-
{"file_name": "6117b2bb-fd83-46e1-a589-703b0f419eaa.png", "code": "def delete_like(session: Session, activity: CreateActivity) -> Like:\r\n with session() as db:\r\n like: Like = db.query(Like).filter(Like.author_id==activity.user_id, Like.post_id==activity.post_id).first()\r\n db.delete(like)\r\n db.commit()\r\n return like\r\n\r\ndef has_liked(session: Session, activity: CreateActivity) -> Like:\r\n with session() as db:\r\n like: Like = db.query(Like).filter(Like.author_id==activity.user_id, Like.post_id==activity.post_id).first()\r\n if like:\r\n return True\r\n return False"}
|
7 |
-
{"file_name": "6b4ff6ca-456c-478b-94f4-d0b8f23ed2ad.png", "code": "def list_user_likes(session: Session, user_data: GetUser) -> list[Like]:\r\n with session() as db:\r\n user: User = db.query(User).filter(User.id == user_data.user_id).first()\r\n likes: list[Like] = user.likes\r\n return likes\r\n\r\ndef list_post_likes(session: Session, post_data: GetPost):\r\n with session() as db:\r\n post: Post = db.query(Post).filter(Post.id == post_data.post_id).first()\r\n likes: list[Like] = post.likes\r\n for like in likes:\r\n like.author\r\n return likes\r\n\r\ndef get_key_like(session: Session, post_data: GetPost):\r\n from random import choice\r\n with session() as db:\r\n post: Post = db.query(Post).filter(Post.id == post_data.post_id).first()\r\n likes: list[Like] = post.likes\r\n for like in likes:\r\n like.author\r\n return choice(likes).author if likes else None"}
|
8 |
-
{"file_name": "4d14a5de-ff1a-4a7e-8c0d-659dcb31d750.png", "code": "def list_user_likes(session: Session, user_data: GetUser) -> list[Like]:\r\n with session() as db:\r\n user: User = db.query(User).filter(User.id == user_data.user_id).first()\r\n likes: list[Like] = user.likes\r\n return likes\r\n\r\ndef list_post_likes(session: Session, post_data: GetPost):\r\n with session() as db:\r\n post: Post = db.query(Post).filter(Post.id == post_data.post_id).first()\r\n likes: list[Like] = post.likes\r\n for like in likes:\r\n like.author\r\n return likes\r\n\r\ndef get_key_like(session: Session, post_data: GetPost):\r\n from random import choice\r\n with session() as db:\r\n post: Post = db.query(Post).filter(Post.id == post_data.post_id).first()\r\n likes: list[Like] = post.likes\r\n for like in likes:\r\n like.author\r\n return choice(likes).author if likes else None"}
|
9 |
-
{"file_name": "20caf41f-9ce4-4875-a023-aee89b324ea0.png", "code": "from sqlalchemy.orm import Session\r\nfrom ..models.post import Post\r\nfrom ..schemas.post import (\r\n CreatePost, GetPosts, GetPost, UpdatePost\r\n)\r\nfrom werkzeug.datastructures import FileStorage\r\nfrom flask import current_app\r\nfrom uuid import uuid4\r\nfrom werkzeug.utils import secure_filename\r\nimport os\r\nimport secrets\r\nfrom typing import Callable"}
|
10 |
-
{"file_name": "ea28d015-0623-4cea-a437-a5b2af247dbb.png", "code": "ALLOWED_EXTENSIONS = {'png', 'jpg', 'jpeg', 'gif'}\r\n\r\ndef get_file_extension(filename: str) -> str:\r\n if '.' in filename and filename.rsplit('.', 1)[1].lower():\r\n return filename.rsplit('.', 1)[1].lower()\r\n return ''\r\n\r\ndef allowed_file(filename: str) -> bool:\r\n file_extension: str = get_file_extension(filename)\r\n if file_extension and file_extension in ALLOWED_EXTENSIONS:\r\n return True\r\n return False\r\n\r\n\r\ndef save_post_photo_locally(post_image: dict) -> None:\r\n \"\"\"Save the uploadeded post image.\"\"\"\r\n file: FileStorage = post_image['post_image']\r\n upload_folder = os.path.join(current_app.root_path, 'static', 'img')\r\n if file and allowed_file(file.filename):\r\n filename = f'{secrets.token_hex(8)}.{get_file_extension(file.filename)}' \r\n # Use celery task\r\n file.save(os.path.join(upload_folder, filename))\r\n return filename\r\n return ''"}
|
11 |
-
{"file_name": "c9adde79-584b-47ba-ae7c-91f2a12ee0cb.png", "code": "def save_post_photo_aws_s3(post_image: dict) -> None:\r\n \"\"\"Save the uploadeded post image.\"\"\"\r\n file: FileStorage = post_image['post_image']\r\n if file and allowed_file(file.filename):\r\n filename = f'{secrets.token_hex(8)}.{get_file_extension(file.filename)}'\r\n # Use celery task\r\n return filename\r\n return ''\r\n\r\ndef no_save_post_photo(post_image: dict) -> None:\r\n \"\"\"Save the uploadeded post image.\"\"\"\r\n file: FileStorage = post_image['post_image']\r\n if file and allowed_file(file.filename):\r\n filename = f'{secrets.token_hex(8)}.{get_file_extension(file.filename)}'\r\n return filename\r\n return ''\r\n\r\n\r\ndef save_post_photo(post_image: dict, save_location: str = '') -> str:\r\n \"\"\"Save the uploadeded post image.\"\"\"\r\n save_photo_funcs: dict[str, Callable[[dict], str]] = {\r\n 'locally': save_post_photo_locally,\r\n 'aws_s3': save_post_photo_aws_s3,\r\n 'default': no_save_post_photo\r\n }\r\n if save_photo_funcs.get(save_location):\r\n filename: str = save_photo_funcs[save_location](post_image)\r\n else:\r\n filename: str = save_photo_funcs['default'](post_image)\r\n return filename"}
|
12 |
-
{"file_name": "b344b10d-8a13-46e1-ae86-5bdf5fae917f.png", "code": "def create_post(post_data: CreatePost, post_image: dict, session: Session):\r\n post_image_url: str = save_post_photo(post_image)\r\n post: Post = Post(\r\n id='Post_' + str(uuid4()),\r\n author_id=post_data.author_id,\r\n location=post_data.location,\r\n text=post_data.text,\r\n image_url=post_image_url\r\n )\r\n with session() as db:\r\n db.add(post)\r\n db.commit()\r\n db.refresh(post)\r\n return post"}
|
13 |
-
{"file_name": "889441e8-6314-4628-b0c0-f6e3115f951a.png", "code": "def create_post(post_data: CreatePost, post_image: dict, session: Session):\r\n post_image_url: str = save_post_photo(post_image)\r\n post: Post = Post(\r\n id='Post_' + str(uuid4()),\r\n author_id=post_data.author_id,\r\n location=post_data.location,\r\n text=post_data.text,\r\n image_url=post_image_url\r\n )\r\n with session() as db:\r\n db.add(post)\r\n db.commit()\r\n db.refresh(post)\r\n return post"}
|
14 |
-
{"file_name": "a4f6995c-8ab2-400a-bbdb-5cc6757d638d.png", "code": "def create_post(post_data: CreatePost, post_image: dict, session: Session):\r\n post_image_url: str = save_post_photo(post_image)\r\n post: Post = Post(\r\n id='Post_' + str(uuid4()),\r\n author_id=post_data.author_id,\r\n location=post_data.location,\r\n text=post_data.text,\r\n image_url=post_image_url\r\n )\r\n with session() as db:\r\n db.add(post)\r\n db.commit()\r\n db.refresh(post)\r\n return post"}
|
15 |
-
{"file_name": "b0558326-bfc4-4a67-8f1f-783c927f87ba.png", "code": "def create_post(post_data: CreatePost, post_image: dict, session: Session):\r\n post_image_url: str = save_post_photo(post_image)\r\n post: Post = Post(\r\n id='Post_' + str(uuid4()),\r\n author_id=post_data.author_id,\r\n location=post_data.location,\r\n text=post_data.text,\r\n image_url=post_image_url\r\n )\r\n with session() as db:\r\n db.add(post)\r\n db.commit()\r\n db.refresh(post)\r\n return post"}
|
16 |
-
{"file_name": "2a9a7201-5c02-448e-af76-4ca708d67d23.png", "code": "def create_post(post_data: CreatePost, post_image: dict, session: Session):\r\n post_image_url: str = save_post_photo(post_image)\r\n post: Post = Post(\r\n id='Post_' + str(uuid4()),\r\n author_id=post_data.author_id,\r\n location=post_data.location,\r\n text=post_data.text,\r\n image_url=post_image_url\r\n )\r\n with session() as db:\r\n db.add(post)\r\n db.commit()\r\n db.refresh(post)\r\n return post"}
|
17 |
-
{"file_name": "f010a565-b8f6-4a0c-ad90-7a50eb13c249.png", "code": "def update_post(post_data: UpdatePost, post_image: dict, session: Session):\r\n post_image_url: str = save_post_photo(post_image)\r\n with session() as db:\r\n post: Post = db.query(Post).filter(Post.id == post_data.post_id).first()\r\n if post_data.location:\r\n post.location = post_data.location\r\n if post_data.text:\r\n post.text = post_data.text\r\n if post_image_url:\r\n post.image_url = post_image_url\r\n db.commit()\r\n db.refresh(post)\r\n return post\r\n\r\ndef get_post(session: Session, post_data: GetPost):\r\n with session() as db:\r\n post = db.query(Post).filter(Post.id == post_data.post_id).first()\r\n return post"}
|
18 |
-
{"file_name": "3668a7ea-5d72-42a8-b26c-bafba9f327cd.png", "code": "def get_posts(session: Session, post_data: GetPosts):\r\n with session() as db:\r\n posts: list[Post] = db.query(Post).offset(post_data.offset).limit(post_data.limit).all()\r\n for post in posts:\r\n post.author\r\n return posts\r\n\r\ndef delete_post(session: Session, post_data: GetPost):\r\n with session() as db:\r\n post = db.query(Post).filter(Post.id == post_data.post_id).first()\r\n db.delete(post)\r\n db.commit()\r\n \r\n return post"}
|
19 |
-
{"file_name": "8bd9a171-5d31-41c0-8963-c49cda7ee71d.png", "code": "def get_posts(session: Session, post_data: GetPosts):\r\n with session() as db:\r\n posts: list[Post] = db.query(Post).offset(post_data.offset).limit(post_data.limit).all()\r\n for post in posts:\r\n post.author\r\n return posts\r\n\r\ndef delete_post(session: Session, post_data: GetPost):\r\n with session() as db:\r\n post = db.query(Post).filter(Post.id == post_data.post_id).first()\r\n db.delete(post)\r\n db.commit()\r\n \r\n return post"}
|
20 |
-
{"file_name": "edba516f-516e-41d9-9d2f-7c788785b717.png", "code": "def get_posts(session: Session, post_data: GetPosts):\r\n with session() as db:\r\n posts: list[Post] = db.query(Post).offset(post_data.offset).limit(post_data.limit).all()\r\n for post in posts:\r\n post.author\r\n return posts\r\n\r\ndef delete_post(session: Session, post_data: GetPost):\r\n with session() as db:\r\n post = db.query(Post).filter(Post.id == post_data.post_id).first()\r\n db.delete(post)\r\n db.commit()\r\n \r\n return post"}
|
21 |
-
{"file_name": "8a7cc60c-3f28-4fb6-81d6-535d7cdde5df.png", "code": "from ..schemas.user import UserCreate\r\nfrom sqlalchemy.orm import Session\r\nfrom ....extensions.extensions import bcrypt\r\nfrom ..models.user import User\r\nfrom ..schemas.user import User as Userschemas\r\nfrom ..schemas.user import (\r\n GetUser, GetUsers, ActivateUser, LoginUser, RequestPasswordReset, PasswordReset\r\n)\r\nfrom typing import Optional\r\nfrom jwt import ExpiredSignatureError, InvalidTokenError\r\nfrom uuid import uuid4\r\nfrom typing import Callable"}
|
22 |
-
{"file_name": "14f6a2a5-e984-4021-9f59-ec8bcd7d5ebd.png", "code": "def send_email_local(user_email_address: str, message: str) -> None:\r\n pass\r\n\r\ndef send_email_aws_ses(user_email_address: str, message: str) -> None:\r\n pass\r\n\r\ndef send_account_activation_email(user_email_address: str, message: str) -> None:\r\n pass\r\n\r\ndef send_password_reset_email(user_email_address: str, message: str) -> None:\r\n pass\r\n\r\ndef generate_account_activation_email(message: str) -> None:\r\n pass\r\n\r\ndef generate_password_reset_email(message: str) -> None:\r\n pass"}
|
23 |
-
{"file_name": "c6b7a3b6-1baf-44ea-888b-885f79aa62c8.png", "code": "def send_email_local(user_email_address: str, message: str) -> None:\r\n pass\r\n\r\ndef send_email_aws_ses(user_email_address: str, message: str) -> None:\r\n pass\r\n\r\ndef send_account_activation_email(user_email_address: str, message: str) -> None:\r\n pass\r\n\r\ndef send_password_reset_email(user_email_address: str, message: str) -> None:\r\n pass\r\n\r\ndef generate_account_activation_email(message: str) -> None:\r\n pass\r\n\r\ndef generate_password_reset_email(message: str) -> None:\r\n pass"}
|
24 |
-
{"file_name": "5b934805-79b7-4e7e-b776-ccdaf1c0ab59.png", "code": "def generate_email(user_email_address: str, email_type: str) -> str:\r\n email_types: dict[str, Callable] = {\r\n 'password_reset': send_password_reset_email,\r\n 'account_activation': send_account_activation_email\r\n }\r\n return email_types[email_type]\r\n\r\ndef send_email(user_email_address: str, email_sender: str) -> None:\r\n email_senders: dict[str, Callable] = {\r\n 'local': send_email_local,\r\n 'aws_ses': send_email_aws_ses\r\n }\r\n return email_sender[email_sender]"}
|
25 |
-
{"file_name": "680f1dde-379b-4424-ba03-6e91aa57d85d.png", "code": "def create_user(user_data: UserCreate, session: Session):\r\n hashed_password = User.hash_password(user_data.password)\r\n user = User(\r\n id='User_' + str(uuid4()),\r\n first_name=user_data.first_name,\r\n last_name=user_data.last_name,\r\n email_address=user_data.email_address,\r\n password=hashed_password\r\n )\r\n with session() as db:\r\n db.add(user)\r\n db.commit()\r\n db.refresh(user)\r\n return user\r\n\r\ndef get_user_by_email(session: Session, email: str):\r\n with session() as db:\r\n user = db.query(User).filter(User.email_address == email).first()\r\n return user"}
|
26 |
-
{"file_name": "346b7027-da81-442d-8b97-f14ffd644954.png", "code": "def get_random_user(session: Session):\r\n from random import choice\r\n with session() as db:\r\n user = choice(db.query(User).all())\r\n return user\r\n\r\ndef get_user(session: Session, user_data: GetUser):\r\n with session() as db:\r\n user = db.query(User).filter(User.id == user_data.user_id).first()\r\n return user\r\n\r\ndef get_users(session: Session, user_data: GetUsers):\r\n with session() as db:\r\n users = db.query(User).offset(user_data.offset).limit(user_data.limit).all()\r\n return users"}
|
27 |
-
{"file_name": "6d62e8bb-9325-4d04-a137-f61ea2a2e7f8.png", "code": "def delete_user(session: Session, user_data: GetUser):\r\n with session() as db:\r\n user = db.query(User).filter(User.id == user_data.user_id).first()\r\n db.delete(user)\r\n db.commit()\r\n \r\n return user\r\n\r\n\r\ndef user_account_active(session: Session, user_data: GetUser):\r\n with session() as db:\r\n user: User = db.query(User).filter(User.id == user_data.user_id).first()\r\n return user.activated"}
|
28 |
-
{"file_name": "f2e1847d-9018-4789-8ea5-f2256daeb8a2.png", "code": "def delete_user(session: Session, user_data: GetUser):\r\n with session() as db:\r\n user = db.query(User).filter(User.id == user_data.user_id).first()\r\n db.delete(user)\r\n db.commit()\r\n \r\n return user\r\n\r\n\r\ndef user_account_active(session: Session, user_data: GetUser):\r\n with session() as db:\r\n user: User = db.query(User).filter(User.id == user_data.user_id).first()\r\n return user.activated"}
|
29 |
-
{"file_name": "1f667095-97c3-4938-a1a2-1ed6ed57a2fd.png", "code": "def activate_user_account(session: Session, activation_data: ActivateUser):\r\n with session() as db:\r\n user: User = db.query(User).filter(User.id == activation_data.user_id).first()\r\n if user.id == User.decode_auth_token(activation_data.activation_token):\r\n user.activated = True\r\n db.commit()\r\n return True\r\n raise InvalidTokenError('Invalid or Expired token.')\r\n\r\n\r\ndef loggin_user(session: Session, login_data: LoginUser):\r\n with session() as db:\r\n user: User = db.query(User).filter(User.email_address == login_data.email_address).first()\r\n if user and user.check_password(login_data.password):\r\n return True\r\n raise ValueError('Invalid email address and or password.')\r\n"}
|
30 |
-
{"file_name": "572f77d2-f1d5-41e8-b6aa-4c7472c62ca3.png", "code": "def activate_user_account(session: Session, activation_data: ActivateUser):\r\n with session() as db:\r\n user: User = db.query(User).filter(User.id == activation_data.user_id).first()\r\n if user.id == User.decode_auth_token(activation_data.activation_token):\r\n user.activated = True\r\n db.commit()\r\n return True\r\n raise InvalidTokenError('Invalid or Expired token.')\r\n\r\n\r\ndef loggin_user(session: Session, login_data: LoginUser):\r\n with session() as db:\r\n user: User = db.query(User).filter(User.email_address == login_data.email_address).first()\r\n if user and user.check_password(login_data.password):\r\n return True\r\n raise ValueError('Invalid email address and or password.')\r\n"}
|
31 |
-
{"file_name": "41544d3f-b603-4392-a08d-1b2bedfb7e49.png", "code": "def generate_password_reset_token(session: Session, reset_password_request: RequestPasswordReset):\r\n with session() as db:\r\n user: User = db.query(User).filter(User.email_address == reset_password_request.email_address).first()\r\n resp = {\r\n 'user_id': user.id,\r\n 'email_address': user.email_address,\r\n 'password_reset_token': user.generate_password_reset_token()\r\n }\r\n return resp\r\n\r\n\r\ndef password_repeated(session: Session, password_reset: PasswordReset):\r\n with session() as db:\r\n user: User = db.query(User).filter(User.email_address == password_reset.email_address).first()\r\n return user.check_password(password_reset.password)"}
|
32 |
-
{"file_name": "7341b4b1-8719-4363-aa81-260d5b61e047.png", "code": "def reset_password(session: Session, password_reset: PasswordReset):\r\n with session() as db:\r\n user: User = db.query(User).filter(User.email_address == password_reset.email_address).first()\r\n email_address = user.decode_password_token(password_reset.password_reset_token)\r\n if email_address == user.email_address:\r\n user.password = user.hash_password(password_reset.password)\r\n db.commit()\r\n return True"}
|
33 |
-
{"file_name": "2540dfa6-3610-48b7-b05d-7191443304dd.png", "code": "from ..schemas.activity import CreateActivity, GetRepeatableActivity\r\nfrom sqlalchemy.orm import Session\r\nfrom ..models.view import View\r\nfrom ..models.user import User\r\nfrom ..models.post import Post\r\nfrom ..schemas.user import GetUser\r\nfrom ..schemas.post import GetPost\r\nfrom uuid import uuid4\r\n\r\n\r\ndef create_view(session: Session, activity: CreateActivity) -> View:\r\n with session() as db:\r\n view: View = View(\r\n author_id=activity.user_id,\r\n post_id=activity.post_id,\r\n id='View_' + str(uuid4())\r\n )\r\n db.add(view)\r\n db.commit()\r\n db.refresh(view)\r\n return view"}
|
34 |
-
{"file_name": "5fd5ccd2-e48d-4dd8-979a-143e4525cefb.png", "code": "from ..schemas.activity import CreateActivity, GetRepeatableActivity\r\nfrom sqlalchemy.orm import Session\r\nfrom ..models.view import View\r\nfrom ..models.user import User\r\nfrom ..models.post import Post\r\nfrom ..schemas.user import GetUser\r\nfrom ..schemas.post import GetPost\r\nfrom uuid import uuid4\r\n\r\n\r\ndef create_view(session: Session, activity: CreateActivity) -> View:\r\n with session() as db:\r\n view: View = View(\r\n author_id=activity.user_id,\r\n post_id=activity.post_id,\r\n id='View_' + str(uuid4())\r\n )\r\n db.add(view)\r\n db.commit()\r\n db.refresh(view)\r\n return view"}
|
35 |
-
{"file_name": "22bf19c1-2192-40b6-bb33-df081156930d.png", "code": "def has_viewed(session: Session, activity: CreateActivity) -> View:\r\n with session() as db:\r\n view: View = db.query(View).filter(View.author_id==activity.user_id, View.post_id==activity.post_id).first()\r\n if view:\r\n return True\r\n return False\r\n\r\ndef list_user_views(session: Session, user_data: GetUser) -> list[View]:\r\n with session() as db:\r\n user: User = db.query(User).filter(User.id == user_data.user_id).first()\r\n views: list[View] = user.views\r\n return views\r\n\r\ndef list_post_views(session: Session, post_data: GetPost):\r\n with session() as db:\r\n post: Post = db.query(Post).filter(Post.id == post_data.post_id).first()\r\n views: list[View] = post.views\r\n return views"}
|
36 |
-
{"file_name": "bec2d9f6-8daa-4666-9b10-e1eb52f5284a.png", "code": "from .user import User\r\nfrom .post import Post\r\nfrom .like import Like\r\nfrom .bookmark import Bookmark\r\nfrom .view import View\r\nfrom .view import View\r\nfrom .comment import Comment"}
|
37 |
-
{"file_name": "50f83148-75cd-4f84-b660-8ca15b0472be.png", "code": "from datetime import datetime\r\nfrom sqlalchemy.orm import Mapped, mapped_column, relationship\r\nfrom ..database import Base\r\nfrom sqlalchemy import ForeignKey\r\n\r\n\r\nclass Bookmark(Base):\r\n __tablename__ = 'bookmarks'\r\n \r\n author_id: Mapped[str] = mapped_column(ForeignKey('users.id'), primary_key=True)\r\n post_id: Mapped[str] = mapped_column(ForeignKey('posts.id'), primary_key=True)\r\n bookmark_date: Mapped[datetime] = mapped_column(default_factory=datetime.utcnow)\r\n \r\n author = relationship('User', back_populates='bookmarks')\r\n post = relationship('Post', back_populates='bookmarks')"}
|
38 |
-
{"file_name": "992a1593-7731-43c3-84e3-d0b41fd9e31e.png", "code": "from datetime import datetime\r\nfrom sqlalchemy.orm import Mapped, mapped_column, relationship\r\nfrom ..database import Base\r\nfrom sqlalchemy import ForeignKey\r\n\r\n\r\nclass Comment(Base):\r\n __tablename__ = 'comments'\r\n \r\n id: Mapped[str] = mapped_column(primary_key=True)\r\n author_id: Mapped[str] = mapped_column(ForeignKey('users.id'))\r\n post_id: Mapped[str] = mapped_column(ForeignKey('posts.id'))\r\n comment_text: Mapped[str]\r\n comment_date: Mapped[datetime] = mapped_column(default_factory=datetime.utcnow)\r\n \r\n author = relationship('User', back_populates='comments')\r\n post = relationship('Post', back_populates='comments')"}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|