Пример #1
0
def send_permission_request_email(obj):
    """
    Emails the editors that someone has requested to view an algorithm.

    Parameters
    ----------
    obj:
        AlgorithmPermissionRequest object containing info on which
        user requested access to which base_object.
    """
    title = f"[{obj.object_name}] New access request"
    kwargs = {
        "user": obj.user,
        "site": Site.objects.get_current(),
        "base_object": obj.base_object,
        "permission_list_url": obj.permission_list_url,
    }
    for editor in obj.base_object.editors_group.user_set.all():
        kwargs["editor"] = editor
        send_templated_email(
            title,
            "grandchallenge/emails/access_request.html",
            kwargs,
            [editor.email],
        )
Пример #2
0
def send_file_uploaded_notification_email(**kwargs):
    uploader = kwargs["uploader"]
    challenge = kwargs["challenge"]
    site = kwargs["site"]
    title = "New upload for {}: '{}' ".format(challenge.short_name,
                                              kwargs["filename"])
    admins = challenge.get_admins()
    if not admins:
        admin_email_adresses = [x[1] for x in settings.ADMINS]
        kwargs["additional_message"] = ("<i> Message from COMIC: I could not\
        find any administrator for " + challenge.short_name +
                                        ". Somebody needs to\
        know about this new upload, so I am Sending this email to everyone set\
        as general COMIC admin (ADMINS in the /comic/settings/ conf file). To\
        stop getting these messages, set an admin for\
        " + challenge.short_name + ".</i> <br/><br/>")
    else:
        kwargs["additional_message"] = ""
        admin_email_adresses = [x.email for x in admins]
    kwargs["project"] = challenge
    send_templated_email(
        title,
        "uploads/emails/file_uploaded_email.html",
        kwargs,
        admin_email_adresses,
    )
Пример #3
0
def send_participation_request_rejected_email(request, obj):
    """ When a users requests to become a participant is rejected, let the user know

    request:     HTTPRequest containing the current admin posting this
    obj:         ParticipationRequest object containing info on which user requested
                 participation for which project

    """
    title = (
        f"[{obj.challenge.short_name.lower()}] Participation Request Rejected"
    )
    mainportal = get_current_site(request)
    kwargs = {
        "user": obj.user,
        "adder": request.user,
        "site": mainportal,
        "challenge": obj.challenge,
    }
    send_templated_email(
        title,
        "participants/emails/participation_request_rejected_email.html",
        kwargs,
        [obj.user.email],
        request=request,
    )
Пример #4
0
def send_file_uploaded_notification_email(**kwargs):
    challenge = kwargs["challenge"]
    title = f"[{challenge.short_name.lower()}] New Upload"
    admins = challenge.get_admins()
    if not admins:
        admin_email_adresses = [x[1] for x in settings.ADMINS]
        kwargs["additional_message"] = (
            "<i> Message from COMIC: I could not\
        find any administrator for "
            + challenge.short_name
            + ". Somebody needs to\
        know about this new upload, so I am Sending this email to everyone set\
        as general COMIC admin (ADMINS in the /comic/settings/ conf file). To\
        stop getting these messages, set an admin for\
        "
            + challenge.short_name
            + ".</i> <br/><br/>"
        )
    else:
        kwargs["additional_message"] = ""
        admin_email_adresses = [x.email for x in admins]
    kwargs["project"] = challenge
    send_templated_email(
        title,
        "uploads/emails/file_uploaded_email.html",
        kwargs,
        admin_email_adresses,
    )
Пример #5
0
def send_file_uploaded_notification_email(**kwargs):
    uploader = kwargs['uploader']
    challenge = kwargs['challenge']
    site = kwargs['site']
    title = "New upload for %s: '%s' " % (challenge.short_name,
                                          kwargs["filename"])
    admins = challenge.get_admins()
    if not admins:
        admin_email_adresses = [x[1] for x in settings.ADMINS]
        kwargs['additional_message'] = '<i> Message from COMIC: I could not\
        find any administrator for ' + challenge.short_name + '. Somebody needs to\
        know about this new upload, so I am Sending this email to everyone set\
        as general COMIC admin (ADMINS in the /comic/settings/ conf file). To\
        stop getting these messages, set an admin for\
        ' + challenge.short_name + '.</i> <br/><br/>'
    else:
        kwargs['additional_message'] = ''
        admin_email_adresses = [x.email for x in admins]
    kwargs['project'] = challenge
    send_templated_email(
        title,
        "uploads/emails/file_uploaded_email.html",
        kwargs,
        admin_email_adresses,
    )
Пример #6
0
def send_new_admin_notification_email(
    *, challenge: Challenge, new_admin: AbstractUser, site
):
    title = f"[{challenge.short_name.lower()}] You Are Now An Admin"
    send_templated_email(
        title,
        "admins/emails/new_admin_notification_email.html",
        {"challenge": challenge, "new_admin": new_admin, "site": site},
        [new_admin.email],
    )
Пример #7
0
def send_new_admin_notification_email(*, challenge: Challenge,
                                      new_admin: AbstractUser, site):
    title = f"You are now admin for {challenge.short_name}"
    send_templated_email(
        title,
        "admins/emails/new_admin_notification_email.html",
        {
            "challenge": challenge,
            "new_admin": new_admin,
            "site": site
        },
        [new_admin.email],
    )
Пример #8
0
def send_new_admin_notification_email(*, challenge: Challenge,
                                      new_admin: AbstractUser, site):
    title = f"[{challenge.short_name.lower()}] You Are Now An Admin"
    send_templated_email(
        title,
        "admins/emails/new_admin_notification_email.html",
        {
            "challenge": challenge,
            "new_admin": new_admin,
            "site": site
        },
        [new_admin.email],
    )
Пример #9
0
def send_new_admin_notification_email(*, challenge: Challenge,
                                      new_admin: AbstractUser, site):
    title = f'You are now admin for {challenge.short_name}'
    send_templated_email(
        title,
        "admins/emails/new_admin_notification_email.html",
        {
            'challenge': challenge,
            'new_admin': new_admin,
            'site': site
        },
        [new_admin.email],
    )
Пример #10
0
def send_participation_request_notification_email(request, obj):
    """ When a user requests to become a participant, let this know to all admins

    request:     HTTPRequest containing the current admin posting this
    obj:         ParticipationRequest object containing info on which user requested
                 participation for which project

    """
    title = f"New participation request for {obj.challenge.short_name}"
    mainportal = get_current_site(request)
    kwargs = {"user": obj.user, "site": mainportal, "challenge": obj.challenge}
    for admin in obj.challenge.get_admins():
        kwargs["admin"] = admin
        send_templated_email(
            title,
            "participants/emails/participation_request_notification_email.html",
            kwargs,
            [admin.email],
            request=request,
        )
Пример #11
0
def send_participation_request_notification_email(request, obj):
    """ When a user requests to become a participant, let this know to all admins

    request:     HTTPRequest containing the current admin posting this
    obj:         ParticipationRequest object containing info on which user requested
                 participation for which project

    """
    title = f"[{obj.challenge.short_name.lower()}] New Participation Request"
    mainportal = get_current_site(request)
    kwargs = {"user": obj.user, "site": mainportal, "challenge": obj.challenge}
    for admin in obj.challenge.get_admins():
        kwargs["admin"] = admin
        send_templated_email(
            title,
            "participants/emails/participation_request_notification_email.html",
            kwargs,
            [admin.email],
            request=request,
        )
Пример #12
0
def send_permission_granted_email(obj):
    """
    Emails the requester that their request has been approved.

    Parameters
    ----------
    obj:
        AlgorithmPermissionRequest object containing info on which
        user requested access to which base_object.
    """
    title = f"[{obj.object_name}] Access granted"
    kwargs = {
        "user": obj.user,
        "site": Site.objects.get_current(),
        "base_object": obj.base_object,
    }
    send_templated_email(
        title,
        "grandchallenge/emails/access_granted.html",
        kwargs,
        [obj.user.email],
    )
Пример #13
0
def send_participation_request_rejected_email(request, obj):
    """ When a users requests to become a participant is rejected, let the user know

    request:     HTTPRequest containing the current admin posting this
    obj:         ParticipationRequest object containing info on which user requested
                 participation for which project

    """
    title = obj.challenge.short_name + " participation request rejected"
    mainportal = get_current_site(request)
    kwargs = {
        "user": obj.user,
        "adder": request.user,
        "site": mainportal,
        "challenge": obj.challenge,
    }
    send_templated_email(
        title,
        "participants/emails/participation_request_rejected_email.html",
        kwargs,
        [obj.user.email],
        request=request,
    )
Пример #14
0
def send_participation_request_rejected_email(request, obj):
    """
    Email the user when a participation request is rejected.

    request:     HTTPRequest containing the current admin posting this
    obj:         ParticipationRequest object containing info on which user
                 requested participation for which challenge
    """
    title = (
        f"[{obj.challenge.short_name.lower()}] Participation Request Rejected")
    kwargs = {
        "user": obj.user,
        "adder": request.user,
        "site": request.site,
        "challenge": obj.challenge,
    }
    send_templated_email(
        title,
        "participants/emails/participation_request_rejected_email.html",
        kwargs,
        [obj.user.email],
        request=request,
    )
Пример #15
0
def send_participation_request_notification_email(request, obj):
    """
    Email the challenge admins when a new participant request is created.

    request:     HTTPRequest containing the current admin posting this
    obj:         ParticipationRequest object containing info on which user
                 requested participation for which challenge
    """
    title = f"[{obj.challenge.short_name.lower()}] New Participation Request"
    kwargs = {
        "user": obj.user,
        "site": request.site,
        "challenge": obj.challenge,
    }
    for admin in obj.challenge.get_admins():
        kwargs["admin"] = admin
        send_templated_email(
            title,
            "participants/emails/participation_request_notification_email.html",
            kwargs,
            [admin.email],
            request=request,
        )
def send_participation_request_accepted_email(request, obj):
    """ When a users requests to become a participant is accepted, let the user know

    request:     HTTPRequest containing the current admin posting this
    obj:         ParticipationRequest object containing info on which user requested
                 participation for which project

    """
    title = (
        f"[{obj.challenge.short_name.lower()}] Participation Request Accepted"
    )
    kwargs = {
        "user": obj.user,
        "adder": request.user,
        "site": request.site,
        "challenge": obj.challenge,
    }
    send_templated_email(
        title,
        "participants/emails/participation_request_accepted_email.html",
        kwargs,
        [obj.user.email],
        request=request,
    )