From: Drew Crampsie Date: Sat, 3 Dec 2005 11:22:42 +0000 (-0800) Subject: added the beginning of a date component using selects, and also added the email valid... X-Git-Url: https://git.hcoop.net/clinton/lisp-on-lines.git/commitdiff_plain/db3b46cbba6ebce2f4dd3b4b7cbd841d575cf3b9?ds=sidebyside added the beginning of a date component using selects, and also added the email validation darcs-hash:20051203112242-5417e-fb035ecc1b42d76a6ffc80dc2651d1c750d5336d.gz --- diff --git a/src/slot-presentations/date.lisp b/src/slot-presentations/date.lisp new file mode 100644 index 0000000..04d93ff --- /dev/null +++ b/src/slot-presentations/date.lisp @@ -0,0 +1,75 @@ +(in-package :lol) + +;;;; Expiry date picker + +(defslot-presentation date-slot-presentation (clsql-wall-time-slot-presentation) + ((date-field :component (my-date-field :year-min 2005 :year-max 2015) + :accessor date-field)) + (:type-name date)) + +(defmethod update-value ((slot date-slot-presentation)) + (multiple-value-bind (year month day) + (time-ymd (presentation-slot-value slot (instance (ucw::parent slot)))) + (multiple-value-bind (new-year new-month new-day) + (time-ymd) + (if (remove nil (map 'list #'(lambda (old new) + (unless (equal (car old) (car new)) + t)) + (list year month day) + (list new-year new-month new-day))) + (setf (presentation-slot-value slot (instance (ucw::parent slot))) + (make-time t)))))) + +(defmethod present-slot ((slot date-slot-presentation) instance) + (let ((date (slot-value instance (slot-name slot)))) + ;; Default values + (when (and (not date) (default-to-now-p slot)) + (setf date (clsql:get-time) + (presentation-slot-value slot instance) date)) + ;;simple viewer + (if (and date (not (editablep slot))) + (<:as-html date)) + ;; editor + (when (editablep slot) + (with-slots ((m month) (y year)) + (date-field slot) + + (multiple-value-bind (year month) (time-ymd date) + (setf (lisp-value m) month + (lisp-value y) year) + (@,;:\\\\\".\\[\\] \\000-\\031]+(?:(?:(?:\\r\\n)?[ \\t])+|\\Z|(?=[\\[\"()<>@,;:\\\\\".\\[\\]]))|\"(?:[^\\\"\\r\\\\]|\\\\.|(?:(?:\\r\\n)?[ \\t]))*\"(?:(?:\\r\\n)?[ \\t])*)(?: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,;:\\\\\".\\[\\]]))|\\[([^\\[\\]\\r\\\\]|\\\\.)*\\](?:(?:\\r\\n)?[ \\t])*))*)*:(?:(?:\\r\\n)?[ \\t])*)?(?:[^()<>@,;:\\\\\".\\[\\] \\000-\\031]+(?:(?:(?:\\r\\n)?[ \\t])+|\\Z|(?=[\\[\"()<>@,;:\\\\\".\\[\\]]))|\"(?:[^\\\"\\r\\\\]|\\\\.|(?:(?:\\r\\n)?[ \\t]))*\"(?:(?:\\r\\n)?[ \\t])*)(?:\\.(?:(?:\\r\\n)?[ \\t])*(?:[^()<>@,;:\\\\\".\\[\\] \\000-\\031]+(?:(?:(?:\\r\\n)?[ \\t])+|\\Z|(?=[\\[\"()<>@,;:\\\\\".\\[\\]]))|\"(?:[^\\\"\\r\\\\]|\\\\.|(?:(?:\\r\\n)?[ \\t]))*\"(?:(?:\\r\\n)?[ \\t])*))*@(?:(?:\\r\\n)?[ \\t])*(?:[^()<>@,;:\\\\\".\\[\\] \\000-\\031]+(?:(?:(?:\\r\\n)?[ \\t])+|\\Z|(?=[\\[\"()<>@,;:\\\\\".\\[\\]]))|\\[([^\\[\\]\\r\\\\]|\\\\.)*\\](?:(?:\\r\\n)?[ \\t])*)(?:\\.(?:(?:\\r\\n)?[ \\t])*(?:[^()<>@,;:\\\\\".\\[\\] \\000-\\031]+(?:(?:(?:\\r\\n)?[ \\t])+|\\Z|(?=[\\[\"()<>@,;:\\\\\".\\[\\]]))|\\[([^\\[\\]\\r\\\\]|\\\\.)*\\](?:(?:\\r\\n)?[ \\t])*))*\\>(?:(?:\\r\\n)?[ \\t])*))*)?;\\s*)") + +(defvar scanner (cl-ppcre:create-scanner +email-regexp+)) + +(defun validate-email-address (instance attribute) + (let ((value (lol::attribute-value instance attribute))) + (multiple-value-bind (start end) + (cl-ppcre:scan scanner value) + (when (not (and (equal start 0) (equal end (length value)))) + (signal 'attribute-validation-condition + :message (format nil "~A must be a valid email address." + (getf (attribute.plist attribute) :label)) + :attribute attribute))))) \ No newline at end of file