@ -2,7 +2,8 @@
( defpackage #:utils
( defpackage #:utils
( :use #:cl
( :use #:cl
#:caveman2
#:caveman2
#:log4cl )
#:log4cl
#:app-constants )
( :export #:i18n-load
( :export #:i18n-load
#:_
#:_
#:parse-iso-date
#:parse-iso-date
@ -11,7 +12,9 @@
#:separate-files-in-web-request
#:separate-files-in-web-request
#:set-alert
#:set-alert
#:get-alert
#:get-alert
#:get-and-reset-alert )
#:get-and-reset-alert
#:bool-to-checkbox
#:checkbox-to-bool )
( :documentation "Utilities that do not depend on models." ) )
( :documentation "Utilities that do not depend on models." ) )
( in-package #:utils )
( in-package #:utils )
@ -62,3 +65,22 @@ POST request."
( let ( ( message ( get-alert ) ) )
( let ( ( message ( get-alert ) ) )
( set-alert nil )
( set-alert nil )
message ) )
message ) )
( defun bool-to-checkbox ( value )
" Converts ` VALUE ' so it can populate an HTML checkbox.
It is assumed you are converting a SQLite version of a Boolean so
either 1 ( true ) or 0 ( false ) . If you need a traditional Boolean value,
DO NOT USE THIS FUNCTION. "
( cond ( ( = value 0 ) "off" )
( ( null value ) "off" )
( t "on" ) ) )
( defun checkbox-to-bool ( value )
" Converts a HTML Checkbox ` VALUE ' to a Boolean.
The ` VALUE ' will either be 'on ' or 'off '. 'Boolean ' in this instance
is assuming you are using SQLite and need to convert ` VALUE ' to an
integer/number. If you are needing a traditional Boolean value, DO NOT USE
THIS FUNCTION. "
( cond ( ( string= "checked" value ) +true+ )
( ( string= "off" value ) +false+ )
( ( null value ) +false+ ) ) )