Beispiel #1
0
def index():
    if current_user.is_authenticated:
        return redirect('/daily')
    else:
        editable_html_obj = EditableHTML.get_editable_html('index')
        return render_template('main/index.html',
                               editable_html_obj=editable_html_obj)
Beispiel #2
0
def text(text_type):
    website_settings = MSettings.query.first()
    editable_html_obj = EditableHTML.get_editable_html(text_type)
    return jsonify({
        'status': 1,
        'editable_html_obj': editable_html_obj.serialize
    })
Beispiel #3
0
def daily():
    editable_html_obj = EditableHTML.get_editable_html('daily')

    if request.method == 'POST':
        data = request.get_json()
        id = int(data['id'])
        habit = Habit.query.get(id)
        habit.complete = data['complete']
        db.session.commit()
    habits = current_user.habits
    return render_template('main/daily.html',
                           editable_html_obj=editable_html_obj,
                           habits=habits)
Beispiel #4
0
def contact():
    if current_user.is_authenticated:
        form = ContactForm()
    else:
        form = PublicContactForm()
    editable_html_obj = EditableHTML.get_editable_html('contact')
    if request.method == 'POST':
        if form.validate_on_submit():
            if not recaptcha.verify():
                flash("Wrong Captcha, pls try again", 'error')
                return redirect(url_for("public.contact"))
            spam_detect = SpamDetector()

            if current_user.is_authenticated:
                spam_detect.setMessage(form.text.data)
                text_spam = spam_detect.predict()
                spam = False
                if 1 in text_spam:
                    spam = True
                contact_message = ContactMessage(
                    user_id=current_user.id,
                    text=form.text.data,
                    spam=spam
                )
            else:
                spam_detect.setMessage(form.name.data)
                name_spam = spam_detect.predict()
                spam_detect.setMessage(form.text.data)
                text_spam = spam_detect.predict()
                spam = False
                if 1 in name_spam or 1 in text_spam:
                    spam = True
                email = form.email.data
                is_valid = validate_email(email, check_mx=False)
                if not is_valid:
                    flash("The email you entered doesn't exist, pls insert a valid email", 'error')
                    return redirect(url_for("public.contact"))
                contact_message = ContactMessage(
                    name=form.name.data,
                    email=email,
                    text=form.text.data,
                    spam=spam
                )
            db.session.add(contact_message)
            db.session.commit()
            flash('Successfully sent contact message.', 'success')
            return redirect(url_for('public.contact'))
    return render_template('public/contact.html', editable_html_obj=editable_html_obj, form=form)
Beispiel #5
0
def texts():
    editable_html_obj = EditableHTML.get_editable_html('contact')
    if request.method == 'POST':
        edit_data = request.form.get('edit_data')
        editor_name = request.form.get('editor_name')

        editor_contents = EditableHTML.query.filter_by(
            editor_name=editor_name).first()
        if editor_contents is None:
            editor_contents = EditableHTML(editor_name=editor_name)
        editor_contents.value = edit_data

        db.session.add(editor_contents)
        db.session.commit()
        flash('Successfully updated text.', 'success')
        return redirect(url_for('admin.texts'))
    return render_template('admin/texts/index.html', editable_html_obj=editable_html_obj)
Beispiel #6
0
def contact():
    if current_user.is_authenticated:
        form = ContactForm()
    else:
        form = PublicContactForm()
    editable_html_obj = EditableHTML.get_editable_html('contact')
    if request.method == 'POST':
        if form.validate_on_submit():
            if current_user.is_authenticated:
                contact_message = ContactMessage(user_id=current_user.id,
                                                 text=form.text.data)
            else:
                contact_message = ContactMessage(name=form.name.data,
                                                 email=form.email.data,
                                                 text=form.text.data)
            db.session.add(contact_message)
            db.session.commit()
            flash('Successfully sent contact message.', 'success')
            return redirect(url_for('public.contact'))
    return render_template('public/contact.html',
                           editable_html_obj=editable_html_obj,
                           form=form)
Beispiel #7
0
def faq():
    editable_html_obj = EditableHTML.get_editable_html('faq')
    return render_template('public/faq.html', editable_html_obj=editable_html_obj)
def about():
    editable_html_obj = EditableHTML.get_editable_html('about')
    return render_template('main/about.html',
                           editable_html_obj=editable_html_obj)
Beispiel #9
0
def privacy():
    editable_html_obj = EditableHTML.get_editable_html('privacy')
    return render_template('public/privacy.html', editable_html_obj=editable_html_obj)
Beispiel #10
0
def terms():
    editable_html_obj = EditableHTML.get_editable_html('terms')
    return render_template('public/terms.html', editable_html_obj=editable_html_obj)
Beispiel #11
0
def donate():
    editable_html_obj = EditableHTML.get_editable_html('donate')
    return render_template(
        'main/privacy.html', editable_html_obj=editable_html_obj)
Beispiel #12
0
def faq():
    editable_html_obj = EditableHTML.get_editable_html('faq')
    return render_template('main/faq.html',
                           editable_html_obj=editable_html_obj)
Beispiel #13
0
def update_form_instructions():
    """Update the email confirmation upon room request submission."""
    editable_html_obj = EditableHTML.get_editable_html("form_instructions")
    return render_template('room_request/edit_text.html',
                           editable_html_obj=editable_html_obj,
                           title="Form Instructions")
Beispiel #14
0
def monthly():
    editable_html_obj = EditableHTML.get_editable_html('monthly')
    return render_template('main/monthly.html',
                           editable_html_obj=editable_html_obj)
Beispiel #15
0
def about():
    editable_html_obj = EditableHTML.get_editable_html('about')
    return render_template('main/about.html',
                           editable_html_obj=editable_html_obj)
Beispiel #16
0
def update_home():
    editable_html_obj = EditableHTML.get_editable_html('home_page_language')
    return render_template('room_request/edit_text.html',
                           editable_html_obj=editable_html_obj,
                           title="Home Page Language")
Beispiel #17
0
def text(text_type):
    editable_html_obj = EditableHTML.get_editable_html(text_type)
    return jsonify({
        'status': 1,
        'editable_html_obj': editable_html_obj.serialize
    })
Beispiel #18
0
def faq():
    website_settings = MSettings.query.first()
    editable_html_obj = EditableHTML.get_editable_html('faq')
    return render_template('public/faq.html',
                           website_settings=website_settings,
                           editable_html_obj=editable_html_obj)
Beispiel #19
0
def privacy():
    website_settings = MSettings.query.first()
    editable_html_obj = EditableHTML.get_editable_html('privacy')
    return render_template('public/privacy.html',
                           website_settings=website_settings,
                           editable_html_obj=editable_html_obj)
Beispiel #20
0
def about():
    editable_html_obj = EditableHTML.get_editable_html("about")
    return render_template("main/about.html", editable_html_obj=editable_html_obj)
Beispiel #21
0
def habits():
    editable_html_obj = EditableHTML.get_editable_html('habits')
    habits = current_user.habits
    return render_template('main/habits.html',
                           editable_html_obj=editable_html_obj,
                           habits=habits)
Beispiel #22
0
def index():
    editable_html_obj = EditableHTML.get_editable_html("home_page_language")
    return render_template('main/index.html',
                           editable_html_obj=editable_html_obj)
Beispiel #23
0
def update_email_confirmation():
    editable_html_obj = EditableHTML.get_editable_html('email_confirmation')
    return render_template('room_request/edit_text.html',
                           editable_html_obj=editable_html_obj,
                           title="Confirmation Email")