show error message for invalid tweet archive
This commit is contained in:
parent
a6678f1057
commit
7d4e9945a5
10
routes.py
10
routes.py
|
@ -6,6 +6,7 @@ from lib import require_auth
|
||||||
from model import Account, Session, Post, TwitterArchive
|
from model import Account, Session, Post, TwitterArchive
|
||||||
from app import app, db, sentry
|
from app import app, db, sentry
|
||||||
import tasks
|
import tasks
|
||||||
|
from zipfile import BadZipFile
|
||||||
|
|
||||||
@app.before_request
|
@app.before_request
|
||||||
def load_viewer():
|
def load_viewer():
|
||||||
|
@ -68,9 +69,14 @@ def upload_tweet_archive():
|
||||||
db.session.add(ta)
|
db.session.add(ta)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
tasks.chunk_twitter_archive(ta.id)
|
try:
|
||||||
|
tasks.chunk_twitter_archive(ta.id)
|
||||||
|
|
||||||
return redirect(url_for('index', _anchor='recent_archives'))
|
assert ta.chunks > 0
|
||||||
|
|
||||||
|
return redirect(url_for('index', _anchor='recent_archives'))
|
||||||
|
except (BadZipFile, AssertionError):
|
||||||
|
return redirect(url_for('index', error='The file you uploaded is not a valid tweet archive. No posts have been imported.'))
|
||||||
|
|
||||||
@app.route('/settings', methods=('POST',))
|
@app.route('/settings', methods=('POST',))
|
||||||
@require_auth
|
@require_auth
|
||||||
|
|
|
@ -2,6 +2,12 @@
|
||||||
{% extends 'lib/layout.html' %}
|
{% extends 'lib/layout.html' %}
|
||||||
{% block body -%}
|
{% block body -%}
|
||||||
|
|
||||||
|
{% if error %}
|
||||||
|
<section class=banners>
|
||||||
|
<div class="banner error">{{ error|safe }}</div>
|
||||||
|
</section>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<section class=viewer>
|
<section class=viewer>
|
||||||
<p>Hello,
|
<p>Hello,
|
||||||
<img class=avatar src="{{g.viewer.account.avatar_url}}"/>
|
<img class=avatar src="{{g.viewer.account.avatar_url}}"/>
|
||||||
|
|
Loading…
Reference in New Issue