Exemple #1
0
    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)
Exemple #2
0
    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)
Exemple #3
0
    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)
Exemple #4
0
    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 _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"],
            "instances": instances,
            "volumes": volumes,
        }

        context.update(request_data(self.request))

        body = render_to_string("feedback.html", context=context)
        email_success = email_support(subject, body, self.request)
        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)
Exemple #6
0
    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)