diff --git a/model.py b/model.py index 69de870..fc64403 100644 --- a/model.py +++ b/model.py @@ -53,6 +53,7 @@ class Account(db.Model, TimestampMixin, RemoteIDMixin): self.last_fetch = db.func.now() # backref: tokens + # backref: twitter_archives def __repr__(self): return f"" @@ -91,8 +92,8 @@ class TwitterArchive(db.Model, TimestampMixin): id = db.Column(db.Integer, primary_key=True) account_id = db.Column(db.String, db.ForeignKey('accounts.id'), nullable=False) - account = db.relationship(Account) - body = db.Column(db.LargeBinary, nullable=False) + account = db.relationship(Account, backref=db.backref('twitter_archives', order_by=lambda: db.desc(TwitterArchive.id))) + body = db.deferred(db.Column(db.LargeBinary, nullable=False)) chunks = db.Column(db.Integer) chunks_successful = db.Column(db.Integer, server_default='0') chunks_failed = db.Column(db.Integer, server_default='0') diff --git a/templates/index.html b/templates/index.html index 314b031..987c787 100644 --- a/templates/index.html +++ b/templates/index.html @@ -1,3 +1,5 @@ +

Forget

+ {% if g.viewer %}

Hello, @@ -6,7 +8,7 @@ Log out

-

your posts ({{g.viewer.account.post_count()}}):

+

Recent posts ({{g.viewer.account.post_count()}} total posts):

{% for post in posts %}

{{post.body}}

diff --git a/templates/settings.html b/templates/settings.html index e467936..c935f64 100644 --- a/templates/settings.html +++ b/templates/settings.html @@ -2,6 +2,9 @@

Settings

+ {% if request.method == 'POST' %} +

Settings saved successfully

+ {% endif %}

Delete posts: @@ -28,9 +31,18 @@

{% if g.viewer.account.service == 'twitter' %} +

Tweet archive import

Upload your tweet archive:
+ +

Recent tweet archive imports

+{% for archive in g.viewer.account.twitter_archives %} +

{{archive.created_at}} {{archive.chunks_successful}}/{{archive.chunks}} months successfully imported, {{archive.chunks_failed}} failed

+{% else %} +

No recent archives found

+{% endfor %} + {% endif %} diff --git a/templates/upload_tweet_archive.html b/templates/upload_tweet_archive.html index d7a90f8..acbe641 100644 --- a/templates/upload_tweet_archive.html +++ b/templates/upload_tweet_archive.html @@ -1 +1 @@ -

Your archive will be processed shortly. Back

+

Your archive will be processed shortly. Back