home
·
contact
·
privacy
projects
/
plomtask
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add date range input form to /calendar view.
[plomtask]
/
plomtask
/
http.py
diff --git
a/plomtask/http.py
b/plomtask/http.py
index 01a949e019eddbf9919f333d252a05aeb7dcd4e7..58b575f837774e5f6106b61b32ec452ff395c2b0 100644
(file)
--- a/
plomtask/http.py
+++ b/
plomtask/http.py
@@
-4,7
+4,7
@@
from http.server import HTTPServer
from urllib.parse import urlparse, parse_qs
from os.path import split as path_split
from jinja2 import Environment as JinjaEnv, FileSystemLoader as JinjaFSLoader
from urllib.parse import urlparse, parse_qs
from os.path import split as path_split
from jinja2 import Environment as JinjaEnv, FileSystemLoader as JinjaFSLoader
-from plomtask.days import Day
+from plomtask.days import Day
, todays_date
from plomtask.misc import HandledException
from plomtask.db import DatabaseConnection
from plomtask.misc import HandledException
from plomtask.db import DatabaseConnection
@@
-29,9
+29,11
@@
class TaskHandler(BaseHTTPRequestHandler):
try:
conn, site, params = self._init_handling()
if 'calendar' == site:
try:
conn, site, params = self._init_handling()
if 'calendar' == site:
- html = self.do_GET_calendar(conn)
+ start = params.get('start', [''])[0]
+ end = params.get('end', [''])[0]
+ html = self.do_GET_calendar(conn, start, end)
elif 'day' == site:
elif 'day' == site:
- date = params.get('date', [
'2024-01-01'
])[0]
+ date = params.get('date', [
todays_date()
])[0]
html = self.do_GET_day(conn, date)
else:
raise HandledException('Test!')
html = self.do_GET_day(conn, date)
else:
raise HandledException('Test!')
@@
-41,14
+43,15
@@
class TaskHandler(BaseHTTPRequestHandler):
except HandledException as error:
self._send_msg(error)
except HandledException as error:
self._send_msg(error)
- def do_GET_calendar(self, conn: DatabaseConnection):
+ def do_GET_calendar(self, conn: DatabaseConnection
, start: str, end: str
):
"""Show Days."""
return self.server.jinja.get_template('calendar.html').render(
"""Show Days."""
return self.server.jinja.get_template('calendar.html').render(
- days=Day.all(conn))
+ days=Day.all(conn, date_range=(start, end)),
+ start=start, end=end)
def do_GET_day(self, conn: DatabaseConnection, date: str):
"""Show single Day."""
def do_GET_day(self, conn: DatabaseConnection, date: str):
"""Show single Day."""
- day = Day.by_date(conn, date)
+ day = Day.by_date(conn, date
, create=True
)
return self.server.jinja.get_template('day.html').render(day=day)
def do_POST(self):
return self.server.jinja.get_template('day.html').render(day=day)
def do_POST(self):
@@
-59,7
+62,7
@@
class TaskHandler(BaseHTTPRequestHandler):
postvars = parse_qs(self.rfile.read(length).decode(),
keep_blank_values=1)
if 'day' == site:
postvars = parse_qs(self.rfile.read(length).decode(),
keep_blank_values=1)
if 'day' == site:
- date = params.get('date', [
'2024-01-01'
])[0]
+ date = params.get('date', [
None
])[0]
self.do_POST_day(conn, date, postvars)
conn.commit()
conn.close()
self.do_POST_day(conn, date, postvars)
conn.commit()
conn.close()