from django.utils.translation import ngettext_lazy, gettext_lazy as _ from froide.helper.email_sending import mail_registry from .utils import send_request_user_email update_requester_email = mail_registry.register( 'foirequest/emails/request_update', ('count', 'user', 'request_list')) classification_reminder_email = mail_registry.register( 'foirequest/emails/classification_reminder', ('foirequest', 'action_url')) def send_update(request_list, user=None): if user is None: return count = len(request_list) subject = ngettext_lazy("Update on one of your request", "Update on %(count)s of your requests", count) % { 'count': count } # Add additional info to template context for req_event_dict in request_list: assert req_event_dict['request'].user_id == user.id req_event_dict.update({ 'go_url': user.get_autologin_url( req_event_dict['request'].get_absolute_short_url()) }) update_requester_email.send(user=user,
from collections import namedtuple, defaultdict import re from django.db.models import Q from django.utils.translation import gettext_lazy as _ from froide.helper.text_utils import split_text_by_separator from froide.helper.admin_utils import make_choose_object_action from froide.helper.email_sending import mail_registry from .models import Rule, Guidance guidance_notification_mail = mail_registry.register( 'guide/emails/new_guidance', ('name', 'single_request', 'request_title', 'guidances') ) GuidanceResult = namedtuple( 'GuidanceResult', ('guidances', 'created', 'deleted',) ) WS = re.compile(r'\s+') def prepare_text(text): text, _1 = split_text_by_separator(text) text = ' '.join(text.splitlines()) text = WS.sub(' ', text)
from django.contrib.auth import get_user_model from django.utils.translation import gettext_lazy as _ from django.urls import reverse from django.utils import timezone from django.utils.crypto import constant_time_compare from django.dispatch import Signal from froide.foirequest.models import FoiRequest from froide.helper.email_sending import mail_registry REFERENCE_PREFIX = 'follow-' User = get_user_model() follow_request_email = mail_registry.register( 'foirequestfollower/emails/confirm_follow', ('action_url', 'foirequest', 'user')) update_follower_email = mail_registry.register( 'foirequestfollower/emails/update_follower', ('count', 'user', 'update_list')) batch_update_follower_email = mail_registry.register( 'foirequestfollower/emails/batch_update_follower', ('count', 'user', 'update_list')) class FoiRequestFollowerManager(models.Manager): def get_followable_requests(self, user): return FoiRequest.objects.exclude(user=user).exclude(visibility=0)
return False mail_middleware_registry.register(OnlyActiveUsersMailMiddleware()) def send_mail_user(subject, body, user: User, ignore_active=False, **kwargs): if not ignore_active and not user.is_active: return if not user.email: return return send_mail(subject, body, user.email, bounce_check=False, **kwargs) user_email = mail_registry.register('account/emails/user_email', ('subject', 'body')) def send_template_mail(user: User, subject: str, body: str, **kwargs): mail_context = { 'first_name': user.first_name, 'last_name': user.last_name, 'name': user.get_full_name(), 'url': user.get_autologin_url('/'), } user_subject = subject.format(**mail_context) user_body = body.format(**mail_context) return user_email.send(user=user, context={ 'subject': user_subject, 'body': user_body
from froide.helper.db_utils import save_obj_unique from froide.helper.email_sending import mail_registry from .models import User, AccountBlocklist from . import account_activated def get_user_for_email(email): try: return User.objects.get(email=email) except User.DoesNotExist: return False confirmation_mail = mail_registry.register( 'account/emails/confirmation_mail', ('action_url', 'name', 'request_id')) confirm_action_mail = mail_registry.register('account/emails/confirm_action', ('title', 'action_url', 'name')) reminder_mail = mail_registry.register('account/emails/account_reminder', ('name', 'action_url')) change_email_mail = mail_registry.register('account/emails/change_email', ('action_url', 'name')) class AccountService(object): def __init__(self, user): self.user = user @classmethod def get_username_base(self, firstname, lastname): base = ""
from django.db.models import signals from django.dispatch import receiver from django.utils.translation import gettext_lazy as _ from froide.helper.email_sending import mail_registry from .models import FoiRequest, FoiMessage, FoiAttachment, FoiEvent, FoiProject from .utils import send_request_user_email became_overdue_email = mail_registry.register( 'foirequest/emails/became_overdue', ( 'action_url', 'foirequest', )) became_asleep_email = mail_registry.register('foirequest/emails/became_asleep', ( 'action_url', 'foirequest', )) message_received_email = mail_registry.register( 'foirequest/emails/message_received_notification', ('action_url', 'foirequest', 'publicbody', 'message')) public_body_suggested_email = mail_registry.register( 'foirequest/emails/public_body_suggestion_received', ('action_url', 'foirequest', 'suggestion')) confirm_foi_project_created_email = mail_registry.register( 'foirequest/emails/confirm_foi_project_created', ('foiproject', 'action_url')) confirm_foi_request_sent_email = mail_registry.register( 'foirequest/emails/confirm_foi_request_sent', ('foirequest', 'message', 'publicbody', 'action_url'))
receipt=data.get('receipt', False), ) if subscription: donor.subscriptions.add(subscription) logger.info('Donor created %s', donor.id) if donor.email_confirmed and donor.contact_allowed: subscribe_to_default_newsletter(donor.email, user=user) subscribe_donor_newsletter(donor) return donor new_donor_thanks_email = mail_registry.register( 'fds_donation/email/donor_new_thanks', ( 'name', 'first_name', 'last_name', 'salutation', 'payment', 'order', 'donor', 'donation' ) ) donor_thanks_email = mail_registry.register( 'fds_donation/email/donor_thanks', ( 'name', 'first_name', 'last_name', 'salutation', 'payment', 'order', 'donor', 'donation' ) ) donor_optin_email = mail_registry.register( 'fds_donation/email/donor_thanks_optin', (