예제 #1
0
 def post(self, request):
     """
     Creates a new feedback email and sends it to admins.
     """
     required = ["message", "user-interface"]
     missing_keys = check_missing_keys(request.data, required)
     if missing_keys:
         return keys_not_found(missing_keys)
     result = self._email(request, request.user.username,
                          lookupEmail(request.user.username),
                          request.data["message"])
     return Response(result, status=status.HTTP_201_CREATED)
예제 #2
0
 def post(self, request):
     """
     Creates a new feedback email and sends it to admins.
     """
     required = ["message", "user-interface"]
     missing_keys = check_missing_keys(request.data, required)
     if missing_keys:
         return keys_not_found(missing_keys)
     result = self._email(request,
                          request.user.username,
                          lookupEmail(request.user.username),
                          request.data["message"])
     return Response(result, status=status.HTTP_201_CREATED)
예제 #3
0
def send_approved_resource_email(user, request, reason):
    """
    Notify the user the that their request has been approved.
    """
    template = "core/email/resource_request_approved.html"
    subject = "Your Resource Request has been approved"
    context = {"user": user.username, "request": request, "reason": reason}
    from_name, from_email = admin_address()
    user_email = lookupEmail(user.username)
    recipients = [email_address_str(user.username, user_email)]
    sender = email_address_str(from_name, from_email)

    return send_email_template(subject, template, recipients, sender, context=context, cc=[sender])
def email_from_admin(username, subject, message, html=False):
    """ Use user, subject and message to build and send a standard
        Atmosphere admin email from admins to a user.
        Returns True on success and False on failure.
    """
    from_name, from_email = admin_address()
    user_email = lookupEmail(username)
    if not user_email:
        user_email = "*****@*****.**" % username
    return send_email(subject, message,
                      from_email=email_address_str(from_name, from_email),
                      to=[email_address_str(username, user_email)],
                      cc=[email_address_str(from_name, from_email)],
                      html=html)
예제 #5
0
 def post(self, request):
     """
     Creates a new feedback email and sends it to admins
     """
     data = request.data
     required = ['message',]
     missing_keys = valid_post_data(data, required)
     if missing_keys:
         return keys_not_found(missing_keys)
     #Pass arguments
     user = request.user
     message = data['message']
     user_email = lookupEmail(user.username)
     result = feedback_email(request, user.username, user_email, message)
     return Response(result, status=status.HTTP_201_CREATED)
예제 #6
0
def email_from_admin(username, subject, message, html=False):
    """ Use user, subject and message to build and send a standard
        Atmosphere admin email from admins to a user.
        Returns True on success and False on failure.
    """
    from_name, from_email = admin_address()
    user_email = lookupEmail(username)
    if not user_email:
        user_email = "*****@*****.**" % username
    return send_email(subject,
                      message,
                      from_email=email_address_str(from_name, from_email),
                      to=[email_address_str(username, user_email)],
                      cc=[email_address_str(from_name, from_email)],
                      html=html)
예제 #7
0
 def post(self, request):
     """
     Creates a new feedback email and sends it to admins
     """
     data = request.data
     required = ['message',]
     missing_keys = valid_post_data(data, required)
     if missing_keys:
         return keys_not_found(missing_keys)
     #Pass arguments
     user = request.user
     message = data['message']
     user_email = lookupEmail(user.username)
     result = feedback_email(request, user.username, user_email, message)
     return Response(result, status=status.HTTP_201_CREATED)
예제 #8
0
def send_approved_resource_email(user, request, reason):
    """
    Notify the user the that their request has been approved.
    """
    template = "core/email/resource_request_approved.html"
    subject = "Your Resource Request has been approved"
    context = {"user": user.username, "request": request, "reason": reason}
    from_name, from_email = admin_address()
    user_email = lookupEmail(user.username)
    recipients = [email_address_str(user.username, user_email)]
    sender = email_address_str(from_name, from_email)

    return send_email_template(subject,
                               template,
                               recipients,
                               sender,
                               context=context,
                               cc=[sender])
예제 #9
0
def email_to_admin(subject,
                   body,
                   username=None,
                   user_email=None,
                   cc_user=True,
                   admin_user=None,
                   request_tracker=False):
    """
    Send a basic email to the admins. Nothing more than subject and message
    are required.
    """
    if admin_user:
        sendto, sendto_email = admin_address(admin_user)
    elif request_tracker:
        sendto, sendto_email = request_tracker_address()
    else:
        sendto, sendto_email = admin_address()
    # E-mail yourself if no users are provided
    if not username and not user_email:
        username, user_email = sendto, sendto_email
    elif not user_email:  # Username provided
        if isinstance(username, User):
            username = username.username
        user_email = lookupEmail(username)
        if not user_email:
            user_email = "*****@*****.**" % username
    elif not username:  # user_email provided
        username = '******'
    if request_tracker or not cc_user:
        # Send w/o the CC
        return send_email(subject,
                          body,
                          from_email=email_address_str(username, user_email),
                          to=[email_address_str(sendto, sendto_email)])
    # Send w/ the CC
    return send_email(subject,
                      body,
                      from_email=email_address_str(username, user_email),
                      to=[email_address_str(sendto, sendto_email)],
                      cc=[email_address_str(username, user_email)])
def email_to_admin(
        subject,
        body,
        username=None,
        user_email=None,
        cc_user=True,
        admin_user=None,
        request_tracker=False):
    """
    Send a basic email to the admins. Nothing more than subject and message
    are required.
    """
    if admin_user:
        sendto, sendto_email = admin_address(admin_user)
    elif request_tracker:
        sendto, sendto_email = request_tracker_address()
    else:
        sendto, sendto_email = admin_address()
    # E-mail yourself if no users are provided
    if not username and not user_email:
        username, user_email = sendto, sendto_email
    elif not user_email:  # Username provided
        if isinstance(username, User):
            username = username.username
        user_email = lookupEmail(username)
        if not user_email:
            user_email = "*****@*****.**" % username
    elif not username:  # user_email provided
        username = '******'
    if request_tracker or not cc_user:
        # Send w/o the CC
        return send_email(subject, body,
                          from_email=email_address_str(username, user_email),
                          to=[email_address_str(sendto, sendto_email)])
    # Send w/ the CC
    return send_email(subject, body,
                      from_email=email_address_str(username, user_email),
                      to=[email_address_str(sendto, sendto_email)],
                      cc=[email_address_str(username, user_email)])