Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 109 additions & 0 deletions notifications/templates/emails/multiple_choice_option_addition.mjml
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

placeholder content

Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
<mjml>
<mj-include path="../../../templates/emails/email_styles.mjml"/>

<mj-body>
<mj-include path="../../../templates/emails/email_top.mjml"/>

<mj-section background-color="#ffffff" padding-bottom="16px">
<mj-column>
<mj-text font-size="16px" color="#161C22" padding-bottom="0px">
Hello {{recipient.username}},
</mj-text>
</mj-column>
</mj-section>

<!-- All dynamic content in ONE section -->
<mj-section background-color="#ffffff" padding="0px">
<mj-column>
<mj-text padding="0px">
<!-- Tournament/Project Status Changes -->
{% if params.from_projects %}

<!-- Intro text for tournament changes -->
<div style="font-size: 15px; color: #161C22; margin: 0px 24px 8px 24px;">
{% blocktrans %}
These questions have changed status:
{% endblocktrans %}
</div>

{% for item in params.from_projects %}
{% if item.notifications %}

<div style="margin-bottom: 16px;">
<div style="background-color: #EFF4F4; border: 1px solid #D7E4F2; border-radius: 8px; padding: 16px; margin: 0px 24px;">
<!-- Project Header -->
<div style="font-size: 15px; color: #2F4155; margin-bottom: 12px;">
{% blocktrans with project_name=item.project.name %}
In <b>{{project_name}}</b>:
{% endblocktrans %}
</div>

<!-- Questions in this project -->
{% for notification in item.notifications %}
<div style="{% if not forloop.last %}margin-bottom: 8px;{% endif %}">
<a href="{% post_url notification.post.post_id notification.post.post_title notification.question.id notification.post.post_type %}"
style="display: block; text-decoration: none; color: inherit;">
<div style="background-color: #ffffff; border: 1px solid #E5E7EB; border-radius: 6px; padding: 12px;">
<div style="font-size: 14px; font-weight: 600; color: #161C22; line-height: 1.4; margin-bottom: 2px;">
{{ notification.question.title|default:notification.post.post_title }}
</div>
{% if notification.post.post_type != 'notebook' %}
<div style="font-size: 13px; font-weight: 600; color: #758EA9;">
is now {{ notification.event }}
</div>
{% endif %}
</div>
</a>
</div>
{% endfor %}
</div>
</div>

{% endif %}
{% endfor %}
{% endif %}

<!-- Regular Status Changes -->
{% if params.from_posts %}

<!-- Intro text -->
{% if params.from_projects %}
<div style="font-size: 15px; color: #161C22; margin: 0px 24px 8px 24px;">
{% blocktrans %}
In the rest of Metaculus:
{% endblocktrans %}
</div>
{% endif %}

<div style="font-size: 15px; color: #161C22; margin: 0px 24px 8px 24px;">
{% blocktrans with count=params.from_posts|length %}
These {{count}} questions have changed status:
{% endblocktrans %}
</div>

<!-- Question cards directly (no outer container) -->
{% for item in params.from_posts %}
<div style="margin: 0px 24px {% if not forloop.last %}8px{% else %}16px{% endif %} 24px;">
<a href="{% post_url item.post.post_id item.post.post_title item.question.id item.post.post_type %}"
style="display: block; text-decoration: none; color: inherit;">
<div style="background-color: #EFF4F4; border: 1px solid #D7E4F2; border-radius: 8px; padding: 12px;">
<div style="font-size: 14px; font-weight: 500; color: #161C22; line-height: 1.4; margin-bottom: 2px;">
{{ item.question.title|default:item.post.post_title }}
</div>
<div style="font-size: 13px; font-weight: 600; color: #758EA9;">
is now {{ item.event }}
</div>
</div>
</a>
</div>
{% endfor %}

{% endif %}
</mj-text>
</mj-column>
</mj-section>

<mj-include path="../../../templates/emails/email_similar_questions.mjml"/>
<mj-include path="../../../templates/emails/email_unsubscribe.mjml"/>
</mj-body>
</mjml>
109 changes: 109 additions & 0 deletions notifications/templates/emails/multiple_choice_option_deletion.mjml
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

placeholder content

Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
<mjml>
<mj-include path="../../../templates/emails/email_styles.mjml"/>

<mj-body>
<mj-include path="../../../templates/emails/email_top.mjml"/>

<mj-section background-color="#ffffff" padding-bottom="16px">
<mj-column>
<mj-text font-size="16px" color="#161C22" padding-bottom="0px">
Hello {{recipient.username}},
</mj-text>
</mj-column>
</mj-section>

<!-- All dynamic content in ONE section -->
<mj-section background-color="#ffffff" padding="0px">
<mj-column>
<mj-text padding="0px">
<!-- Tournament/Project Status Changes -->
{% if params.from_projects %}

<!-- Intro text for tournament changes -->
<div style="font-size: 15px; color: #161C22; margin: 0px 24px 8px 24px;">
{% blocktrans %}
These questions have changed status:
{% endblocktrans %}
</div>

{% for item in params.from_projects %}
{% if item.notifications %}

<div style="margin-bottom: 16px;">
<div style="background-color: #EFF4F4; border: 1px solid #D7E4F2; border-radius: 8px; padding: 16px; margin: 0px 24px;">
<!-- Project Header -->
<div style="font-size: 15px; color: #2F4155; margin-bottom: 12px;">
{% blocktrans with project_name=item.project.name %}
In <b>{{project_name}}</b>:
{% endblocktrans %}
</div>

<!-- Questions in this project -->
{% for notification in item.notifications %}
<div style="{% if not forloop.last %}margin-bottom: 8px;{% endif %}">
<a href="{% post_url notification.post.post_id notification.post.post_title notification.question.id notification.post.post_type %}"
style="display: block; text-decoration: none; color: inherit;">
<div style="background-color: #ffffff; border: 1px solid #E5E7EB; border-radius: 6px; padding: 12px;">
<div style="font-size: 14px; font-weight: 600; color: #161C22; line-height: 1.4; margin-bottom: 2px;">
{{ notification.question.title|default:notification.post.post_title }}
</div>
{% if notification.post.post_type != 'notebook' %}
<div style="font-size: 13px; font-weight: 600; color: #758EA9;">
is now {{ notification.event }}
</div>
{% endif %}
</div>
</a>
</div>
{% endfor %}
</div>
</div>

{% endif %}
{% endfor %}
{% endif %}

<!-- Regular Status Changes -->
{% if params.from_posts %}

<!-- Intro text -->
{% if params.from_projects %}
<div style="font-size: 15px; color: #161C22; margin: 0px 24px 8px 24px;">
{% blocktrans %}
In the rest of Metaculus:
{% endblocktrans %}
</div>
{% endif %}

<div style="font-size: 15px; color: #161C22; margin: 0px 24px 8px 24px;">
{% blocktrans with count=params.from_posts|length %}
These {{count}} questions have changed status:
{% endblocktrans %}
</div>

<!-- Question cards directly (no outer container) -->
{% for item in params.from_posts %}
<div style="margin: 0px 24px {% if not forloop.last %}8px{% else %}16px{% endif %} 24px;">
<a href="{% post_url item.post.post_id item.post.post_title item.question.id item.post.post_type %}"
style="display: block; text-decoration: none; color: inherit;">
<div style="background-color: #EFF4F4; border: 1px solid #D7E4F2; border-radius: 8px; padding: 12px;">
<div style="font-size: 14px; font-weight: 500; color: #161C22; line-height: 1.4; margin-bottom: 2px;">
{{ item.question.title|default:item.post.post_title }}
</div>
<div style="font-size: 13px; font-weight: 600; color: #758EA9;">
is now {{ item.event }}
</div>
</div>
</a>
</div>
{% endfor %}

{% endif %}
</mj-text>
</mj-column>
</mj-section>

<mj-include path="../../../templates/emails/email_similar_questions.mjml"/>
<mj-include path="../../../templates/emails/email_unsubscribe.mjml"/>
</mj-body>
</mjml>
19 changes: 19 additions & 0 deletions questions/services/multiple_choice_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,15 @@ def multiple_choice_delete_options(

build_question_forecasts(question)

# notify users that about the change
from questions.tasks import multiple_choice_delete_option_notificiations

multiple_choice_delete_option_notificiations(
question_id=question.id,
timestep=timestep,
comment_author_id=4, # placeholder id
)

return question


Expand Down Expand Up @@ -272,4 +281,14 @@ def multiple_choice_add_options(

build_question_forecasts(question)

# notify users that about the change
from questions.tasks import multiple_choice_add_option_notificiations

multiple_choice_add_option_notificiations(
question_id=question.id,
grace_period_end=grace_period_end,
timestep=timestep,
comment_author_id=4, # placeholder id
)

return question
Loading