diff options
Diffstat (limited to 'lisp/service/resume-service.lisp')
| -rw-r--r-- | lisp/service/resume-service.lisp | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/lisp/service/resume-service.lisp b/lisp/service/resume-service.lisp index 46badc6..6a8e589 100644 --- a/lisp/service/resume-service.lisp +++ b/lisp/service/resume-service.lisp @@ -42,7 +42,7 @@ ;; macros -(defmacro define-resume-component ((component-s rest-args input-add-fields input-modify-fields order-by &optional view-p)) +(defmacro define-resume-component ((component-s rest-args input-add-fields input-modify-fields order-by &key view-p)) "`component-s' is a symbol that matches the component's record object name, i.e SKILL, JOB, EDUCATION, LANGUAGE, CONTACTINFO. This will be used all over the place. The record name equals the component name. @@ -57,7 +57,7 @@ fields that get inserted into the add and modify forms. needs to JOIN with other data." (let* ((component (symbol-name component-s)) (component-lcase (string-downcase component)) - (components-s (intern (format nil "~aS" component))) + (component-s (intern (format nil "~a" component))) (table (format nil "resume.~a~a" component-lcase (if view-p "_v" ""))) (arg-names (loop for arg in rest-args collect (car arg))) (func-root-s (intern (format nil "~a-JSON" component))) @@ -90,13 +90,11 @@ needs to JOIN with other data." (defun ,func-add-s () (with-auth (instance resume/resume-component/modify-service "resume-modify") - (with-resume-database - (let ((resume-pkg (make-instance 'resume-pkg))) - (setf (title instance) (format nil "~a - Add" ,component)) - (setf (form instance) (make-form ,form-add - nil - t - ,input-add-fields)))))) + (setf (title instance) (format nil "~a - Add" ,component)) + (setf (form instance) (make-form ,form-add + nil + t + ,input-add-fields)))) (defun ,func-add-submit-s (,@arg-names) (declare (special ,@arg-names)) @@ -149,11 +147,13 @@ needs to JOIN with other data." (loop for param in (sb-introspect:function-lambda-list #',func-modify-submit-s) do (setf (slot-value new-component param) (symbol-value param))) (setf (user_id new-component) (id user)) - (update-record resume-pkg new-component) - (setf (session-value :message) (format nil "~a modified successfully." ,component))) + (update-record-no-nulls resume-pkg new-component) + (setf (session-value :message) (format nil "~a modified successfully." ,component)) + (setf (message instance) (session-value :message))) (error (format nil "~a error" ,component)))) (error (e) - (setf (session-value :errormsg) (format nil "Error modifying ~a. ~a" ,component e))))))) + (setf (session-value :errormsg) (format nil "Error modifying ~a. ~a" ,component e)) + (setf (errormsg instance) (session-value :errormsg))))))) (defun ,func-delete-s (id) (with-auth (instance resume/resume-component/modify-service "resume-modify") @@ -167,8 +167,11 @@ needs to JOIN with other data." (if ,component-s (progn (delete-record resume-pkg (make-instance ',component-s :id id)) - (setf (session-value :message) (format nil "~a deleted successfully." ,component))) - (setf (session-value :errormsg) (format nil "Error: could not delete ~a: not found." ,component))))))) + (setf (session-value :message) (format nil "~a deleted successfully." ,component)) + (setf (message instance) (session-value :message))) + (progn + (setf (session-value :errormsg) (format nil "Error: could not delete ~a: not found." ,component)) + (setf (errormsg instance) (session-value :errormsg)))))))) (define-endpoint (,(format nil "/resume/~a" component-lcase) :method :get) () ,func-root-s) (define-endpoint (,(format nil "/resume/~a/view" component-lcase) :method :get) () ,func-view-s) @@ -207,7 +210,7 @@ needs to JOIN with other data." (:name "visastatus_id" :label "VISA Status" :field-type "select" :value (visastatus_id contactinfo) :options ,(visastatus-options (get-records resume-pkg (make-instance 'visastatus) "visastatus asc")) :required "required") (:label "Modify CONTACTINFO" :field-type "button" :onclick "on_contactinfo_modify_submit_clicked()")) "state_abbr asc, city asc, address asc" - t)) + :view-p t)) (define-resume-component (education ((school :parameter-type 'string) (major :parameter-type 'string) (minor :parameter-type 'string) (degree :parameter-type 'string) (progress :parameter-type 'string) (start_date :parameter-type 'string) (end_date :parameter-type 'string)) |
