From: Paul Hänsch Date: Sun, 3 Jan 2021 19:33:45 +0000 (+0100) Subject: reintroduce attendence selection X-Git-Url: https://git.plutz.net/?a=commitdiff_plain;h=203fc5d63ba59a30688bac00c98d199cb08a8f30;p=lobster reintroduce attendence selection --- diff --git a/cards/l10n.sh b/cards/l10n.sh index 044a6a1..ec52766 100755 --- a/cards/l10n.sh +++ b/cards/l10n.sh @@ -17,7 +17,7 @@ l10n(){ local word - [ $# -eq 0 ] && read -r word || word="$1" + [ $# -eq 0 ] && read -r word || word="$*" case $word in PHOTO) printf %s "Foto";; LOGO) printf %s "Logo";; @@ -131,8 +131,7 @@ l10n(){ other) printf %s "⚥";; none) printf %s "⚪";; - - *) printf %s "$1";; + *) printf %s "$word";; esac } diff --git a/cards/list.sh b/cards/list.sh index 6321f0b..4e40072 100755 --- a/cards/list.sh +++ b/cards/list.sh @@ -40,8 +40,8 @@ edit_card(){ "${course##*/}" \ "$(grep -qF "${course##*/} ${cardfile##*/}" "$_DATA/mappings/attendance" \ && printf 'checked="checked"' - )" \ - "$(pdi_value "$(pdi_load "$course")" SUMMARY |unescape |HTML)" + )" \ + "$(pdi_value "$(pdi_load "$course")" SUMMARY || l10n "(unnamed course)" |unescape |HTML)" done) [h3 $(l10n CATEGORIES) ] $( grep -xE '[^ ]+' "$_DATA"/mappings/categories |while read -r cat; do @@ -85,11 +85,11 @@ print_card(){ [div .section .message . $(card_item "$card" EMAIL IMPP URL)] [div .section .address . $(card_item "$card" ADR)] [div .section .note . $(card_item "$card" NOTE)] - [div .section .attendance [h3 $(l10n course_attendance) ] [ul . + [div .section .attendance [h3 $(l10n course_attendance) ] [ul $(grep -F " ${cardfile##*/}" "$_DATA/mappings/attendance" |while read each discard; do printf '[li [a .item .attendance href="/courses#%s" . %s]]' \ "$each" \ - "$(pdi_value "$(pdi_load "$_DATA/ical/$each")" SUMMARY |unescape |HTML)" + "$(pdi_value "$(pdi_load "$_DATA/ical/$each")" SUMMARY || l10n "(unnamed course)" |unescape |HTML)" done)] $(card_item "$card" CATEGORIES) ] diff --git a/cards/update_card.sh b/cards/update_card.sh index 34db10c..7896beb 100755 --- a/cards/update_card.sh +++ b/cards/update_card.sh @@ -1,6 +1,6 @@ #!/bin/zsh -# Copyright 2014, 2016, 2019 Paul Hänsch +# Copyright 2014, 2016, 2019, 2020 Paul Hänsch # # This file is part of Confetti. # @@ -19,6 +19,7 @@ . "$_EXEC/pdiread.sh" . "$_EXEC/session_lock.sh" +. "$_EXEC/cgilite/storage.sh" unset filter order card action newfield unset cardfile attfile tempfile @@ -27,8 +28,8 @@ unset vcf field cnt delete_key filter="$(REF f)" order="$(REF o)" -card="$(POST card |PATH)" -cardfile="$_DATA/vcard/${card##*/}" +card="$(POST card |PATH)"; card="${card##*/}" +cardfile="$_DATA/vcard/${card}" attfile="$_DATA/mappings/attendance" action="$(POST action)" @@ -101,20 +102,21 @@ case "$action" in REDIRECT "/cards/?o=${order}&f=${filter}&e=${card}" ;; update) - # attendance=() - # for att in attendance attendance{0..100}; do - # [ -n "${_POST[$att]}" ] && attendance+=("${_POST[$att]}") - # done - # sed -rn 's:^(.+)'$card'$:\1:p' "$attfile" |while read course; do - # touch "$_DATA/ical/$course" - # done - # sed -i -r '/^(.+)\t'$card'$/d' "$attfile" - # for each in $attendance; do - # echo "$each\t$card" - # done >>"$attfile" - # sed -rn 's:^(.+)'$card'$:\1:p' "$attfile" |while read course; do - # touch "$_DATA/ical/$course" - # done + if LOCK "$attfile"; then + grep -F " ${card}" "$attfile" |while read course junk; do + touch "$_DATA/courses/${course}" + done + sed -i -r "/^.+ ${card}\$/d" "$attfile" + seq 1 $(POST_COUNT attendance) |while read n; do + printf '%s %s\n' "$(POST attendance $n)" "$card" + done >>"$attfile" + grep -F " ${card}" "$attfile" |while read course junk; do + touch "$_DATA/courses/${course}" + done + RELEASE "$attfile" + else + SET_COOKIE 0 message="COULD NOT UPDATE COURSE MAPPINGS" + fi cp "$tempfile" "$cardfile" RELEASE_SLOCK "$cardfile"