Пример #1
0
    def send_welcome_email(self, user):
        emails = [user.email]
        subject = "Welcome to Decisive!"
        template = 'account/email/welcome_email.html'
        context = None

        try:
            results = ViewHelper.send_html_email(emails, subject, template,
                                                 context)
            msg = "Email sent to {}. [Code {}]".format(user.email, results)
            print(msg)
        except Exception as e:
            if hasattr(e, 'message'):
                print(e.message)
            else:
                print(e)
Пример #2
0
def cheetah5_report(request):
    parsed = ViewHelper.parse_request_path(request, navigation())
    module = ViewHelper.load_module(request, 'cheetah5_apply', Module)

    context = {
        'biases_results': ViewHelper.load_json(module.biases),
        'cheetah_sheet': cheetah_sheet4,
        'module': module,
        'my_bias': ViewHelper.load_json(module.my_bias),
        'my_bias_impact': ViewHelper.load_json(module.my_bias_impact),
        'my_bias_remedy': ViewHelper.load_json(module.my_bias_remedy),
        'my_remedy': ViewHelper.load_json(module.my_remedy),
        'nav': parsed,
        'questions': Module.get_game2_questions(),
    }

    if parsed['currentStep'] == 'cheetah5_email':
        data = {}
        if request.user.is_authenticated():
            emails = [request.user.email]
            subject = "AREA Module {0}: Own it: Apply to real life!".format(
                module.display_num())
            template = 'module2/cheetah5/email.html'

            try:
                results = ViewHelper.send_html_email(emails, subject, template,
                                                     context)
                msg = "Email sent to {}. [Code {}]".format(
                    request.user.email, results)
            except Exception as e:
                if hasattr(e, 'message'):
                    print("Exception: " + e.message)
                else:
                    print("Exception: " + e)

                msg = "Unable to send email. There was an internal server error. Try again later."
        else:
            msg = "User is not authenticated. Cannot send email."

        data['message'] = msg
        print("Email: {0} to {1}".format(data['message'], request.user.email))
        return JsonResponse(data)

    return render_page(request, module, parsed, context)
Пример #3
0
def cheetah1_report(request):
    parsed = ViewHelper.parse_request_path(request, navigation())
    module = ViewHelper.load_module(request, parsed['currentStep'], Module)
    cheetah_sheet = CheetahSheet()

    context = {
        'ca': ViewHelper.load_json(module.cheetah_answers),
        'cheetah_sheet': cheetah_sheet,
        'module': module,
        'nav': parsed,
    }

    if parsed['currentStep'] == 'cheetah1_email':
        data = {}
        if request.user.is_authenticated():
            emails = [request.user.email]
            subject = "AREA Module {0}: Own it: Apply to real life!".format(
                module.display_num())
            template = 'module0/cheetah1/email.html'

            try:
                results = ViewHelper.send_html_email(emails, subject, template,
                                                     context)
                msg = "Email sent to {}. [Code {}]".format(
                    request.user.email, results)
            except Exception as e:
                if hasattr(e, 'message'):
                    print(e.message)
                else:
                    print(e)

                msg = "Unable to send email. There was a server error."
        else:
            msg = "User is not authenticated. Cannot send email."

        data['message'] = msg
        return JsonResponse(data)

    return render_page(request, module, parsed, context)