Default month and year when adding a new reminder

merge-requests/30/head
Bob Mottram 2022-11-25 20:52:47 +00:00
parent 3ea0bad356
commit 8622d7c672
3 changed files with 32 additions and 5 deletions

View File

@ -3495,7 +3495,8 @@ class PubServer(BaseHTTPRequestHandler):
reply_is_chat, reply_is_chat,
bold_reading, bold_reading,
self.server.dogwhistles, self.server.dogwhistles,
self.server.min_images_for_accounts) self.server.min_images_for_accounts,
None, None)
if msg: if msg:
msg = msg.encode('utf-8') msg = msg.encode('utf-8')
msglen = len(msg) msglen = len(msg)
@ -3649,7 +3650,8 @@ class PubServer(BaseHTTPRequestHandler):
reply_is_chat, reply_is_chat,
bold_reading, bold_reading,
self.server.dogwhistles, self.server.dogwhistles,
self.server.min_images_for_accounts) self.server.min_images_for_accounts,
None, None)
if msg: if msg:
msg = msg.encode('utf-8') msg = msg.encode('utf-8')
msglen = len(msg) msglen = len(msg)
@ -15278,7 +15280,23 @@ class PubServer(BaseHTTPRequestHandler):
"""Shows the new post screen """Shows the new post screen
""" """
is_new_post_endpoint = False is_new_post_endpoint = False
new_post_month = None
new_post_year = None
if '/users/' in path and '/new' in path: 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 # Various types of new post in the web interface
new_post_endpoints = get_new_post_endpoints() new_post_endpoints = get_new_post_endpoints()
for curr_post_type in new_post_endpoints: for curr_post_type in new_post_endpoints:
@ -15367,7 +15385,8 @@ class PubServer(BaseHTTPRequestHandler):
reply_is_chat, reply_is_chat,
bold_reading, bold_reading,
self.server.dogwhistles, self.server.dogwhistles,
self.server.min_images_for_accounts) self.server.min_images_for_accounts,
new_post_month, new_post_year)
if not msg: if not msg:
print('Error replying to ' + in_reply_to_url) print('Error replying to ' + in_reply_to_url)
self._404() self._404()

View File

@ -597,7 +597,8 @@ def html_calendar(person_cache: {}, translate: {},
new_event_str = \ new_event_str = \
'<br><center>\n<p>\n' + \ '<br><center>\n<p>\n' + \
'<a href="' + cal_actor + '/newreminder" tabindex="2"> ' + \ '<a href="' + cal_actor + '/newreminder?month=' + \
str(month_number) + ';year=' + str(year) + '" tabindex="2"> ' + \
translate['Add to the calendar'] + '</a>\n</p>\n</center>\n' translate['Add to the calendar'] + '</a>\n</p>\n</center>\n'
calendar_icon_str = \ calendar_icon_str = \

View File

@ -278,7 +278,8 @@ def html_new_post(edit_post_params: {},
box_name: str, box_name: str,
reply_is_chat: bool, bold_reading: bool, reply_is_chat: bool, bold_reading: bool,
dogwhistles: {}, dogwhistles: {},
min_images_for_accounts: []) -> str: min_images_for_accounts: [],
default_month: int, default_year) -> str:
"""New post screen """New post screen
""" """
# get the json if this is an edited post # get the json if this is an edited post
@ -312,6 +313,12 @@ def html_new_post(edit_post_params: {},
default_location = '' default_location = ''
default_start_time = '' default_start_time = ''
default_end_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 edited_post_json:
# if this is an edited post then get the subject line or # if this is an edited post then get the subject line or
# content warning # content warning