File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed
Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ def get_post_detail(self):
4040 return
4141 result = session .exec (
4242 select (BlogPostModel ).where (
43- BlogPostModel .id == self .blog_post_id
43+ ( BlogPostModel .id == self .blog_post_id )
4444 )
4545 ).one_or_none ()
4646 self .post = result
@@ -52,11 +52,18 @@ def get_post_detail(self):
5252 # return
5353
5454
55-
56- def load_posts (self ):
55+ def load_posts (self , published_only = False ):
56+ lookup_args = ()
57+ if published_only :
58+ lookup_args = (
59+ (BlogPostModel .publish_active == True ) &
60+ (BlogPostModel .publish_date < datetime .now ())
61+ )
5762 with rx .session () as session :
5863 result = session .exec (
59- select (BlogPostModel )
64+ select (BlogPostModel ).where (
65+ * lookup_args
66+ )
6067 ).all ()
6168 self .posts = result
6269 # return
You can’t perform that action at this time.
0 commit comments