コード例 #1
0
ファイル: processes.py プロジェクト: BarbaraEMac/Side-Project
    def post( self ):
        title = self.request.get('title')
        text  = self.request.get('text')
        email = self.request.get('email')
        owner = self.request.get('owner')
        store_name = self.request.get('store_name')
        store_url  = self.request.get('store_url')
        
        # Make the feedback obj.
        Feedback.create( text, email )

        url = ''
        # Try to get url:
        try:
            url = urlparse(self.request.headers.get('referer'))
        except:
            pass

        if url == '':
            url = os.environ['HTTP_REFERER']

        # Email Barbara
        Email.emailBarbara( '<p>[%s]:</p> <p>%s: %s</p> <p>%s</p> <p>%s</p> <p>%s</p><p>%s</p>' % (title, owner, email, text, store_name, store_url, url) )

        self.response.out.write("Thanks!") 
コード例 #2
0
ファイル: views.py プロジェクト: gmist/3dhero.ru
def index():
    master_db = Config.get_master_db()
    if master_db.recaptcha_public_key and master_db.recaptcha_private_key:
        if not flask.request.headers.getlist("X-Forwarded-For"):
            ip = flask.request.remote_addr
        else:
            ip = flask.request.headers.getlist("X-Forwarded-For")[0]
        form = FeedbackCaptchaForm(captcha={
            'ip_address': ip,
            'public_key': master_db.recaptcha_public_key,
            'private_key': master_db.recaptcha_private_key
        })
        use_captcha = True
    else:
        form = FeedbackForm()
        use_captcha = False
    if form.validate_on_submit():
        feedback = Feedback()
        form.populate_obj(feedback)
        feedback.put()
        feedback_email = master_db.feedback_email
        managers = Manager.query()
        if feedback_email and managers:
            subject = u'[%s] Сообщение - %s' % (
                master_db.brand_name,
                form.subject.data
            )
            body = u'%s\n\n%s' % (form.feedback.data, form.email.data)
            for manager in managers:
                if manager.email and manager.is_mailable:
                    emails = collect_emails(manager.email)
                    for email in emails:
                        mail.send_mail(
                            sender=master_db.feedback_email,
                            to=email,
                            subject=subject,
                            reply_to=form.email.data or master_db.feedback_email,
                            body=body
                        )
        flask.flash(u'Спасибо за Ваш отзыв!', category='success')
        return flask.redirect(flask.url_for('pages.index'))
    if not form.errors and current_user_id() > 0:
        form.email.data = current_user_db().email
    return flask.render_template(
        'feedback/index.html',
        title=u'Обратная связь',
        html_class='feedback',
        form=form,
        use_captcha=use_captcha
    )
コード例 #3
0
ファイル: views.py プロジェクト: minimedj/3dhero.ru
def index():
    master_db = Config.get_master_db()
    if master_db.recaptcha_public_key and master_db.recaptcha_private_key:
        if not flask.request.headers.getlist("X-Forwarded-For"):
            ip = flask.request.remote_addr
        else:
            ip = flask.request.headers.getlist("X-Forwarded-For")[0]
        form = FeedbackCaptchaForm(
            captcha={
                'ip_address': ip,
                'public_key': master_db.recaptcha_public_key,
                'private_key': master_db.recaptcha_private_key
            })
        use_captcha = True
    else:
        form = FeedbackForm()
        use_captcha = False
    if form.validate_on_submit():
        feedback = Feedback()
        form.populate_obj(feedback)
        feedback.put()
        feedback_email = master_db.feedback_email
        managers = Manager.query()
        if feedback_email and managers:
            subject = u'[%s] Сообщение - %s' % (master_db.brand_name,
                                                form.subject.data)
            body = u'%s\n\n%s' % (form.feedback.data, form.email.data)
            for manager in managers:
                if manager.email and manager.is_mailable:
                    emails = collect_emails(manager.email)
                    for email in emails:
                        mail.send_mail(sender=master_db.feedback_email,
                                       to=email,
                                       subject=subject,
                                       reply_to=form.email.data
                                       or master_db.feedback_email,
                                       body=body)
        flask.flash(u'Спасибо за Ваш отзыв!', category='success')
        return flask.redirect(flask.url_for('pages.index'))
    if not form.errors and current_user_id() > 0:
        form.email.data = current_user_db().email
    return flask.render_template('feedback/index.html',
                                 title=u'Обратная связь',
                                 html_class='feedback',
                                 form=form,
                                 use_captcha=use_captcha)
コード例 #4
0
ファイル: views.py プロジェクト: minimedj/3dhero.ru
def view_feedback(key_id):
    feedback = Feedback.retrieve_by_id(key_id)
    if not feedback:
        return redirect(url_for('admin.feedback.index'))
    if request.method == 'POST' and 'delete_feedback' in request.form:
        feedback.key.delete()
        return redirect(url_for('admin.feedback.index'))
    return render_template('admin/feedback/view.html', feedback=feedback)
コード例 #5
0
ファイル: views.py プロジェクト: gmist/3dhero.ru
def view_feedback(key_id):
    feedback = Feedback.retrieve_by_id(key_id)
    if not feedback:
        return redirect(url_for('admin.feedback.index'))
    if request.method == 'POST' and 'delete_feedback' in request.form:
        feedback.key.delete()
        return redirect(url_for('admin.feedback.index'))
    return render_template(
        'admin/feedback/view.html',
        feedback=feedback
    )
コード例 #6
0
ファイル: views.py プロジェクト: gmist/3dhero.ru
def index():
    feedbacks = Feedback.query().order(-Feedback.created)
    return render_template(
        'admin/feedback/index.html',
        feedbacks=feedbacks
    )
コード例 #7
0
ファイル: views.py プロジェクト: minimedj/3dhero.ru
def index():
    feedbacks = Feedback.query().order(-Feedback.created)
    return render_template('admin/feedback/index.html', feedbacks=feedbacks)