commit d20805b85cb58696ff83292c9798ba2c39ce193a
parent e77a48ed97daaed5b21490ed2de7d122e7fbbe76
Author: Jacob R. Edwards <jacob@jacobedwards.org>
Date: Tue, 19 Mar 2024 20:37:02 -0700
Disable writes when viewing past periods in main
The break and time headers are ignored when viewing previous periods.
Diffstat:
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/pages/main.c b/pages/main.c
@@ -358,12 +358,16 @@ pagemain(struct pagedata *pd)
if (!pd->user)
return errorpage(pd, KHTTP_401);
- if (pd->req.fieldmap[KeyBreak]) {
+ period = pd->req.fieldmap[KeyPeriod] ?
+ pd->req.fieldmap[KeyPeriod]->parsed.i : 0;
+ current = period == 0;
+
+ if (current && pd->req.fieldmap[KeyBreak]) {
if (breaktime(pd, pd->user->hash))
err(1, "Unable to break time");
}
- if (pd->req.fieldmap[KeyTime]) {
+ if (current && pd->req.fieldmap[KeyTime]) {
tf = gettf(pd->req.fieldmap[KeyTime]->parsed.s);
if (tf < 0)
err(1, "Invalid time field");
@@ -375,9 +379,6 @@ pagemain(struct pagedata *pd)
if (status != KCGI_OK)
return status;
- period = pd->req.fieldmap[KeyPeriod] ?
- pd->req.fieldmap[KeyPeriod]->parsed.i : 0;
- current = period == 0;
if (gettimes(pd, pd->user->hash, period, ×))
err(1, "gettimes");
if (current && !times && !(times = newtimesheet()))