diff --git a/flaskr/__init__.py b/flaskr/__init__.py index 33779f8..7d7ec81 100644 --- a/flaskr/__init__.py +++ b/flaskr/__init__.py @@ -8,7 +8,7 @@ def create_app(test_config=None): app.config.from_mapping( SECRET_KEY='dev', DATABASE=os.path.join(app.instance_path, 'flaskr.sqlite'), - ALLOW_REGISTER=True, + ALLOW_REGISTER=False, ) app.wsgi_app = ProxyFix( diff --git a/flaskr/blog.py b/flaskr/blog.py index 8082d2f..523cfaf 100644 --- a/flaskr/blog.py +++ b/flaskr/blog.py @@ -28,23 +28,6 @@ def index(): posts.append(post) return render_template('blog/index.html', posts=posts) -@bp.route('/firehose') -def firehose(): - db = get_db() - db_posts = db.execute( - 'SELECT p.id, title, body, created, author_id, username' - ' FROM post p JOIN user u ON p.author_id = u.id' - ' ORDER BY created DESC' - ).fetchall() - posts = [] - for post in db_posts: - if post['created'] > datetime.datetime.utcnow(): - continue - post = dict(post) - post['body'] = markdown.markdown(post['body']) - posts.append(post) - return render_template('blog/firehose.html', posts=posts) - @bp.route('/create',methods=('GET', 'POST')) @login_required def create(): @@ -86,12 +69,6 @@ def get_post(id, check_author=True): return post -@bp.route('//') -def individual_post(id): - post = dict(get_post(id, False)) - post['body'] = markdown.markdown(post['body']) - return render_template('blog/post.html', post=post) - @bp.route('//update', methods=('GET', 'POST')) @login_required def update(id): diff --git a/flaskr/templates/blog/firehose.html b/flaskr/templates/blog/firehose.html deleted file mode 100644 index 21e3178..0000000 --- a/flaskr/templates/blog/firehose.html +++ /dev/null @@ -1,28 +0,0 @@ -{% extends 'base.html' %} - -{% block header %} -

{% block title %}Posts{% endblock %}

- {% if g.user %} - New - {% endif %} -{% endblock %} - -{% block content %} - {% for post in posts %} -
-
-
-

{{ post['title'] }}

-
by {{ post['username'] }} on {{ post['created'].strftime('%Y-%m-%d') }}
-
- {% if g.user['id'] == post['author_id'] %} - Edit - {% endif %} -
-

{{ post['body']|safe }}

-
- {% if not loop.last %} -
- {% endif %} - {% endfor %} -{% endblock %} diff --git a/flaskr/templates/blog/index.html b/flaskr/templates/blog/index.html index f50de7f..ffd9fbc 100644 --- a/flaskr/templates/blog/index.html +++ b/flaskr/templates/blog/index.html @@ -12,13 +12,14 @@
-

{{ post['title'] }}

+

{{ post['title'] }}

by {{ post['username'] }} on {{ post['created'].strftime('%Y-%m-%d') }}
{% if g.user['id'] == post['author_id'] %} Edit {% endif %}
+

{{ post['body']|safe }}

{% if not loop.last %}
diff --git a/flaskr/templates/blog/post.html b/flaskr/templates/blog/post.html deleted file mode 100644 index c2a612c..0000000 --- a/flaskr/templates/blog/post.html +++ /dev/null @@ -1,19 +0,0 @@ -{% extends 'base.html' %} - -{% block header %} -

{% block title %}{{ post['title'] }}{% endblock %}

-{% endblock %} - -{% block content %} -
-
-
-
by {{ post['username'] }} on {{ post['created'].strftime('%Y-%m-%d') }}
-
- {% if g.user['id'] == post['author_id'] %} - Edit - {% endif %} -
-

{{ post['body']|safe }}

-
-{% endblock %} diff --git a/tests/test_blog.py b/tests/test_blog.py index 548363a..810ade1 100644 --- a/tests/test_blog.py +++ b/tests/test_blog.py @@ -11,29 +11,9 @@ def test_index(client, auth): assert b'Log Out' in response.data assert b'test title' in response.data assert b'by test on 2018-01-01' in response.data - assert b'test\nbody' not in response.data - assert b'href="/1/update"' in response.data - assert b'href="/1/"' in response.data - -def test_firehose(client, auth): - response = client.get('/') - assert b"Log In" not in response.data - assert b"Register" not in response.data - - auth.login() - response = client.get('/firehose') - assert b'Log Out' in response.data - assert b'test title' in response.data - assert b'by test on 2018-01-01' in response.data assert b'test\nbody' in response.data assert b'href="/1/update"' in response.data -def test_individual_page(client, auth): - response = client.get('/1/') - assert b'test title' in response.data - assert b'by test on 2018-01-01' in response.data - assert b'test\nbody' in response.data - @pytest.mark.parametrize('path', ( '/create', '/1/update',