From e63a5e4a744b1bb56eaa1af2e139b8a8e315f6ef Mon Sep 17 00:00:00 2001 From: "Schimon Jehudah, Adv." Date: Mon, 16 Sep 2024 13:46:04 +0300 Subject: [PATCH] Improve subscription preview form; Fix adding subscriptions to a custom JID/ --- slixfeed/utilities.py | 6 ++++++ slixfeed/version.py | 4 ++-- slixfeed/xmpp/client.py | 41 +++++++++++++++++++++++------------------ 3 files changed, 31 insertions(+), 20 deletions(-) diff --git a/slixfeed/utilities.py b/slixfeed/utilities.py index 4934782..021dcd8 100644 --- a/slixfeed/utilities.py +++ b/slixfeed/utilities.py @@ -191,6 +191,12 @@ class DateAndTime: return date + def convert_seconds_to_yyyy_mm_dd(seconds_time): + date_time = datetime.fromtimestamp(seconds_time) + formatted_date = date_time.strftime('%Y-%m-%d') + return formatted_date + + def current_date(): """ Print MM DD, YYYY (Weekday Time) timestamp. diff --git a/slixfeed/version.py b/slixfeed/version.py index ea65daf..5290407 100644 --- a/slixfeed/version.py +++ b/slixfeed/version.py @@ -1,2 +1,2 @@ -__version__ = '0.1.97' -__version_info__ = (0, 1, 97) +__version__ = '0.1.98' +__version_info__ = (0, 1, 98) diff --git a/slixfeed/xmpp/client.py b/slixfeed/xmpp/client.py index 4a9b458..8c7590c 100644 --- a/slixfeed/xmpp/client.py +++ b/slixfeed/xmpp/client.py @@ -1802,10 +1802,10 @@ class XmppClient(slixmpp.ClientXMPP): identifier = values['identifier'] if 'identifier' in values else None url = values['subscription'] jid_bare = session['from'].bare - if XmppUtilities.is_operator(self, jid_bare) and 'jid' in values: - custom_jid = values['jid'] - jid_bare = custom_jid[0] if isinstance(custom_jid, list) else jid_bare - # jid_bare = custom_jid[0] if custom_jid else jid_bare + if 'jid' in values: custom_jid = values['jid'] + if XmppUtilities.is_operator(self, jid_bare) and custom_jid: + if isinstance(custom_jid, list): custom_jid = custom_jid[0] + jid_bare = custom_jid or jid_bare form.add_field(var='jid', ftype='hidden', value=jid_bare) @@ -1928,14 +1928,17 @@ class XmppClient(slixmpp.ClientXMPP): feed_id = str(result['index']) entries = sqlite.get_entries_of_feed(db_file, feed_id) renewed, scanned = sqlite.get_last_update_time_of_feed(db_file, - feed_id) - last_updated = renewed or scanned - last_updated = str(last_updated) - options = form.add_field(desc='Recent titles from subscription', - ftype='list-multi', - label='Preview') + feed_id) + last_updated = DateAndTime.convert_seconds_to_yyyy_mm_dd( + float(renewed or scanned)) + form.add_field(desc='Recent titles from subscription', + ftype='fixed', + value='Recent updates') + recent_updates = '' for entry in entries: - options.addOption(entry[1], entry[2]) + recent_updates += '* ' + entry[1] + '\n\n' + form.add_field(ftype='text-multi', + value=recent_updates) form.add_field(ftype='fixed', label='Information') form.add_field(ftype='text-single', @@ -1965,14 +1968,16 @@ class XmppClient(slixmpp.ClientXMPP): feed_id = str(result['index']) entries = sqlite.get_entries_of_feed(db_file, feed_id) renewed, scanned = sqlite.get_last_update_time_of_feed(db_file, - feed_id) - last_updated = renewed or scanned - last_updated = str(last_updated) - options = form.add_field(desc='Recent titles from subscription', - ftype='list-multi', - label='Preview') + feed_id) + last_updated = DateAndTime.convert_seconds_to_yyyy_mm_dd( + float(renewed or scanned)) + options = form.add_field(ftype='fixed', + value='Recent updates') + recent_updates = '' for entry in entries: - options.addOption(entry[1], entry[2]) + recent_updates += '* ' + entry[1] + '\n\n' + form.add_field(ftype='text-multi', + value=recent_updates) form.add_field(ftype='fixed', label='Information') form.add_field(ftype='text-single',