diff --git a/main.cfg.dist b/main.cfg.dist index 8137962..e5cff94 100644 --- a/main.cfg.dist +++ b/main.cfg.dist @@ -11,3 +11,4 @@ AT_API_URL = "https://at.hackerspace.pl/api" OPEN_DAY_WEEKDAY = 4 # Thursday (according to %w of http://docs.python.org/2/library/time.html#time.strftime) OPEN_DAY_BEGIN_HOUR = 18 +SESSION_TYPE = filesystem diff --git a/main.py b/main.py index a91109f..a717ea0 100644 --- a/main.py +++ b/main.py @@ -6,12 +6,17 @@ import string import random import json from flask import Flask, render_template, request, flash, session, abort, jsonify, redirect +from flask_session import Session +from flask_session_captcha import FlaskSessionCaptcha from time import mktime, strftime from datetime import datetime app = Flask('main') app.config.from_pyfile('main.cfg') +Session(app) +captcha = FlaskSessionCaptcha(app) + def pull_feed_entries(): all_entries = [] for tag, url in app.config['FEEDS']: @@ -34,8 +39,9 @@ def mailman_subscribe(email, mailing_list): return True def parse_subscribe_requests(): - flash(u"Subskrypcje tymczasowo wyłączone.", "error") - return + if not captcha.validate(): + flash(u"Nie rozwiązano poprawnie CAPTCHA.", "error") + return if "email" in request.form: email = request.form["email"].strip() if len(email) > 0: diff --git a/requirements.txt b/requirements.txt index f04886c..ee1a7b2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,12 +1,16 @@ +captcha==0.3 certifi==2019.3.9 chardet==3.0.4 Click==7.0 feedparser==5.2.1 Flask==1.0.2 +Flask-Session==0.3.1 +flask-session-captcha==1.1.0 idna==2.8 itsdangerous==1.1.0 Jinja2==2.10 MarkupSafe==1.1.1 +Pillow==5.4.1 requests==2.21.0 six==1.12.0 urllib3==1.24.1 diff --git a/static/main.css b/static/main.css index 26a55ea..cfda0e8 100644 --- a/static/main.css +++ b/static/main.css @@ -64,7 +64,7 @@ ul.news li { #about { border-bottom: 2px groove #fff; - padding: 5px; + padding: 15px; } #hs_branding { @@ -97,12 +97,12 @@ span.author { #left { border-right: 2px groove #fff; - margin-right: 270px; + margin-right: 320px; } #right { position: absolute; - width: 250px; + width: 300px; top: 100px; padding-top: 16px; right: 0; @@ -203,6 +203,26 @@ div.mail-desc { line-height: 15px; } +div.mail-captcha { + width: 276px; + height: 40px; +} +div.mail-captcha img { + border: 1px groove #777; + width: 80px; + height: 30px; + float: left; +} + +div.mail-captcha input { + float: left; + width: 178px !important; + height: 26px !important; + margin-top: 0 !important; + margin-bottom: 0 !important; + margin-right: 0 !important; +} + div.flashes { padding: 0; margin-left: auto; @@ -228,4 +248,4 @@ div.flashes li { div.flashes li.error { background-color: #a01023; -} \ No newline at end of file +} diff --git a/templates/about.html b/templates/about.html index 01b9819..6ae1ed1 100644 --- a/templates/about.html +++ b/templates/about.html @@ -66,21 +66,7 @@