Skip to content

Commit

Permalink
prep comments
Browse files Browse the repository at this point in the history
  • Loading branch information
dternyak committed Sep 30, 2018
1 parent 5d3b19b commit ab9fac7
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions api/user/views.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
from typing import List, Tuple, Optional
from typing import List, Tuple, Optional, Any

from molten import (
HTTP_404, HTTPError, schema, Field, HTTP_201, HTTP_204
HTTP_404, HTTPError, schema, Field, HTTP_201, HTTP_204,
)
from molten.contrib.sqlalchemy import (
Session
)

from .models import User

# from ..comment.views import CommentSchema

@schema
class UserSchema:
id: int = Field(response_only=True)
email_address: Optional[str]
display_name: Optional[str]
title: Optional[str]
# comments: List[CommentSchema]


def list_users(session: Session) -> List[UserSchema]:
Expand All @@ -25,7 +26,8 @@ def list_users(session: Session) -> List[UserSchema]:
id=ob.id,
email_address=ob.email_address,
display_name=ob.display_name,
title=ob.title
title=ob.title,
# comments=ob.comments
) for ob in user_obs
]

Expand All @@ -40,6 +42,7 @@ def create_user(user: UserSchema, session: Session) -> Tuple[str, UserSchema]:
session.flush()

user.id = user_ob.id
# user.comments = user_ob.comments
return HTTP_201, user


Expand All @@ -57,5 +60,6 @@ def get_user(user_id: int, session: Session) -> UserSchema:
id=ob.id,
email_address=ob.email_address,
display_name=ob.display_name,
title=ob.title
title=ob.title,
# comments=ob.comments
)

0 comments on commit ab9fac7

Please sign in to comment.