def _email(self, request, username, user_email, message): """ Sends an email to support based on feedback from a client machine Returns a response. """ user = User.objects.get(username=username) subject = 'Subject: Atmosphere Client Feedback from %s' % username context = {"user": user, "feedback": message} body = render_to_string("core/email/feedback.html", context=context) email_success = email_admin(request, subject, body, request_tracker=True) if email_success: resp = { 'result': { 'code': 'success', 'meta': '', 'value': ('Thank you for your feedback! ' 'Support has been notified.') } } else: resp = { 'result': { 'code': 'failed', 'meta': '', 'value': 'Failed to send feedback!' } } return resp
def quota_request_email(request, username, new_quota, reason): """ Processes Increase Quota request. Sends email to [email protected] Returns a response. """ user = User.objects.get(username=username) membership = IdentityMembership.objects.get( identity=user.select_identity(), member__in=user.group_set.all()) admin_url = reverse('admin:core_identitymembership_change', args=(membership.id,)) subject = "Atmosphere Quota Request - %s" % username context = { "user": user, "quota": new_quota, "reason": reason, "url": request.build_absolute_uri(admin_url) } body = render_to_string("core/email/quota_request.html", context=Context(context)) logger.info(body) email_success = email_admin(request, subject, body, cc_user=False) return {"email_sent": email_success}
def _email(self, user, data): """ Sends an instance/volume report email to support Returns a response. """ subject = "Volume Instance Report from %s" % user.username; volume = Volume.objects \ .filter(id=data["volume"])[0] context = { "problems": data.get("problems", []), "ui": data.get("user-interface", ""), "server": settings.SERVER_URL, "message": data["message"], "provider": user.selected_identity.provider, "volume": volume, } context.update(request_data(self.request)) message = render_to_string("volume_report.html", context=context) email_success = email_admin(self.request, subject, message, request_tracker=True) email_response = {"email_sent": email_success} if not email_success: return Response(email_response, status=status.HTTP_400_BAD_REQUEST) return Response(email_response, status=status.HTTP_200_OK)
def feedback(request): """ Sends an email Bto support based on feedback from a client machine Returns a response. """ user, user_email = user_address(request) message = request.POST.get('message') subject = 'Subject: Atmosphere Client Feedback from %s' % user message = '---\nFeedback: %s\n---' % message email_success = email_admin(request, subject, message) if email_success: resp = json.dumps({ 'result': { 'code': 'success', 'meta': '', 'value': 'Thank you for your feedback! ' + 'Support has been notified.' } }) return HttpResponse(resp, content_type='application/json') else: resp = json.dumps({ 'result': { 'code': 'failed', 'meta': '', 'value': 'Failed to send feedback!' } }) return HttpResponse(resp, content_type='application/json')
def requestImaging(request, machine_request_id, auto_approve=False): """ Processes image request, sends an email to the user and a sperate email to [email protected] Returns a response. """ # TODO: This could also be: # machine_request.instance.created_by.username # And we could add another field 'new_image_owner'.. machine_request = MachineRequest.objects.get(id=machine_request_id) user = machine_request.new_machine_owner subject = 'Atmosphere Imaging Request - %s' % user.username context = { "user": user, "approved": auto_approve, "request": machine_request } body = render_to_string("core/email/imaging_request.html", context=Context(context)) # Send staff url if not approved if not auto_approve: namespace = "api:v1:cloud-admin-imaging-request-detail" base_url = reverse(namespace, args=(machine_request_id,)) context["view"] = base_url context["approve"] = "%s/approve" % base_url context["deny"] = "%s/deny" % base_url staff_body = render_to_string("core/email/imaging_request_staff.html", context=Context(context)) email_success = email_admin(request, subject, staff_body, cc_user=False) return email_from_admin(user.username, subject, body)
def feedback(request): """ Sends an email Bto support based on feedback from a client machine Returns a response. """ user, user_email = user_address(request) message = request.POST.get('message') subject = 'Subject: Atmosphere Client Feedback from %s' % user message = '---\nFeedback: %s\n---' % message email_success = email_admin(request, subject, message) if email_success: resp = json.dumps({'result': {'code': 'success', 'meta': '', 'value': 'Thank you for your feedback! ' + 'Support has been notified.'}}) return HttpResponse(resp, content_type='application/json') else: resp = json.dumps({'result': {'code': 'failed', 'meta': '', 'value': 'Failed to send feedback!'}}) return HttpResponse(resp, content_type='application/json')
def _email(self, user, data): """ Sends an instance/volume report email to support Returns a response. """ subject = "Atmosphere Instance Report from %s" % user.username instance = Instance.objects.filter(id=data["instance"])[0] last_status = instance.instancestatushistory_set \ .order_by('start_date') \ .last() context = { "problems": data.get("problems", []), "ui": data.get("user-interface", ""), "server": settings.SERVER_URL, "message": data["message"], "provider": user.selected_identity.provider_uuid(), "instance": instance, "status": last_status } context.update(request_data(self.request)) message = render_to_string("instance_report.html", context=context) email_success = email_admin(self.request, subject, message, request_tracker=True) email_response = {"email_sent": email_success} if not email_success: return Response(email_response, status=status.HTTP_400_BAD_REQUEST) return Response(email_response, status=status.HTTP_200_OK)
def feedback_email(request, username, user_email, message): """ Sends an email Bto support based on feedback from a client machine Returns a response. """ subject = 'Subject: Atmosphere Client Feedback from %s' % username message = '---\nFeedback: %s\n---' % message email_success = email_admin(request, subject, message) if email_success: resp = { 'result': { 'code': 'success', 'meta': '', 'value': 'Thank you for your feedback! ' + 'Support has been notified.' } } else: resp = { 'result': { 'code': 'failed', 'meta': '', 'value': 'Failed to send feedback!' } } return resp
def feedback_email(request, username, user_email, message): """ Sends an email Bto support based on feedback from a client machine Returns a response. """ user = User.objects.get(username=username) subject = 'Subject: Atmosphere Client Feedback from %s' % username context = { "user": user, "feedback": message } body = render_to_string("core/email/feedback.html", context=Context(context)) email_success = email_admin(request, subject, body, request_tracker=True) if email_success: resp = {'result': {'code': 'success', 'meta': '', 'value': 'Thank you for your feedback! ' + 'Support has been notified.'}} else: resp = {'result': {'code': 'failed', 'meta': '', 'value': 'Failed to send feedback!'}} return resp
def requestQuota(request): """ Processes Increase Quota request. Sends email to [email protected] Returns a response. """ if request.method != 'POST': return HttpResponse('') username = request.POST['username'] new_quota = request.POST['quota'] reason = request.POST['reason'] user = User.objects.get(username=username) membership = IdentityMembership.objects.get(identity=user.select_identity(), member__in=user.group_set.all()) admin_url = urlresolvers.reverse('admin:core_identitymembership_change', args=(membership.id,)) message = """ Username : %s Quota Requested: %s Reason for Quota Increase: %s URL for Quota Increase:%s """ % (username, new_quota, reason, request.build_absolute_uri(admin_url)) subject = "Atmosphere Quota Request - %s" % username logger.info(message) email_success = email_admin(request, subject, message, cc_user=False) resp = json.dumps({}) if email_success: return HttpResponse(resp, content_type='application/json') else: return HttpResponseServerError(resp, content_type='application/json')
def _email(self, user, data): """ Sends an instance/volume report email to support Returns a response. """ subject = "Atmosphere Instance Report from %s" % user.username; instance = Instance.objects.filter(id=data["instance"])[0] last_status = instance.instancestatushistory_set \ .order_by('start_date') \ .last() context = { "problems": data.get("problems", []), "ui": data.get("user-interface", ""), "server": settings.SERVER_URL, "message": data["message"], "provider": instance.provider, "instance": instance, "status": last_status } context.update(request_data(self.request)) message = render_to_string("instance_report.html", context=context) email_success = email_admin(self.request, subject, message, request_tracker=True) email_response = {"email_sent": email_success} if not email_success: return Response(email_response, status=status.HTTP_400_BAD_REQUEST) return Response(email_response, status=status.HTTP_200_OK)
def resource_request_email(request, username, new_resource, reason): """ Processes Resource request. Sends email to [email protected] Returns a response. """ user = User.objects.get(username=username) membership = IdentityMembership.objects.get( identity=user.select_identity(), member__in=user.group_set.all()) admin_url = reverse('admin:core_identitymembership_change', args=(membership.id,)) subject = "Atmosphere Resource Request - %s" % username context = { "user": user, "resource": new_resource, "reason": reason, "url": request.build_absolute_uri(admin_url) } body = render_to_string("core/email/resource_request.html", context=Context(context)) logger.info(body) email_success = email_admin(request, subject, body, cc_user=False) return {"email_sent": email_success}
def requestImaging(request, machine_request_id, auto_approve=False): """ Processes image request, sends an email to the user and a sperate email to [email protected] Returns a response. """ # TODO: This could also be: # machine_request.instance.created_by.username # And we could add another field 'new_image_owner'.. machine_request = MachineRequest.objects.get(id=machine_request_id) user = machine_request.new_machine_owner subject = 'Atmosphere Imaging Request - %s' % user.username context = { "user": user, "approved": auto_approve, "request": machine_request } body = render_to_string("core/email/imaging_request.html", context=Context(context)) # Send staff url if not approved if not auto_approve: namespace = "api:public_apis:cloud-admin-imaging-request-detail" base_url = reverse(namespace, args=(machine_request_id,)) context["view"] = base_url context["approve"] = "%s/approve" % base_url context["deny"] = "%s/deny" % base_url staff_body = render_to_string("core/email/imaging_request_staff.html", context=Context(context)) email_success = email_admin(request, subject, staff_body, cc_user=False) return email_from_admin(user.username, subject, body)
def email_support(request): """ Sends an email to support. POST Params expected: * user * message * subject Returns a response. """ if request.META['REQUEST_METHOD'] != 'POST': return HttpResponse("Expecting POST with message and subject" "parameters.") message = request.POST.get('message') if not message: return HttpResponseServerError({'email_sent': False, 'reason': 'Message contents missing'}, content_type='application/json') subject = request.POST.get('subject') if not subject: return HttpResponseServerError({'email_sent': False, 'reason': 'E-Mail Subject missing'}, content_type='application/json') email_success = email_admin(request, subject, message) resp = json.dumps({'email_sent': email_success}) if email_success: return HttpResponse(resp, content_type='application/json') else: return HttpResponseServerError(resp, content_type='application/json')
def _email(self, user, data): """ Sends an instance/volume report email to support Returns a response. """ subject = "Volume Instance Report from %s" % user.username volume = Volume.objects \ .filter(id=data["volume"])[0] context = { "problems": data.get("problems", []), "ui": data.get("user-interface", ""), "server": settings.SERVER_URL, "message": data["message"], "provider": user.selected_identity.provider, "volume": volume, } context.update(request_data(self.request)) message = render_to_string("volume_report.html", context=context) email_success = email_admin(self.request, subject, message, request_tracker=True) email_response = {"email_sent": email_success} if not email_success: return Response(email_response, status=status.HTTP_400_BAD_REQUEST) return Response(email_response, status=status.HTTP_200_OK)
def requestQuota(request): """ Processes Increase Quota request. Sends email to [email protected] Returns a response. """ if request.method != 'POST': return HttpResponse('') username = request.POST['username'] new_quota = request.POST['quota'] reason = request.POST['reason'] user = User.objects.get(username=username) membership = IdentityMembership.objects.get( identity=user.select_identity(), member__in=user.group_set.all()) admin_url = urlresolvers.reverse('admin:core_identitymembership_change', args=(membership.id, )) message = """ Username : %s Quota Requested: %s Reason for Quota Increase: %s URL for Quota Increase:%s """ % (username, new_quota, reason, request.build_absolute_uri(admin_url)) subject = "Atmosphere Quota Request - %s" % username logger.info(message) email_success = email_admin(request, subject, message, cc_user=False) resp = json.dumps({}) if email_success: return HttpResponse(resp, content_type='application/json') else: return HttpResponseServerError(resp, content_type='application/json')
def _email(self, user, data): subject = data.pop('subject') message = data.pop('message') email_success = email_admin(self.request, subject, message, data=data) email_response = {"email_sent": email_success} if not email_success: return Response(email_response, status=status.HTTP_400_BAD_REQUEST) return Response(email_response, status=status.HTTP_200_OK)
def test_email_admin(self): """ Assert that emails to admin correctly set from, to, and cc fields """ with mock.patch('core.tasks.EmailMessage') as MockMessage, \ override_settings(ADMINS=[ ('Admin1', '*****@*****.**'), ('Admin2', '*****@*****.**')]): email_admin('Subject', 'Body', 'First Last <*****@*****.**>') kwargs = MockMessage.call_args[1] MockMessage.assert_called_with( to=['Admin1 <*****@*****.**>', 'Admin2 <*****@*****.**>'], from_email='First Last <*****@*****.**>', cc=None, subject=kwargs['subject'], body=kwargs['body'], )
def requestImaging(request, machine_request_id): """ Processes image request, sends an email to [email protected] Returns a response. """ view_link = '%s/api/v1/request_image/%s' \ % (settings.SERVER_URL, machine_request_id) approve_link = '%s/api/v1/request_image/%s/approve' \ % (settings.SERVER_URL, machine_request_id) deny_link = '%s/api/v1/request_image/%s/deny' \ % (settings.SERVER_URL, machine_request_id) machine_request = MachineRequest.objects.get(id=machine_request_id) name = request.POST.get('name', '') instance_id = request.POST.get('instance', '') description = request.POST.get('description', '') software = request.POST.get('installed_software', '') sys_files = request.POST.get('sys', '') tags = request.POST.get('tags', '') public = request.POST.get('vis', '') shared_with = request.POST.get('shared_with', '') username = request.POST.get('owner', request.user.username) message = """ URLs require staff access to view/approve/deny: View Request: %s Auto-Approve Request: %s Auto-Deny Request: %s --- Username : %s Instance ID:%s --- Installed software:%s System Files changed:%s Image visiblity:%s Shared with (Private only):%s --- New Image name:%s New Image description:%s New Image tags:%s """ % ( view_link, approve_link, deny_link, #TODO: This could also be: #machine_request.instance.created_by.username #And we could add another field 'new_image_owner'.. machine_request.new_machine_owner.username, machine_request.instance.provider_alias, machine_request.installed_software, machine_request.iplant_sys_files, machine_request.new_machine_visibility, machine_request.access_list, machine_request.new_machine_name, machine_request.new_machine_description, machine_request.new_machine_tags) subject = 'Atmosphere Imaging Request - %s' % username email_success = email_admin(request, subject, message, cc_user=False) return email_success
def _email(self, user, data): subject = data.pop('subject') message = data.pop('message') email_success = email_admin( self.request, subject, message, data=data) email_response = {"email_sent": email_success} if not email_success: return Response(email_response, status=status.HTTP_400_BAD_REQUEST) return Response(email_response, status=status.HTTP_200_OK)
def _email(self, user, data): """ Sends an email to support based on feedback from a client machine Returns a response. """ username = user.username subject = 'Subject: Atmosphere Client Feedback from %s' % username instances = Instance.objects \ .filter(created_by=user.id) \ .filter(end_date__exact=None) volumes = Volume.objects \ .filter(instance_source__created_by__username=username) \ .filter(instance_source__end_date__isnull=True) context = { "ui": data.get("user-interface", ""), "server": settings.SERVER_URL, "feedback": data["message"], "provider": user.selected_identity.provider_uuid(), "instances": instances, "volumes": volumes, } context.update(request_data(self.request)) body = render_to_string("feedback.html", context=context) email_success = email_admin(self.request, subject, body, request_tracker=True) if email_success: resp_status = status.HTTP_200_OK email_response = { 'result': { 'code': 'success', 'meta': '', 'value': ('Thank you for your feedback! ' 'Support has been notified.') } } else: resp_status = status.HTTP_400_BAD_REQUEST email_response = { 'result': { 'code': 'failed', 'meta': '', 'value': 'Failed to send feedback!' } } return Response(email_response, status=resp_status)
def requestImaging(request, machine_request_id): """ Processes image request, sends an email to [email protected] Returns a response. """ view_link = '%s/api/v1/request_image/%s' \ % (settings.SERVER_URL, machine_request_id) approve_link = '%s/api/v1/request_image/%s/approve' \ % (settings.SERVER_URL, machine_request_id) deny_link = '%s/api/v1/request_image/%s/deny' \ % (settings.SERVER_URL, machine_request_id) machine_request = MachineRequest.objects.get(id=machine_request_id) name = request.POST.get('name', '') instance_id = request.POST.get('instance', '') description = request.POST.get('description', '') software = request.POST.get('installed_software', '') sys_files = request.POST.get('sys', '') tags = request.POST.get('tags', '') public = request.POST.get('vis', '') shared_with = request.POST.get('shared_with', '') username = request.POST.get('owner', request.user.username) message = """ URLs require staff access to view/approve/deny: View Request: %s Auto-Approve Request: %s Auto-Deny Request: %s --- Username : %s Instance ID:%s --- Installed software:%s System Files changed:%s Image visiblity:%s Shared with (Private only):%s --- New Image name:%s New Image description:%s New Image tags:%s """ % (view_link, approve_link, deny_link, #TODO: This could also be: #machine_request.instance.created_by.username #And we could add another field 'new_image_owner'.. machine_request.new_machine_owner.username, machine_request.instance.provider_alias, machine_request.installed_software, machine_request.iplant_sys_files, machine_request.new_machine_visibility, machine_request.access_list, machine_request.new_machine_name, machine_request.new_machine_description, machine_request.new_machine_tags) subject = 'Atmosphere Imaging Request - %s' % username email_success = email_admin(request, subject, message, cc_user=False) return email_success
def _email(self, request, subject, message): """ Sends an email to support. POST Params expected: * user * message * subject Returns a response. """ email_success = email_admin(request, subject, message) return {"email_sent": email_success}
def support_email(request, subject, message): """ Sends an email to support. POST Params expected: * user * message * subject Returns a response. """ email_success = email_admin(request, subject, message, request_tracker=True) return {"email_sent": email_success}
def _email(self, request, subject, message, data): """ Sends an email to support. POST Params expected: * user * message * subject Returns a response. """ data['server'] = settings.SERVER_URL email_success = email_admin(request, subject, message, data=data) return {"email_sent": email_success}
def _email(self, user, data): """ Sends an email to support based on feedback from a client machine Returns a response. """ username = user.username subject = 'Subject: Atmosphere Client Feedback from %s' % username instances = Instance.objects \ .filter(created_by=user.id) \ .filter(end_date__exact=None) volumes = Volume.objects \ .filter(instance_source__created_by__username=username) \ .filter(instance_source__end_date__isnull=True) context = { "ui": data.get("user-interface", ""), "server": settings.SERVER_URL, "feedback": data["message"], "provider": user.selected_identity.provider_uuid(), "instances": instances, "volumes": volumes, } context.update(request_data(self.request)) body = render_to_string("feedback.html", context=context) email_success = email_admin( self.request, subject, body, request_tracker=True) if email_success: resp_status = status.HTTP_200_OK email_response = {'result': {'code': 'success', 'meta': '', 'value': ( 'Thank you for your feedback! ' 'Support has been notified.')}} else: resp_status = status.HTTP_400_BAD_REQUEST email_response = {'result': {'code': 'failed', 'meta': '', 'value': 'Failed to send feedback!'}} return Response(email_response, status=resp_status)
def feedback_email(request, username, user_email, message): """ Sends an email Bto support based on feedback from a client machine Returns a response. """ subject = 'Subject: Atmosphere Client Feedback from %s' % username message = '---\nFeedback: %s\n---' % message email_success = email_admin(request, subject, message) if email_success: resp = {'result': {'code': 'success', 'meta': '', 'value': 'Thank you for your feedback! ' + 'Support has been notified.'}} else: resp = {'result': {'code': 'failed', 'meta': '', 'value': 'Failed to send feedback!'}} return resp
def quota_request_email(request, username, new_quota, reason): """ Processes Increase Quota request. Sends email to [email protected] Returns a response. """ user = User.objects.get(username=username) membership = IdentityMembership.objects.get( identity=user.select_identity(), member__in=user.group_set.all()) admin_url = urlresolvers.reverse('admin:core_identitymembership_change', args=(membership.id, )) message = """ Username : %s Quota Requested: %s Reason for Quota Increase: %s URL for Quota Increase:%s """ % (username, new_quota, reason, request.build_absolute_uri(admin_url)) subject = "Atmosphere Quota Request - %s" % username logger.info(message) email_success = email_admin(request, subject, message, cc_user=False) return {"email_sent": email_success}
def _email(self, request, username, user_email, message): """ Sends an email Bto support based on feedback from a client machine Returns a response. """ subject = "Subject: Atmosphere Client Feedback from %s" % username message = "---\nFeedback: %s\n---" % message email_success = email_admin(request, subject, message) if email_success: resp = {"result": {"code": "success", "meta": "", "value": "Thank you for your feedback! " + "Support has been notified."}} else: resp = {"result": {"code": "failed", "meta": "", "value": "Failed to send feedback!"}} return resp
def quota_request_email(request, username, new_quota, reason): """ Processes Increase Quota request. Sends email to [email protected] Returns a response. """ user = User.objects.get(username=username) membership = IdentityMembership.objects.get(identity=user.select_identity(), member__in=user.group_set.all()) admin_url = urlresolvers.reverse('admin:core_identitymembership_change', args=(membership.id,)) message = """ Username : %s Quota Requested: %s Reason for Quota Increase: %s URL for Quota Increase:%s """ % (username, new_quota, reason, request.build_absolute_uri(admin_url)) subject = "Atmosphere Quota Request - %s" % username logger.info(message) email_success = email_admin(request, subject, message, cc_user=False) return {"email_sent": email_success}
def email_support(request): """ Sends an email to support. POST Params expected: * user * message * subject Returns a response. """ if request.META['REQUEST_METHOD'] != 'POST': return HttpResponse("Expecting POST with message and subject" "parameters.") message = request.POST.get('message') if not message: return HttpResponseServerError( { 'email_sent': False, 'reason': 'Message contents missing' }, content_type='application/json') subject = request.POST.get('subject') if not subject: return HttpResponseServerError( { 'email_sent': False, 'reason': 'E-Mail Subject missing' }, content_type='application/json') email_success = email_admin(request, subject, message) resp = json.dumps({'email_sent': email_success}) if email_success: return HttpResponse(resp, content_type='application/json') else: return HttpResponseServerError(resp, content_type='application/json')
def requestImaging(request, machine_request_id, auto_approve=False): """ Processes image request, sends an email to the user and a sperate email to [email protected] Returns a response. """ #TODO: This could also be: #machine_request.instance.created_by.username #And we could add another field 'new_image_owner'.. machine_request = MachineRequest.objects.get(id=machine_request_id) user = machine_request.new_machine_owner username = user.username full_name = user.get_full_name() if auto_approve: message_header = "Your image request has been approved!"\ " The imaging process will begin shortly.\n" else: view_link = '%s/api/v1/request_image/%s' \ % (settings.SERVER_URL, machine_request_id) approve_link = '%s/api/v1/request_image/%s/approve' \ % (settings.SERVER_URL, machine_request_id) deny_link = '%s/api/v1/request_image/%s/deny' \ % (settings.SERVER_URL, machine_request_id) staff_header = """ ATTN Staff Users: Authenticate to atmosphere, then select any of these URLs to access the approriate action. Are you unable to click on these links? Let one of the Admins know and we will make sure your account is marked as 'staff'. View Request: %s Auto-Approve Request: %s Auto-Deny Request: %s --- """ % (view_link, approve_link, deny_link) message_header = "Your Image Request has been received."\ " Upon staff approval, we will send you an e-mail to let you"\ " know that the the imaging process will begin shortly.\n" #Add appropriate header.. message = message_header + """ When the imaging process has completed, you will receive an email with details about the new image. Your Image Request: Username : %s Full Name: %s Instance ID:%s --- Installed software:%s System Files changed:%s Image visiblity:%s Shared with (Private only):%s --- New Image name:%s New Image description:%s New Image tags:%s """ % (username, full_name, machine_request.instance.provider_alias, machine_request.installed_software, machine_request.iplant_sys_files, machine_request.new_machine_visibility, machine_request.access_list, machine_request.new_machine_name, machine_request.new_machine_description, machine_request.new_machine_tags) subject = 'Atmosphere Imaging Request - %s' % username #First e-mail is 'clean' email_success = email_from_admin(username, subject, message) #Second e-mail contains API urls if not auto_approve: message = "%s\n%s" % (staff_header, message) email_success = email_admin(request, subject, message, cc_user=False) return email_success
def requestImaging(request, machine_request_id, auto_approve=False): """ Processes image request, sends an email to the user and a sperate email to [email protected] Returns a response. """ #TODO: This could also be: #machine_request.instance.created_by.username #And we could add another field 'new_image_owner'.. machine_request = MachineRequest.objects.get(id=machine_request_id) username = machine_request.new_machine_owner.username if auto_approve: message_header = "Your image request has been approved!"\ " The imaging process will begin shortly.\n" else: view_link = '%s/api/v1/request_image/%s' \ % (settings.SERVER_URL, machine_request_id) approve_link = '%s/api/v1/request_image/%s/approve' \ % (settings.SERVER_URL, machine_request_id) deny_link = '%s/api/v1/request_image/%s/deny' \ % (settings.SERVER_URL, machine_request_id) staff_header = """ ATTN Staff Users: Authenticate to atmosphere, then select any of these URLs to access the approriate action. Are you unable to click on these links? Let one of the Admins know and we will make sure your account is marked as 'staff'. View Request: %s Auto-Approve Request: %s Auto-Deny Request: %s --- """ % (view_link, approve_link, deny_link) message_header = "Your Image Request has been received."\ " Upon staff approval, we will send you an e-mail to let you"\ " know that the the imaging process will begin shortly.\n" #Add appropriate header.. message = message_header + """ When the imaging process has completed, you will receive an email with details about the new image. Your Image Request: Username : %s Instance ID:%s --- Installed software:%s System Files changed:%s Image visiblity:%s Shared with (Private only):%s --- New Image name:%s New Image description:%s New Image tags:%s """ % (username, machine_request.instance.provider_alias, machine_request. installed_software, machine_request.iplant_sys_files, machine_request.new_machine_visibility, machine_request.access_list, machine_request.new_machine_name, machine_request. new_machine_description, machine_request.new_machine_tags) subject = 'Atmosphere Imaging Request - %s' % username #First e-mail is 'clean' email_success = email_from_admin(username, subject, message) #Second e-mail contains API urls if not auto_approve: message = "%s\n%s" % (staff_header, message) email_success = email_admin(request, subject, message, cc_user=False) return email_success