Commit b3524ae2 authored by felix.herrmann's avatar felix.herrmann
Browse files

feat(mail): add compose_status_email function to User model

parent 56a3faa2
......@@ -11,6 +11,7 @@ from django.urls import reverse
from django.utils import timezone
from django.utils.translation import gettext as _
from django_bleach.models import BleachField
from django.template.loader import render_to_string
from guardian.shortcuts import get_objects_for_user
from PIL import Image
from taggit.managers import TaggableManager
......@@ -323,6 +324,12 @@ class User(AbstractUser):
.filter(timestamp__gte=enddate)
)
def compose_status_email(self):
feed_actions = self.get_user_actions_recent_weekly()
return render_to_string(
"ddusers/status_email.html", {"user": self, "feed_actions": feed_actions}
)
def get_following(self):
return following(self, User)
......
......@@ -15,7 +15,7 @@ def send_status_emails():
for user in User.objects.all():
email = user.email.split(";")[0]
subject = _("[Discuss Data] Daily Status")
text = _("Mail text")
text = user.compose_status_email()
sender = "info@discuss-data.net"
to = [email]
async_task(
......@@ -24,5 +24,6 @@ def send_status_emails():
text,
sender,
to,
html_message=text,
fail_silently=False,
)
{% load static i18n compress%}<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>{% block title %}Discuss Data{% endblock title %}</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
{% block metatags %}
{% endblock %}
<link rel="icon" type="image/svg+xml" href="{% static 'images/logo-sm-primary.svg' %}" sizes="any">
{% block css %}
<!-- Your stuff: Third-party CSS libraries go here -->
{% compress css %}
<!-- This file stores project-specific CSS -->
<link href="{% static 'css/project.css' %}" rel="stylesheet">
{% endcompress %}
{% endblock %}
<!-- jsDelivr :: Sortable :: Latest (https://www.jsdelivr.com/package/npm/sortablejs) -->
<script src="https://cdn.jsdelivr.net/npm/sortablejs@1.12.0/dist/sortable.umd.js" integrity="sha256-5fXAU9N22Tec41bUvuStMzIywttdqVlleaOm24H5rGw=" crossorigin="anonymous"></script>
{% block javascript %}
<!-- Vendor dependencies bundled as one file-->
{% compress js %}
<script src="{% static 'js/vendors.js' %}"></script>
{% endcompress %}
<!-- place project specific Javascript in this file -->
{% compress js %}
<script src="{% static 'js/project.js' %}"></script>
{% endcompress %}
{% endblock javascript %}
</head>
<body>
<header>
{# main navigation #}
<nav class="navbar navbar-light fixed-top flex-md-nowrap p-0 border-bottom navbar-expand-sm" id="navbar-top">
<a class="navbar-brand px-3" href="{% url 'core.landing_page' %}"><img class="navbar-logo" src="{% static 'images/logo-primary.svg' %}" /></a>
<button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
</nav>
</header>
{# main container #}
<div class="container">
<div id="content">
{% block content %}
{% endblock content %}
</div>
</div>
{# end main container #}
{# Footer #}
{% include "footer.html" %}
{# end footer #}
</body>
</html>
{% extends "base_email.html" %}
{% load static i18n activity_tags core_tags %}
{% block title %}Your Discuss Data Status{% endblock title %}
{% block content %}
<h1>{% trans "Your Discuss Data Status" %}</h1>
Dear {{ user.get_academic_name }},<br>
<p>Your recent activities:</p>
{% for action in feed_actions %}
{% if feed_type == "notifications" or feed_type == "curation" %}
{% include 'ddcomments/_notification_card.html' with comment=action form=form %}
{% else %}
{% include 'ddusers/_feed_card.html' with action=action feed_type=feed_type %}
{% endif %}
{% endfor %}
{% endblock content %}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment