]> git.plutz.net Git - lobster/commitdiff
enable set up of new course
authorPaul Hänsch <paul@plutz.net>
Mon, 18 Jan 2021 17:03:42 +0000 (18:03 +0100)
committerPaul Hänsch <paul@plutz.net>
Mon, 18 Jan 2021 17:03:42 +0000 (18:03 +0100)
courses/index.cgi
courses/new_course.sh

index 446cc9fdaf9c5de4493017e601573a05cc6c31de..56db2faa7ef9731f2c97d489484ef16849b8d976 100755 (executable)
@@ -22,7 +22,7 @@ edit="${edit##*/}"
 
 { w_sort_courses
   printf '
-  [form .newcourses action="/cards/new_course.sh" method="POST"
+  [form .newcourses action="/courses/new_course.sh" method="POST"
     [button type="submit" %s]
   ]' "$(l10n newcourse)"
 
index 4f97d4aadc94d3144135ad6854efeecd1871d1e0..c262b790bdbf279ea5ac44229e44e2189fedeb31 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/zsh
 
-# Copyright 2014 Paul Hänsch
+# Copyright 2014, 2021 Paul Hänsch
 #
 # This file is part of Confetti.
 # 
 # You should have received a copy of the GNU Affero General Public License
 # along with Confetti.  If not, see <http://www.gnu.org/licenses/>. 
 
-cgi_post
+locktimeout=900
+. "$_EXEC"/session_lock.sh
 
-uid=$(uuidgenerator)
+uid="$(timeid)$(randomid)"  # 32 Octets UID, starting with timestamp
 course="${uid}.ics"
 
-tzid=$(cat /etc/timezone)
-tstamp=$(TZ="$tzid" date +%Y%m%dT%H%M%S)
+tzid="$(cat /etc/timezone)"
+tstamp="$(TZ="$tzid" date +%Y%m%dT%H%M%S)"
 
-tempfile="$_DATA/temp/$course"
+coursefile="$_DATA/ical/$course"
 
-cat >"$tempfile" <<EOF
-BEGIN:VCALENDAR
-VERSION:2.0
-PRODID:Berlin RAW Confetti
-BEGIN:VEVENT
-UID:$uid
-DTSTAMP:TZID=${tzid}:${tstamp}
-DTSTART:
-DURATION:
-RRULE:
-SUMMARY:
-COMMENT:
-END:VEVENT
-END:VCARD
-EOF
-
-echo -n "Location: ?p=courses&edit=$course\n\n"
+if tempfile="$(SLOCK "$coursefile")"; then
+  cat >"$tempfile" <<-EOF
+       BEGIN:VCALENDAR
+       VERSION:2.0
+       PRODID:Berlin RAW Confetti
+       BEGIN:VEVENT
+       UID:$uid
+       DTSTAMP:TZID=${tzid}:${tstamp}
+       DTSTART:
+       DURATION:
+       RRULE:
+       SUMMARY:
+       COMMENT:
+       END:VEVENT
+       END:VCARD
+       EOF
+  REDIRECT "/courses/?e=${course}"
+else
+  SET_COOKIE session message="EDITLOCK"
+  REDIRECT "/courses/"
+fi