From 8622d7c672538820ce2e7d210c73461bfd8e9504 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Fri, 25 Nov 2022 20:52:47 +0000 Subject: [PATCH] Default month and year when adding a new reminder --- daemon.py | 25 ++++++++++++++++++++++--- webapp_calendar.py | 3 ++- webapp_create_post.py | 9 ++++++++- 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/daemon.py b/daemon.py index bb57eb85c..af91253c1 100644 --- a/daemon.py +++ b/daemon.py @@ -3495,7 +3495,8 @@ class PubServer(BaseHTTPRequestHandler): reply_is_chat, bold_reading, self.server.dogwhistles, - self.server.min_images_for_accounts) + self.server.min_images_for_accounts, + None, None) if msg: msg = msg.encode('utf-8') msglen = len(msg) @@ -3649,7 +3650,8 @@ class PubServer(BaseHTTPRequestHandler): reply_is_chat, bold_reading, self.server.dogwhistles, - self.server.min_images_for_accounts) + self.server.min_images_for_accounts, + None, None) if msg: msg = msg.encode('utf-8') msglen = len(msg) @@ -15278,7 +15280,23 @@ class PubServer(BaseHTTPRequestHandler): """Shows the new post screen """ is_new_post_endpoint = False + new_post_month = None + new_post_year = None if '/users/' in path and '/new' in path: + if '?month=' in path: + month_str = path.split('?month=')[1] + if ';' in month_str: + month_str = month_str.split(';')[0] + if month_str.isdigit(): + new_post_month = int(month_str) + if new_post_month and ';year=' in path: + year_str = path.split(';year=')[1] + if ';' in year_str: + year_str = year_str.split(';')[0] + if year_str.isdigit(): + new_post_year = int(year_str) + if new_post_year: + path = path.split('?month=')[0] # Various types of new post in the web interface new_post_endpoints = get_new_post_endpoints() for curr_post_type in new_post_endpoints: @@ -15367,7 +15385,8 @@ class PubServer(BaseHTTPRequestHandler): reply_is_chat, bold_reading, self.server.dogwhistles, - self.server.min_images_for_accounts) + self.server.min_images_for_accounts, + new_post_month, new_post_year) if not msg: print('Error replying to ' + in_reply_to_url) self._404() diff --git a/webapp_calendar.py b/webapp_calendar.py index 9dfbda2be..cca3a6228 100644 --- a/webapp_calendar.py +++ b/webapp_calendar.py @@ -597,7 +597,8 @@ def html_calendar(person_cache: {}, translate: {}, new_event_str = \ '
\n

\n' + \ - '➕ ' + \ + '➕ ' + \ translate['Add to the calendar'] + '\n

\n
\n' calendar_icon_str = \ diff --git a/webapp_create_post.py b/webapp_create_post.py index 033067791..ba963f0d9 100644 --- a/webapp_create_post.py +++ b/webapp_create_post.py @@ -278,7 +278,8 @@ def html_new_post(edit_post_params: {}, box_name: str, reply_is_chat: bool, bold_reading: bool, dogwhistles: {}, - min_images_for_accounts: []) -> str: + min_images_for_accounts: [], + default_month: int, default_year) -> str: """New post screen """ # get the json if this is an edited post @@ -312,6 +313,12 @@ def html_new_post(edit_post_params: {}, default_location = '' default_start_time = '' default_end_time = '' + if default_month and default_year: + default_month_str = str(default_month) + if default_month < 10: + default_month_str = '0' + default_month_str + default_start_time = \ + str(default_year) + '-' + default_month_str + '-01T09:00:00' if edited_post_json: # if this is an edited post then get the subject line or # content warning