-
-
Notifications
You must be signed in to change notification settings - Fork 730
[16.0][ADD] website_blog_scheduled_publication: add new module #1159
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
base: 16.0
Are you sure you want to change the base?
[16.0][ADD] website_blog_scheduled_publication: add new module #1159
Conversation
|
@marcelsavegnago I guess you could take a similar approach as https://github.com/OCA/e-commerce/blob/15.0/website_sale_product_publish_date/models/product_template.py? I think there could even be a generic module with a mixin model which can be inherited by regular models if it fits the core architecture (I haven't taken a thorough look on it). |
bb858c1 to
90b624b
Compare
@yostashiro You’re right — that approach looks like a solid reference point. For now I’m handling a very specific case to solve the immediate need, but once I have a bit more time I’ll take a closer look and see if we can support a more generic solution (like a mixin / small reusable module) that fits well with the core architecture. |
aa545a8 to
faa9210
Compare
c4dce31 to
d06c485
Compare
e03ecbc to
6303ae2
Compare
ivs-cetmix
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for you contribution!
Some note - not an issue - how about adding a calendar view for the blog.post model so it would be easier to see the scheduled posts?
| """Check if post has a future scheduled date.""" | ||
| if post.scheduled_publication_date and post.scheduled_publication_date > now: | ||
| return True | ||
| scheduled_date = _to_datetime(vals.get("scheduled_publication_date")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question: isn't scheduled_publication_date a Python datetime object already?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. When accessed from a record (post.scheduled_publication_date), it's already a datetime object. However, vals.get("scheduled_publication_date") can be a string when values come from forms, wizards, or API calls.
The _to_datetime() helper handles both cases safely — it converts strings to datetime and passes through datetime objects unchanged.
We're open to suggestions if you have a better approach.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noted, let's leave as is for now. Would be good to add some comment in the code though to avoid same question in the future.
11510fa to
ec379a3
Compare
ivs-cetmix
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code review LGTM
Summary
This PR adds a new module
website_blog_scheduled_publicationthat allows users to schedule blog posts for automatic publication at a specific date and time.Features
Technical Details
blog.postmodel with new fields (scheduled_publication_date,schedule_type,next_departure) and methodsblog.post.schedule.datefor the scheduling wizardwebsite_blogDependencies
website_blogTest Plan
pytest website_blog_scheduled_publication/tests/