Beispiel #1
0
    def post(self, request):
        user_form = CreateUserForm(request.POST)
        profile_form = CreateProfileForm(request.POST)

        print(user_form.errors)
        print(user_form.cleaned_data)

        if user_form.is_valid() and profile_form.is_valid():

            user = User(**user_form.cleaned_data)
            user.save()
            print('User表OK,,,,')

            user_profile = Profile()
            user_profile.user = user
            user_profile.name = profile_form.cleaned_data['name']
            user_profile.lnvalid_date = profile_form.cleaned_data[
                'lnvalid_date']
            user_profile.phone = profile_form.cleaned_data['phone']
            user_profile.weixin = profile_form.cleaned_data['weixin']
            user_profile.info = request.POST.getlist('info', None)[0]
            user_profile.save()

            print('userprofile表OK,,,,')

            if request.POST.get('groups', None):
                user.groups.set(request.POST.getlist('groups'))

            register_email = RegisterEmail()
            register_email.user = user
            register_email.type_code = 0
            register_email.code = random_str()
            register_email.save()

            contnet = """
            <p>你好 %s: </p>
            
            <p>恭喜您,您的账号已经创建成功 </p>

            <p>用户名: %s </p>

            <p><a href='%s'>请点击这里设置密码</a> </p>
            """ % (user.username, user_profile.name,
                   settings.HOST_URL + reverse('user_create_password') +
                   '?code=' + str(register_email.code))

            try:
                send_mail(settings.EMAIL_USER, settings.EMAIL_PASSWORD,
                          user.email, settings.EMAIL_TITLE, contnet,
                          settings.EMAIL_HOST, settings.EMAIL_PORT)
                print('邮件发送OK...')
            except Exception as e:
                print(e)
                print('邮件发送失败...')

        return redirect(reverse('user_list'))
Beispiel #2
0
 def GET(self):
     pars = web.input()
     username = pars['username']
     rt = db.query('select * from user where username=$aa', vars={'aa':username})
     for r in rt:
         email = r['email']
         from utils.sendmail import send_mail
         return send_mail(email, 'checkmail', 'please checkmail http://localhost:8080/checkingmail')
Beispiel #3
0
 def GET(self):
     pars = web.input()
     username = pars['username']
     rt = db.query('select * from user where username=$aa', vars={'aa':username})
     for r in rt:
         password = r['password']
         email = r['email']
         content ='your password is '+password
         from utils.sendmail import send_mail
         return send_mail(email, 'findpassword', content)
Beispiel #4
0
 def GET(self):
     pars = web.input()
     username = pars['username']
     rt = db.query('select * from user where username=$aa',
                   vars={'aa': username})
     for r in rt:
         password = r['password']
         email = r['email']
         content = 'your password is ' + password
         from utils.sendmail import send_mail
         return send_mail(email, 'findpassword', content)
Beispiel #5
0
 def GET(self):
     pars = web.input()
     username = pars['username']
     rt = db.query('select * from user where username=$aa',
                   vars={'aa': username})
     for r in rt:
         email = r['email']
         from utils.sendmail import send_mail
         return send_mail(
             email, 'checkmail',
             'please checkmail http://localhost:8080/checkingmail')
Beispiel #6
0
def send_to_mail(to_list, cc_list, sub, content):
    print(sub)
    send_mail(to_list, cc_list, sub, content)
Beispiel #7
0
 def POST(self, name):
     #return 'i am in POST'
     #return do_action('***') + 'action line' + do_action('***')
     from utils.sendmail import send_mail
     return send_mail('send_to', 'subject', 'body')
Beispiel #8
0
 def POST(self, name):
     #return 'i am in POST'
     #return do_action('***') + 'action line' + do_action('***')
     from utils.sendmail import send_mail
     return send_mail('send_to', 'subject', 'body')
Beispiel #9
0
def send_to_mail(to_list, cc_list, sub, content):
    send_mail(to_list, cc_list, sub, content)