- # db = TodoDB(prefix=prefix, selected_date=postvars['original_selected_date'][0])
- # # import pprint
- # # pp = pprint.PrettyPrinter(indent=4)
- # # pp.pprint(postvars)
- # db.t_filter_and = set()
- # db.t_filter_not = set()
- # if 't_filter_and' in postvars.keys():
- # for target in postvars['t_filter_and']:
- # db.t_filter_and.add(target)
- # if 't_filter_not' in postvars.keys():
- # for target in postvars['t_filter_not']:
- # db.t_filter_not.add(target)
- # if 'hide_unchosen' in postvars.keys():
- # db.hide_unchosen = True
- # if 't_uuid' in postvars.keys():
- # new_postvars_t_uuid = postvars['t_uuid'].copy()
- # for i, uuid in enumerate(postvars['t_uuid']):
- # if len(uuid) < 36 and len(postvars['t_title'][i]) > 0:
- # new_uuid, t = db.add_task(return_id=True)
- # new_postvars_t_uuid[i] = new_uuid
- # for key in [k for k in postvars.keys() if not k == 't_uuid']:
- # if uuid in postvars[key]:
- # uuid_index = postvars[key].index(uuid)
- # postvars[key][uuid_index] = new_uuid
- # postvars['t_uuid'] = new_postvars_t_uuid
- # for i, uuid in enumerate(postvars['t_uuid']):
- # if len(uuid) < 36:
- # continue
- # t = db.tasks[uuid]
- # t.set_title(postvars['t_title'][i])
- # t.tags_from_joined_string(postvars['t_tags'][i])
- # t.set_default_weight(float(postvars['t_default_weight'][i]))
- # if uuid in db.selected_day.todos.keys() and ((not 'choose' in postvars) or uuid not in postvars['choose']):
- # del db.selected_day.todos[uuid]
- # if 'choose' in postvars.keys():
- # for i, uuid in enumerate(postvars['t_uuid']):
- # if uuid in postvars['choose']:
- # done = 'done' in postvars and uuid in postvars['done']
- # day_weight = float(postvars['day_weight'][i]) if postvars['day_weight'][i] else None
- # db.selected_day.add_todo(uuid, {'done': done, 'day_weight': day_weight})
-
- # if 'comment' in postvars.keys():
- # db.selected_day.comment = postvars['comment'][0]
- # if 'new_selected_date' in postvars.keys():
- # new_selected_date = postvars['new_selected_date'][0]
- # try:
- # datetime.strptime(new_selected_date, '%Y-%m-%d')
- # except ValueError:
- # raise PlomException(f"{prefix} bad date string: {new_selected_date}")
- # if new_selected_date != db.selected_date:
- # if new_selected_date in db.days.keys():
- # raise PlomException('cannot use same date twice')
- # else:
- # db.days[new_selected_date] = db.selected_day
- # del db.days[db.selected_date]
- # db.selected_date = new_selected_date
-
- # switch_edited_day = None
- # day_edit_prefix = 'edit_'
- # for k in postvars.keys():
- # if k.startswith(day_edit_prefix):
- # switch_edited_day = k[len(day_edit_prefix):]
- # db.switch_to_day(switch_edited_day)
- # break
- # db.write()
- # data = [('t_and', f) for f in db.t_filter_and] + [('t_not', f) for f in db.t_filter_not] + [('hide_unchosen', int(db.hide_unchosen))] + [('date', db.selected_date)]
- # encoded_params = urlencode(data)
- # if prefix + '/day' == parsed_url.path:
- # homepage = f'{prefix}/day?{encoded_params}'
- # else:
- # homepage = f'{prefix}/all?{encoded_params}'
- # self.redirect(homepage)