コード例 #1
0
def recovery(request):
    """Recovery action"""

    data = request.DATA

    data = helpers.set_null_values_if_not_exist(data, get_fields())

    data['email'] = data['email'].lower()

    user = get_item_by_email(request, data['email'])

    code = Code.objects.create(text=helpers.make_code(), created_user=user, type=1)

    from ..home.helpers import get_config
    from ..manager.properties import resource as properties_resource

    config = get_config(request)
    config['code'] = code.text
    config['user_first_name'] = user.first_name
    config['properties'] = properties_resource.get_list_of_names(['SITE_TITLE', 'SITE_DESCRIPTION', 'SITE_NAME',
                                                                  'SITE_LOGO'])
    helpers.send_mail(subject=ugettext('Reset password'),
                      html_content=render_to_string(
                          'account/templates/%s/%s/reset.email.htm' % (settings.THEME, get_language()), config),
                      text_content=render_to_string(
                          'account/templates/%s/%s/reset.email.txt' % (settings.THEME, get_language()), config),
                      to_email=[data['email']],
                      config=config)

    return {'code': 'ok', 'data': [data['email']]}, 200, user
コード例 #2
0
def send(request):
    data = request.DATA

    data = helpers.set_null_values_if_not_exist(data, get_fields(), '')

    data['email'] = data['email'].lower()

    config = {}
    config['email'] = data['email']
    config['username'] = data['username']
    config['message'] = data['message']
    config['properties'] = properties_resource.get_list_of_names(['SITE_TITLE', 'SITE_DESCRIPTION', 'SITE_NAME',
                                                                  'SITE_LOGO'])

    helpers.send_mail(subject=ugettext('Message from contact form'),
                      html_content=render_to_string(
                          'contact/templates/%s/%s/message.email.htm' % (settings.THEME, get_language()), config),
                      text_content=render_to_string(
                          'contact/templates/%s/%s/message.email.txt' % (settings.THEME, get_language()), config),
                      config=config)

    return {'code': 'ok', 'data': [data['email']]}, 200, data['email']