diff --git a/addons/itsulu_blog_publisher/data/mail_template_data.xml b/addons/itsulu_blog_publisher/data/mail_template_data.xml index 69ed9ab..5d23285 100644 --- a/addons/itsulu_blog_publisher/data/mail_template_data.xml +++ b/addons/itsulu_blog_publisher/data/mail_template_data.xml @@ -5,111 +5,54 @@ Blog Publisher — Post Published Notification - [${object.blog_post_id.blog_id.name or 'ITSulu Insights'}] Blog Post Published: ${object.blog_post_id.name or 'New Post'} - ${format_date(object.create_date, date_format='MMMM dd, yyyy')} + Blog Post Published: ${object.blog_post_id.name or 'New Post'} ${user.email_formatted} True +
-

Today's ${object.blog_post_id.blog_id.name or 'ITSulu Insights'} Blog Post Published

+

Blog Post Published

-

Date: ${format_date(object.create_date, date_format='MMMM dd, yyyy (EEEE)')}

-

Title: ${object.blog_post_id.name or ''}

- % set post_url = object.blog_post_id.website_url and ('https://itsulu.com' + object.blog_post_id.website_url) or '' -

URL: ${post_url}

+

Title: ${object.blog_post_id.name or 'N/A'}

+

Blog: ${object.blog_post_id.blog_id.name or 'N/A'}

-

Post Details

-
    -
  • LLM Provider: ${object.llm_provider or ''} / ${object.llm_model or ''}
  • -
  • Tokens Used: ${object.tokens_used or 0}
  • -
  • Generation Time: ${'{:.1f}'.format(object.duration_seconds or 0)}s
  • -
  • Tags: - % for tag in object.blog_post_id.tag_ids: - ${tag.name}${' | ' if not loop.last else ''} - % endfor -
  • -
  • Publication Status: ${'Published' if object.blog_post_id.is_published else 'Draft'}
  • -
  • Blog: ${object.blog_post_id.blog_id.name or ''}
  • -
+

Social Media Posts — Ready to Post

- % set social = object.blog_post_id.itsulu_social_id - % if social + % for social in object.blog_post_id.itsulu_social_id: -

Social Media Posts — Ready to Post

- -
- - % if social.twitter_enabled and (social.twitter_post_a or social.twitter_post_b) -

🐦 X (Twitter) Post A:

-

- ${social.twitter_post_a or ''} -

- -

🐦 X (Twitter) Post B:

-

- ${social.twitter_post_b or ''} -

+ % if social.twitter_post_a or social.twitter_post_b: +

Twitter

+ % if social.twitter_post_a: +

Post A: ${social.twitter_post_a}

+ % endif + % if social.twitter_post_b: +

Post B: ${social.twitter_post_b}

+ % endif % endif -
- - % if social.bluesky_enabled and (social.bluesky_post_a or social.bluesky_post_b) -

🌐 BlueSky Posts:

-

- BlueSky A:
- ${social.bluesky_post_a or ''} -

-

- BlueSky B:
- ${social.bluesky_post_b or ''} -

+ % if social.bluesky_post_a or social.bluesky_post_b: +

BlueSky

+ % if social.bluesky_post_a: +

Post A: ${social.bluesky_post_a}

+ % endif + % if social.bluesky_post_b: +

Post B: ${social.bluesky_post_b}

+ % endif % endif -
- - % if social.mastodon_enabled and social.mastodon_post -

🦣 Fediverse/Mastodon Post:

-

- ${social.mastodon_post or ''} -

+ % if social.mastodon_post: +

Mastodon

+

${social.mastodon_post}

% endif -
- - % if social.linkedin_enabled and social.linkedin_post -

💼 LinkedIn Post:

-

- ${social.linkedin_post or ''} -

+ % if social.linkedin_post: +

LinkedIn

+

${social.linkedin_post}

% endif - % if social.sources_referenced -
-

News Sources Referenced:

-
    - % for line in (social.sources_referenced or '').splitlines(): - % if line.strip() - % set parts = line.split(' — ', 1) - % if parts|length == 2 -
  • ${parts[0].strip()}
  • - % else -
  • ${line.strip()}
  • - % endif - % endif - % endfor -
- % endif +

URL: https://itsulu.com${object.blog_post_id.website_url or ''}

- % endif - -
- -

- Generated: ${format_date(object.create_date, date_format='MMMM dd, yyyy')} | - Service: ITSulu Blog Publisher
- This email contains all social media post variations ready for posting - across X, BlueSky, Fediverse, and LinkedIn. -

+ % endfor
]]>
diff --git a/addons/itsulu_blog_publisher/models/__init__.py b/addons/itsulu_blog_publisher/models/__init__.py index 9b83b3b..5d8f7bb 100644 --- a/addons/itsulu_blog_publisher/models/__init__.py +++ b/addons/itsulu_blog_publisher/models/__init__.py @@ -2,6 +2,7 @@ """ itsulu_blog_publisher models. """ +from . import blog_post from . import blog_topic from . import blog_schedule from . import blog_generation_log @@ -9,6 +10,7 @@ from . import blog_post_social from . import res_config_settings __all__ = [ + 'blog_post', 'blog_topic', 'blog_schedule', 'blog_generation_log', diff --git a/addons/itsulu_blog_publisher/models/blog_post.py b/addons/itsulu_blog_publisher/models/blog_post.py new file mode 100644 index 0000000..1b78fad --- /dev/null +++ b/addons/itsulu_blog_publisher/models/blog_post.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +""" +Extend blog.post to add reverse relationship to itsulu.blog.post.social. +""" +from odoo import fields, models + + +class BlogPost(models.Model): + _inherit = 'blog.post' + + itsulu_social_id = fields.One2many( + comodel_name='itsulu.blog.post.social', + inverse_name='blog_post_id', + string='Social Media Copy', + help='Social media copy generated for this post.', + ) + + def get_social_copy(self): + """Return the single social copy record, or False if none exists.""" + self.ensure_one() + return self.itsulu_social_id[0] if self.itsulu_social_id else False