-
-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] pms_api_rest: add rss_post service, datamodel and add feed_rss …
…module in pms_api_rest depends
- Loading branch information
1 parent
0440003
commit 7708b04
Showing
5 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from marshmallow import fields | ||
|
||
from odoo.addons.datamodel.core import Datamodel | ||
|
||
|
||
class FeedPost(Datamodel): | ||
_name ="feed.post.info" | ||
postId = fields.String(required=True, allow_none=False) | ||
title = fields.String(required=True, allow_none=False) | ||
link = fields.String(required=True, allow_none=False) | ||
description = fields.String(required=True, allow_none=False) | ||
publishDate = fields.String(required=True, allow_none=False) | ||
author = fields.String(required=True, allow_none=False) | ||
imageUrl = fields.String(required=True, allow_none=False) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
from odoo.addons.base_rest import restapi | ||
from odoo.addons.base_rest_datamodel.restapi import Datamodel | ||
from odoo.addons.component.core import Component | ||
|
||
|
||
class PmsFeedRss(Component): | ||
_inherit = "base.rest.service" | ||
_name = "pms.feed.rss.service" | ||
_usage = "feed-posts" | ||
_collection = "pms.services" | ||
|
||
@restapi.method( | ||
[ | ||
( | ||
[ | ||
"/", | ||
], | ||
"GET", | ||
) | ||
], | ||
output_param=Datamodel("feed.post.info", is_list=True), | ||
auth="jwt_api_pms", | ||
) | ||
def get_feed_posts(self): | ||
result_rss = [] | ||
PmsFeedRss = self.env.datamodels["feed.post.info"] | ||
for rss in self.env["rss.post"].search([], limit=5, order='publish_date desc'): | ||
result_rss.append( | ||
PmsFeedRss( | ||
postId=rss.post_id, | ||
title=rss.title, | ||
link=rss.link, | ||
description=rss.description, | ||
publishDate=str(rss.publish_date), | ||
author=rss.author if rss.author else "", | ||
imageUrl=rss.image_url if rss.image_url else "", | ||
) | ||
) | ||
return result_rss |