Exemplo n.º 1
0
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)
Exemplo n.º 2
0
def data(fid):
    formlinks = FormLink.objects(creator=current_user.to_dbref())
    formlink = FormLink.objects(fid=fid).first()
    # print 'formlink:', formlink
    threads = Thread.objects(formlink=formlink)
    return render_template('forms/dashboard.html', fid=fid,
                           threads=threads, formlinks=formlinks)
Exemplo n.º 3
0
def inbound():
    if request.method == 'POST':
        InboundData(raw=request.form).save()
        text = None
        subject = request.form['subject'].decode('utf-8')
        print subject
        reg = re.compile(ur"[\[]DFNR:(\d+)[-](\d+)[\]]".decode('utf-8'))
        fid = int(re.search(reg, subject).group(1))
        tid = int(re.search(reg, subject).group(2))
        if request.form['text']:
            text = request.form['text'].split('\n')[0]

        form_data = FormData()
        form_data.thread = Thread.objects(tid=tid).first().to_dbref()
        form_data.load = {'message': text}
        form_data.save()
    return ''
Exemplo n.º 4
0
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))