remove course mapping when deleting card file
authorPaul Hänsch <paul@plutz.net>
Mon, 18 Jan 2021 17:02:35 +0000 (18:02 +0100)
committerPaul Hänsch <paul@plutz.net>
Mon, 18 Jan 2021 17:02:35 +0000 (18:02 +0100)
cards/update_card.sh

index 97dedf3..bf8bce1 100755 (executable)
@@ -131,6 +131,15 @@ case "$action" in
   delete)
     rm "$cardfile"
     RELEASE_SLOCK "$cardfile"
+    if LOCK "$attfile"; then
+      grep -F "        ${card}" "$attfile" |while read course junk; do
+        touch "$_DATA/ical/${course}"
+      done
+      sed -i -E "/^.+  ${card}\$/d" "$attfile"
+      RELEASE "$attfile"
+    else
+      SET_COOKIE 0 message="COULD NOT UPDATE COURSE MAPPINGS"
+    fi
     REDIRECT "/cards/?o=${order}&f=${filter}"
     ;;
 esac