Esempio n. 1
0
def download_avater(request):
    avatar_url = os.path.join('media', str(request.user.avatar))
    #file_name = os.path.basename(str(request.user.avatar))
    response = FileResponse(open(avatar_url, 'rb'))
    response['Content-Type'] = 'application/octet-stream'
    response['Content-Disposition'] = 'attachment;filename="user_avater.jpg"'
    utils.channel_send_msg('user_' + request.user.username, '所需下载的文件已准备好。')
    return response
Esempio n. 2
0
def celery_senm_mail(username, email):
    subject, from_email, to_email = '来自FDD的异步测试邮件', settings.DEFAULT_FROM_EMAIL, email
    html_content = utils.activation_html_content(username)
    msg = EmailMessage(subject, html_content, from_email, [to_email])
    msg.content_subtype = "html"  # Main content is now text/html
    msg.send()

    utils.channel_send_msg('user_' + username, 'Celery已发送测试邮件!')
Esempio n. 3
0
def celery_send_maile(request):
	if not  request.user.is_authenticated:
		return JsonResponse({'status':"error-User not logged in"})
	
	if 'hassendmail' in request.session:
		return JsonResponse({'status':"error-Already sent once!"})

	utils.channel_send_msg('user_'+request.user.username,'后台已收到发送邮件任务!')
	#发送验证邮件---------------------------
	if request.user.email:
		celery_task.celery_senm_mail.delay(request.user.username,request.user.email)
		request.session['hassendmail'] = True
		return JsonResponse({'status':"success"})
	else:
		return JsonResponse({'status':"error-The current user has not set a mailbox!"})