Exemplo n.º 1
0
def send_idea_comment_email(user, idea, comment, sender, notification):
    lang_code = get_user_lang_code(user)
    subjects_by_language = {
        "en":
        "Somebody left a comment on your idea '{}' on Climate Connect".format(
            idea.name),
        "de":
        "Jemand hat einen Kommentar zu deiner Idee '{}' auf Climate Connect hinterlassen."
        .format(idea.name)
    }
    base_url = settings.FRONTEND_URL
    url_ending = "/hubs/" + idea.hub_shared_in.url_slug + "?idea=" + idea.url_slug + "#ideas"

    variables = {
        "IdeaName": idea.name,
        "CommentText": comment,
        "FirstName": user.first_name,
        "CommenterName": sender.first_name + " " + sender.last_name,
        "url": base_url + get_user_lang_url(lang_code) + url_ending
    }
    send_email(user=user,
               variables=variables,
               template_key="IDEA_COMMENT_TEMPLATE_ID",
               subjects_by_language=subjects_by_language,
               should_send_email_setting="email_on_comment_on_your_idea",
               notification=notification)
Exemplo n.º 2
0
def send_private_chat_message_notification_email(
    user, 
    message_content, 
    chat_uuid, 
    sender_name, 
    notification
):
    lang_url = get_user_lang_url(get_user_lang_code(user))
    chat_url = settings.FRONTEND_URL + lang_url + "/chat/" + str(chat_uuid)
    
    subjects_by_language = {
        "en": "You received a private message from {} on Climate Connect".format(sender_name),
        "de": "Du hast eine Privatnachricht von {} auf Climate Connect bekommen".format(sender_name)
    }

    message_preview = message_content
    if len(message_content) > 50:
        message_preview = message_content[0:50] + "..."

    variables =  {
        "FirstName": user.first_name,
        "SenderName": sender_name,
        "Message": message_preview,
        "url": chat_url,
    }
    send_email(
        user=user, 
        variables=variables, 
        template_key="PRIVATE_MESSAGE_TEMPLATE_ID", 
        subjects_by_language=subjects_by_language,
        should_send_email_setting="email_on_private_chat_message",
        notification=notification
    )   
Exemplo n.º 3
0
def send_project_comment_email(user, project, comment, sender, notification):
    lang_code = get_user_lang_code(user)
    subjects_by_language = {
        "en":
        "Somebody left a comment on your project {} on Climate Connect".format(
            project.name),
        "de":
        "Jemand hat dein Projekt {} auf Climate Connect kommentiert".format(
            project.name)
    }
    base_url = settings.FRONTEND_URL
    url_ending = "/projects/" + project.url_slug + "#comments"
    variables = {
        "ProjectName": project.name,
        "CommentText": comment,
        "FirstName": user.first_name,
        "CommenterName": sender.first_name + " " + sender.last_name,
        "url": base_url + get_user_lang_url(lang_code) + url_ending
    }
    send_email(user=user,
               variables=variables,
               template_key="PROJECT_COMMENT_TEMPLATE_ID",
               subjects_by_language=subjects_by_language,
               should_send_email_setting="email_on_comment_on_your_project",
               notification=notification)
Exemplo n.º 4
0
def send_project_follower_email(user, project_follower, notification):
    lang_code = get_user_lang_code(user)
    follower_name = project_follower.user.first_name + " " + project_follower.user.last_name
    subjects_by_language = {
        "en":
        "{} now follows your project on Climate Connect".format(follower_name),
        "de":
        "{} folgt jetzt deinem Projekt auf Climate Connect".format(
            follower_name)
    }

    base_url = settings.FRONTEND_URL
    url_ending = "/projects/" + project_follower.project.url_slug + "?show_followers=true"

    variables = {
        "FollowerName": follower_name,
        "FirstName": user.first_name,
        "ProjectName": project_follower.project.name,
        "url": base_url + get_user_lang_url(lang_code) + url_ending
    }
    send_email(user=user,
               variables=variables,
               template_key="PROJECT_FOLLOWER_TEMPLATE_ID",
               subjects_by_language=subjects_by_language,
               should_send_email_setting="email_on_new_project_follower",
               notification=notification)
Exemplo n.º 5
0
def send_password_link(user, password_reset_key):
    lang_url = get_user_lang_url(get_user_lang_code(user))
    url = get_reset_password_url(password_reset_key, lang_url)

    subjects_by_language = {
        "en": "Reset your Climate Connect password",
        "de": "Setze deine Climate Connect Passwort zurück"
    }

    variables = {"FirstName": user.first_name, "url": url}
    send_email(user=user,
               variables=variables,
               template_key="RESET_PASSWORD_TEMPLATE_ID",
               subjects_by_language=subjects_by_language,
               should_send_email_setting="",
               notification=None)
Exemplo n.º 6
0
def send_user_verification_email(user, verification_key):
    lang_url = get_user_lang_url(get_user_lang_code(user))
    url = get_user_verification_url(verification_key, lang_url)

    subjects_by_language = {
        "en": "Welcome to Climate Connect! Verify your email address",
        "de":
        "Willkommen bei Climate Connect! Verifiziere deine Email-Adresse!"
    }

    variables = {"FirstName": user.first_name, "url": url}
    send_email(user=user,
               variables=variables,
               template_key="EMAIL_VERIFICATION_TEMPLATE_ID",
               subjects_by_language=subjects_by_language,
               should_send_email_setting="",
               notification=None)
Exemplo n.º 7
0
def send_new_email_verification(user, new_email, verification_key):
    lang_url = get_user_lang_url(get_user_lang_code(user))
    url = get_new_email_verification_url(verification_key, lang_url)

    subjects_by_language = {
        "en": "Verify your new email address",
        "de": "Bestätige deine neue Email Adresse"
    }

    variables = {
        "FirstName": user.first_name,
        "url": url,
        "NewMail": new_email
    }
    send_email(user=user,
               variables=variables,
               template_key="NEW_EMAIL_VERIFICATION_TEMPLATE_ID",
               subjects_by_language=subjects_by_language,
               should_send_email_setting="",
               notification=None)
Exemplo n.º 8
0
def send_project_comment_reply_email(user, project, comment, sender,
                                     notification):
    lang_code = get_user_lang_code(user)
    subjects_by_language = {
        "en": "Someone replied to your comment on Climate Connect",
        "de": "Jemand hat auf deinen Kommentar auf Climate Connect geantwortet"
    }
    base_url = settings.FRONTEND_URL
    url_ending = "/projects/" + project.url_slug + "#comments"
    variables = {
        "FirstName": user.first_name,
        "CommenterName": sender.first_name + " " + sender.last_name,
        "CommentText": comment,
        "url": base_url + get_user_lang_url(lang_code) + url_ending,
        "ProjectName": project.name
    }
    send_email(user=user,
               variables=variables,
               template_key="PROJECT_COMMENT_REPLY_TEMPLATE_ID",
               subjects_by_language=subjects_by_language,
               should_send_email_setting="email_on_reply_to_your_comment",
               notification=notification)
Exemplo n.º 9
0
def send_idea_join_email(user, joining_user, idea, chat_uuid, notification):
    lang_code = get_user_lang_code(user)
    subjects_by_language = {
        "en": "{} joined your idea on Climate Connect".format(joining_user.first_name + " " + joining_user.last_name),
        "de": "{} macht jetzt bei deiner Idee auf Climate Connect mit!".format(joining_user.first_name + " " + joining_user.last_name)
    }
    base_url = settings.FRONTEND_URL
    url_ending = "/chat/"+str(chat_uuid)
    variables = {
        "FirstName": user.first_name,
        "JoiningUserFirstName": joining_user.first_name,
        "JoiningUserName": joining_user.first_name + " " + joining_user.last_name,
        "ChatUrl": base_url + get_user_lang_url(lang_code) + url_ending,
        "IdeaName": idea.name
    }
    send_email(
        user=user, 
        variables=variables, 
        template_key="JOINED_IDEA_TEMPLATE", 
        subjects_by_language=subjects_by_language,
        should_send_email_setting="email_on_idea_join",
        notification=notification
    )
Exemplo n.º 10
0
def send_group_chat_message_notification_email(
    user, 
    message_content, 
    chat_uuid, 
    sender_name, 
    chat_title, 
    notification
):
    lang_url = get_user_lang_url(get_user_lang_code(user))
    chat_url = settings.FRONTEND_URL + lang_url + "/chat/" + str(chat_uuid)
    
    subjects_by_language = {
        "en": "{} sent a message in the group '{}' on Climate Connect".format(sender_name, chat_title),
        "de": "{} hat eine Nachricht in der Gruppe '{}' on Climate Connect geschrieben".format(sender_name, chat_title)
    }

    message_preview = message_content
    if len(message_content) > 50:
        message_preview = message_content[0:50] + "..."

    variables =  {
        "FirstName": user.first_name,
        "SenderName": sender_name,
        "GroupName": chat_title,
        "Message": message_preview,
        "url": chat_url,
    }

    send_email(
        user=user, 
        variables=variables, 
        template_key="GROUP_MESSAGE_TEMPLATE_ID", 
        subjects_by_language=subjects_by_language,
        should_send_email_setting="email_on_group_chat_message",
        notification=notification
    ) 
Exemplo n.º 11
0
def send_idea_comment_reply_email(user, idea, comment, sender, notification):
    lang_code = get_user_lang_code(user)
    subjects_by_language = {
        "en": "Someone replied to your comment on Climate Connect",
        "de":
        "Jemand hat auf deinen Kommentar auf Climate Connect geantwortet."
    }

    base_url = settings.FRONTEND_URL
    url_ending = "/hubs/" + idea.hub_shared_in.url_slug + "?idea=" + idea.url_slug + "#ideas"

    variables = {
        "FirstName": user.first_name,
        "CommenterName": sender.first_name + " " + sender.last_name,
        "CommentText": comment,
        "url": base_url + get_user_lang_url(lang_code) + url_ending,
        "IdeaName": idea.name
    }
    send_email(user=user,
               variables=variables,
               template_key="IDEA_COMMENT_REPLY_TEMPLATE_ID",
               subjects_by_language=subjects_by_language,
               should_send_email_setting="email_on_reply_to_your_comment",
               notification=notification)