示例#1
0
文件: views.py 项目: abdelhai/dyform
def data_view(fid, tid):
    formlinks = FormLink.objects(creator=current_user.to_dbref())
    formlink = FormLink.objects(fid=fid).first()
    # print 'formlink:', formlink
    threads = Thread.objects(formlink=formlink)
    thread = Thread.objects(tid=tid).first()
    datas = FormData.objects(thread=thread).order_by('id')
    main = FormData.objects(thread=thread).order_by('id').first()
    # for x in mains:
    #     print 'hhhhhh', x.load
    # main =  None
    return render_template('forms/dashboard.html', fid=fid, datas=datas,
                           threads=threads, formlinks=formlinks, tid=tid, main=main)
示例#2
0
文件: views.py 项目: abdelhai/dyform
def send_email(fid, tid):
    body = request.form.get('message')
    thread = Thread.objects(tid=tid).first()
    data = FormData.objects(thread=thread).order_by('id').first()
    email = data.load['email']
    email_address = current_user.username + '@mail.dyform.co'

    subject = 'Reply To: ' + '[DFNR:' + str(fid) + '-' + str(tid) + ']'

    message = sendgrid.Mail(to=email, subject=subject,
                            text=body, from_email=email_address)
    status, msg = sg.send(message)
    form_data = FormData()
    form_data.thread = thread.to_dbref()
    form_data.load = {"message": body,
                      "from": current_user.username + '@mail.dyform.co'}
    form_data.save()

    return redirect(url_for('forms.data_view', fid=fid, tid=tid))