diff options
| -rw-r--r-- | lisp/service/menu-service.lisp | 1 | ||||
| -rw-r--r-- | lisp/service/resume-service.lisp | 152 | ||||
| -rw-r--r-- | lisp/sql/contactinfo.lisp | 17 | ||||
| -rw-r--r-- | lisp/sql/resume-pkg.lisp | 43 | ||||
| -rw-r--r-- | lisp/sql/visastatus.lisp | 6 | ||||
| -rw-r--r-- | lisp/webapps/resume/clojurescript/resume/src/core.cljs | 209 | ||||
| -rw-r--r-- | lisp/webapps/resume/site.lisp | 29 | ||||
| -rw-r--r-- | sql/functions/contact.insert_contact_us_post.sql | 10 | ||||
| -rw-r--r-- | sql/functions/resume.insert_contactinfo.sql | 45 | ||||
| -rw-r--r-- | sql/functions/resume.insert_resume.sql | 7 | ||||
| -rw-r--r-- | sql/tables/resume.contactinfo.sql | 1 | ||||
| -rw-r--r-- | sql/views/resume.contactinfo_v.sql | 17 |
12 files changed, 514 insertions, 23 deletions
diff --git a/lisp/service/menu-service.lisp b/lisp/service/menu-service.lisp index 6e97992..a01c5f8 100644 --- a/lisp/service/menu-service.lisp +++ b/lisp/service/menu-service.lisp @@ -5,6 +5,7 @@ (defparameter *menu-config* '((:id "a_menu_home" :label "Home" :handler "/home" :permissions "_Public") (:id "a_menu_resumes" :label "Resumes" :handler "/resumes" :permissions "resume-view") + (:id "a_menu_resumes_contactinfo" :label "Contact Info" :handler "/resumes/contactinfo" :permissions "resume-view") (:id "a_menu_contact_us" :label "Contact Me" :handler "/contact-us" :permissions "_Public") (:id "a_menu_messages" :label "Messages" :handler "/messages" :permissions "messages-view") (:id "a_menu_users" :label "Users" :handler "/users" :permissions "users-view"))) diff --git a/lisp/service/resume-service.lisp b/lisp/service/resume-service.lisp index d31ae30..3536a87 100644 --- a/lisp/service/resume-service.lisp +++ b/lisp/service/resume-service.lisp @@ -3,12 +3,16 @@ (in-package :resume) +;; shared + (defclass resumes-service (auth-service) ((title :initarg :title :initform nil :accessor title)) (:documentation "")) +;; resume + (defun resumes-json () (with-auth (instance resumes-service "resume-view") (setf (title instance) "Resumes"))) @@ -25,7 +29,7 @@ (with-resume-database (let ((resume-pkg (make-instance 'resume-pkg)) (user (get-user))) - (setf (resumes instance) (get-all-resumes-for-user resume-pkg user)))) + (setf (resumes instance) (get-all-resumes resume-pkg user)))) (sanitize-rest-json instance) (loop for resume in (resumes instance) do (sanitize-json resume)))) @@ -52,7 +56,11 @@ (handler-case (let* ((resume-pkg (make-instance 'resume-pkg)) (user (get-user)) - (resume (make-instance 'resume :user_id (id user) :name name))) + (resume (make-instance 'resume :user_id (id user)))) + (loop for param in (remove-if (lambda (x) + (intersection `(,x) '(id))) + (sb-introspect:function-lambda-list #'resumes-add-submit-json)) + do (setf (slot-value resume param) (symbol-value param))) (insert-resume resume-pkg resume) (setf (session-value :message) (format nil "Resume \"~a\" created successfully." (name resume)))) (error (e) @@ -86,6 +94,10 @@ (let* ((resume-pkg (make-instance 'resume-pkg)) (user (get-user)) (resume (get-resume resume-pkg (make-instance 'resume :id id :user_id (id user))))) + (loop for param in (remove-if (lambda (x) + (intersection `(,x) '(id))) + (sb-introspect:function-lambda-list #'resumes-modify-submit-json)) + do (setf (slot-value resume param) (symbol-value param))) (setf (name resume) name) (update-resume resume-pkg resume) (setf (session-value :message) (format nil "Resume \"~a\" modified successfully." (name resume)))) @@ -107,3 +119,139 @@ (delete-resume resume-pkg resume) (setf (session-value :message) (format nil "Resume \"~a\" deleted successfully." (name resume)))) (setf (session-value :errormsg) "Error: could not delete resume: not found.")))))) + +;; contactinfo + +(defun contactinfo-json () + (with-auth (instance resumes-service "resume-view") + (setf (title instance) "Contact Information"))) + +(defclass contactinfo/view-service (resumes-service contactinfo) + ((contactinfos :initarg :contactinfos + :initform nil + :accessor contactinfos) + (location-p :initform nil)) + (:documentation "")) + +(defun contactinfo-view-json () + (with-auth (instance contactinfo/view-service "resume-view") + (with-resume-database + (let ((resume-pkg (make-instance 'resume-pkg)) + (user (get-user))) + (setf (contactinfos instance) (get-all-contactinfo resume-pkg user)))) + (sanitize-rest-json instance) + (loop for contactinfo-v in (contactinfos instance) + do (sanitize-json contactinfo-v)))) + +(defclass contactinfo/add-service (contactinfo/view-service) + ((form :initarg :form + :initform nil + :accessor form)) + (:documentation "")) + +(defun state-options (states) + (mapcar (lambda (state) + `(:label ,(format nil "~a ~a" (abbr state) (state state)) :value ,(id state))) + states)) + +(defun visastatus-options (visastatuses) + (mapcar (lambda (visastatus) + `(:label ,(status visastatus) :value ,(id visastatus))) + visastatuses)) + +(defun contactinfo-add-json () + (with-auth (instance contactinfo/add-service "resume-modify") + (with-resume-database + (let* ((resume-pkg (make-instance 'resume-pkg)) + (user (get-user)) + (states (get-records resume-pkg (make-instance 'states) "abbr asc")) + (visastatuses (get-records resume-pkg (make-instance 'visastatus) "visastatus asc"))) + (setf (title instance) "Contact Info - Add") + (setf (form instance) (make-form "contactinfo-add-form" + nil + t + `((:name "address" :label "Address" :field-type "text" :required "required") + (:name "city" :label "City" :field-type "text" :required "required") + (:name "state_id" :label "State" :field-type "select" :options ,(state-options states) :required "required") + (:name "phone" :label "Phone" :field-type "text" :required "required") + (:name "email" :label "Email" :field-type "text" :required "required") + (:name "visastatus_id" :label "VISA Status" :field-type "select" :options ,(visastatus-options visastatuses) :required "required") + (:label "Add Contact Info" :field-type "button" :onclick "on_contactinfo_add_submit_clicked()")))))))) + +(defun contactinfo-add-submit-json (address city state_id phone email visastatus_id) + (declare (special address city state_id phone email visastatus_id)) + (with-auth (instance contactinfo/add-service "resume-modify") + (with-resume-database + (handler-case + (let* ((resume-pkg (make-instance 'resume-pkg)) + (user (get-user)) + (contactinfo (make-instance 'contactinfo :user_id (id user)))) + (loop for param in (remove-if (lambda (x) + (intersection `(,x) '(id))) + (sb-introspect:function-lambda-list #'contactinfo-add-submit-json)) + do (setf (slot-value contactinfo param) (symbol-value param))) + (insert-contactinfo resume-pkg contactinfo) + (setf (session-value :message) (format nil "Contact Info \"~a, ~a\" created successfully." address city))) + (error (e) + (setf (session-value :errormsg) (format nil "Error creating Contact Info \"~a, ~a\". ~a" address city e))))))) + +(defclass contactinfo/modify-service (contactinfo/add-service) + () + (:documentation "")) + +(defun contactinfo-modify-json (id) + (with-auth (instance contactinfo/modify-service "resume-modify") + (setf (title instance) "Contact Info - Modify") + (with-resume-database + (let* ((resume-pkg (make-instance 'resume-pkg)) + (user (get-user)) + (states (get-records resume-pkg (make-instance 'states) "abbr asc")) + (visastatuses (get-records resume-pkg (make-instance 'visastatus) "status asc")) + (contactinfo-v (get-contactinfo resume-pkg (make-instance 'contactinfo-v :id id :user_id (id user))))) + (if contactinfo-v + (setf (form instance) (make-form "contactinfo-modify-form" + nil + t + `((:name "id" :field-type "hidden" :value ,(id contactinfo-v) :required "required") + (:name "address" :label "Address" :field-type "text" :value ,(address contactinfo-v) :required "required") + (:name "city" :label "City" :field-type "text" :value ,(city contactinfo-v) :required "required") + (:name "state_id" :label "State" :field-type "select" :value ,(state_id contactinfo-v) :options ,(state-options states) :required "required") + (:name "phone" :label "Phone" :field-type "text" :value ,(phone contactinfo-v) :required "required") + (:name "email" :label "Email" :field-type "text" :value ,(email contactinfo-v) :required "required") + (:name "visastatus_id" :label "VISA Status" :field-type "select" :value ,(visastatus_id contactinfo-v) :options ,(visastatus-options visastatuses) :required "required") + (:label "Modify Contact Info" :field-type "button" :onclick "on_contactinfo_modify_submit_clicked()")))) + (setf (session-value :errormsg) "Error: could not modify Contact Info. Not found.")))))) + +(defun contactinfo-modify-submit-json (id address city state_id phone email visastatus_id) + (declare (special id address city state_id phone email visastatus_id)) + (with-auth (instance contactinfo/modify-service "resume-modify") + (setf (title instance) "Contact Info - Modify") + (with-resume-database + (handler-case + (let* ((resume-pkg (make-instance 'resume-pkg)) + (user (get-user)) + (contactinfo (get-record resume-pkg (make-instance 'contactinfo :id id :user_id (id user))))) + (loop for param in (remove-if (lambda (x) + (intersection `(,x) '(id))) + (sb-introspect:function-lambda-list #'contactinfo-modify-submit-json)) + do (setf (slot-value contactinfo param) (symbol-value param))) + (update-contactinfo resume-pkg contactinfo) + (setf (session-value :message) (format nil "Contact Info \"~a, ~a\" modified successfully." address city))) + (error (e) + (setf (session-value :errormsg) (format nil "Error modifying Contact Info \"~a, ~a\". ~a" address city e))))))) + +(defclass contactinfo/delete-service (contactinfo/add-service) + () + (:documentation "")) + +(defun contactinfo-delete-json (id) + (with-auth (instance contactinfo/delete-service "resume-modify") + (with-resume-database + (let* ((resume-pkg (make-instance 'resume-pkg)) + (user (get-user)) + (contactinfo (get-record resume-pkg (make-instance 'contactinfo :id id :user_id (id user))))) + (if contactinfo + (progn + (delete-contactinfo resume-pkg contactinfo) + (setf (session-value :message) (format nil "Contact Info \"~a, ~a\" deleted successfully." (address contactinfo) (city contactinfo)))) + (setf (session-value :errormsg) "Error: could not delete Contact Info: not found.")))))) diff --git a/lisp/sql/contactinfo.lisp b/lisp/sql/contactinfo.lisp index 83c271d..efaed37 100644 --- a/lisp/sql/contactinfo.lisp +++ b/lisp/sql/contactinfo.lisp @@ -7,6 +7,9 @@ ((id :initarg :id :initform nil :accessor id) + (user_id :initarg :user_id + :initform nil + :accessor user_id) (address :initarg :address :initform nil :accessor address) @@ -28,3 +31,17 @@ (*table :initform "resume.contactinfo") (*where-expression :initform "id = ~a")) (:documentation "Holds the data for a resume.contactinfo record.")) + +(defclass contactinfo-v (contactinfo) + ((state_name :initarg :state_name + :initform nil + :accessor state_name) + (state_abbr :initarg :state_abbr + :initform nil + :accessor state_abbr) + (visastatus :initarg :visastatus + :initform nil + :accessor visastatus) + (*table :initform "resume.contactinfo_v") + (*where-expression :initform "id = ~a")) + (:documentation "Holds the data for a resume.contactinfo_v record.")) diff --git a/lisp/sql/resume-pkg.lisp b/lisp/sql/resume-pkg.lisp index 8a7b0fa..a0fc3d2 100644 --- a/lisp/sql/resume-pkg.lisp +++ b/lisp/sql/resume-pkg.lisp @@ -7,7 +7,9 @@ () (:documentation "")) -(defmethod get-all-resumes-for-user ((resume-pkg resume-pkg) (user user)) +;; resumes + +(defmethod get-all-resumes ((resume-pkg resume-pkg) (user user)) (let ((resume (make-instance 'resume :user_id (id user)))) (get-records resume-pkg resume "name asc"))) @@ -29,3 +31,42 @@ "resume.delete_resume(~a)" (id resume))) (caar (call-pg-function resume-pkg resume))) + +;; contactinfo + +(defmethod get-all-contactinfo ((resume-pkg resume-pkg) (user user)) + (let ((contactinfo-v (make-instance 'contactinfo-v :user_id (id user)))) + (get-records resume-pkg contactinfo-v "state_name asc, city asc, address asc, email asc, phone asc, visastatus asc"))) + +(defmethod get-contactinfo ((resume-pkg resume-pkg) (contactinfo-v contactinfo-v)) + (get-record resume-pkg contactinfo-v)) + +(defmethod insert-contactinfo ((resume-pkg resume-pkg) (contactinfo contactinfo)) + (setf (*table contactinfo) (format nil + "resume.insert_contactinfo(~a, ~a, ~a, '~a', '~a', '~a', '~a')" + (user_id contactinfo) + (state_id contactinfo) + (visastatus_id contactinfo) + (address contactinfo) + (city contactinfo) + (phone contactinfo) + (email contactinfo))) + (caar (call-pg-function resume-pkg contactinfo))) + +(defmethod update-contactinfo ((resume-pkg resume-pkg) (contactinfo contactinfo)) + (update-record resume-pkg contactinfo)) + +(defmethod delete-contactinfo ((resume-pkg resume-pkg) (contactinfo contactinfo)) + (delete-record resume-pkg contactinfo)) + +;; education + + + +;; language + + + +;; job + + diff --git a/lisp/sql/visastatus.lisp b/lisp/sql/visastatus.lisp index 3f6293c..a4c6744 100644 --- a/lisp/sql/visastatus.lisp +++ b/lisp/sql/visastatus.lisp @@ -7,9 +7,9 @@ ((id :initarg :id :initform nil :accessor id) - (visastatus :initarg :visastatus - :initform nil - :accessor visastatus) + (status :initarg :status + :initform nil + :accessor status) (*table :initform "resume.visastatus") (*where-expression :initform "id = ~a")) (:documentation "Holds the data for a resume.visastatus record.")) diff --git a/lisp/webapps/resume/clojurescript/resume/src/core.cljs b/lisp/webapps/resume/clojurescript/resume/src/core.cljs index 34108b7..cde1a89 100644 --- a/lisp/webapps/resume/clojurescript/resume/src/core.cljs +++ b/lisp/webapps/resume/clojurescript/resume/src/core.cljs @@ -149,6 +149,29 @@ (declare on-resumes-delete-clicked) (declare handler-resumes-delete) (declare render-resumes-delete) +(declare template-contactinfo) +(declare handler-contactinfo) +(declare render-contactinfo) +(declare template-contactinfo-view) +(declare handler-contactinfo-view) +(declare render-contactinfo-view) +(declare on-contactinfo-add-clicked) +(declare template-contactinfo-add) +(declare handler-contactinfo-add) +(declare render-contactinfo-add) +(declare on-contactinfo-add-submit-clicked) +(declare handler-contactinfo-add-submit) +(declare render-contactinfo-add-submit) +(declare on-contactinfo-modify-clicked) +(declare template-contactinfo-modify) +(declare handler-contactinfo-modify) +(declare render-contactinfo-modify) +(declare on-contactinfo-modify-submit-clicked) +(declare handler-contactinfo-modify-submit) +(declare render-contactinfo-modify-submit) +(declare on-contactinfo-delete-clicked) +(declare handler-contactinfo-delete) +(declare render-contactinfo-delete) (declare on-menu-clicked) (declare handler-location) (declare goto-location) @@ -1190,6 +1213,189 @@ {:format :raw :handler handler-resumes-delete})) +;; contactinfo + +(hiccups/defhtml template-contactinfo [jsonobj] + [:h3 {:style "text-align: center"} (get jsonobj "title")] + [:div {:id "content"}] + [:div {:id "modify" + :class "modal fade" + :role "dialog" + :tabindex "-1"} + [:div {:class "modal-dialog modal-lg"} + [:div {:class "modal-content"} + [:div {:class "modal-header"} + [:h5 [:span {:id "modify-title"}]] + [:button {:type "button" + :class "close" + :data-dismiss "modal"} + "×"]] + [:div {:id "modify-body" + :class "modal-body" + :style "height: 450px;"}] + [:div {:class "modal-footer"} + [:button {:type "submit" + :class "btn btn-danger btn-default" + :data-dismiss "modal"} + [:span {:class "glyphicon glyphicon-remove"}] + "Cancel"]]]]]) + +(defn handler-contactinfo [response] + (let [jsonobj (js->clj (js/JSON.parse response))] + (notifications jsonobj) + (dommy/set-html! (dommy/sel1 :#body) (template-contactinfo jsonobj)) + (render-contactinfo-view))) + +(defn render-contactinfo [] + (GET "/resumes/contactinfo" {:handler handler-contactinfo})) + +;; contactinfo-view + +(hiccups/defhtml template-contactinfo-view [jsonobj] + [:div {:style "text-align: right"} + [:img {:src "/static/images/add.png" + :style "cursor:pointer; cursor:hand" + :onclick (str (namespace ::x) ".on_contactinfo_add_clicked()")}]] + [:table {:class "table table-striped table-hover table-sm"} + [:thead + [:tr + [:th {:scope "col"} "Address"] + [:th {:scope "col"} "City"] + [:th {:scope "col"} "State"] + [:th {:scope "col"} "Phone"] + [:th {:scope "col"} "Email"] + [:th {:scope "col"} "VISA Status"] + [:th {:scope "col"} "Mod"] + [:th {:scope "col"} "Del"]]] + [:tbody + (for [contactinfo (get jsonobj "contactinfos")] + [:tr + [:td (get contactinfo "address")] + [:td (get contactinfo "city")] + [:td (get contactinfo "state_abbr")] + [:td (get contactinfo "phone")] + [:td (get contactinfo "email")] + [:td (get contactinfo "visastatus")] + [:td {:width "30"} + [:img {:src "/static/images/modify.png" + :onclick (str (namespace ::x) ".on_contactinfo_modify_clicked(" (get contactinfo "id") ")")}]] + [:td {:width "30"} + [:img {:src "/static/images/delete.png" + :onclick (str (namespace ::x) ".on_contactinfo_delete_clicked(" (get contactinfo "id") ", '" (str (get contactinfo "address") ", " (get contactinfo "city") " " (get contactinfo "state_abbr")) "')")}]]])]]) + +(defn handler-contactinfo-view [response] + (let [jsonobj (js->clj (js/JSON.parse response))] + (dommy/set-html! (dommy/sel1 :#content) (template-contactinfo-view jsonobj)))) + +(defn render-contactinfo-view [] + (GET "/resumes/contactinfo/view" {:handler handler-contactinfo-view})) + +;; contactinfo-add + +(defn on-contactinfo-add-clicked [] + (render-contactinfo-add)) + +(hiccups/defhtml template-contactinfo-add [jsonobj] + (ck-form/template-generic-form (get jsonobj "form") (namespace ::x))) + +(defn handler-contactinfo-add [response] + (let [jsonobj (js->clj (js/JSON.parse response))] + (auth-notifications jsonobj) + (dommy/set-html! (dommy/sel1 :#modify-title) (get jsonobj "title")) + (dommy/set-html! (dommy/sel1 :#modify-body) (template-contactinfo-add jsonobj)) + (.modal (jquery "#modify")))) + +(defn render-contactinfo-add [] + (POST "/resumes/contactinfo/add" {:handler handler-contactinfo-add})) + +;; contactinfo-add-submit + +(defn on-contactinfo-add-submit-clicked [] + (when (-> (jquery "#contactinfo-add-form") + (.get "0") + (.checkValidity)) + (.modal (jquery "#modify") "hide") + (render-contactinfo-add-submit))) + +(defn handler-contactinfo-add-submit [response] + (let [jsonobj (js->clj (js/JSON.parse response))] + (auth-notifications jsonobj) + (on-menu-clicked "/resumes/contactinfo"))) + +(defn render-contactinfo-add-submit [] + (POST "/resumes/contactinfo/add/submit" + {:format :raw + :params {:address (dommy/value (dommy/sel1 :#address)) + :city (dommy/value (dommy/sel1 :#city)) + :state_id (dommy/value (dommy/sel1 :#state_id)) + :phone (dommy/value (dommy/sel1 :#phone)) + :email (dommy/value (dommy/sel1 :#email)) + :visastatus_id (dommy/value (dommy/sel1 :#visastatus_id))} + :handler handler-contactinfo-add-submit})) + +;; contactinfo-modify + +(defn on-contactinfo-modify-clicked [id] + (render-contactinfo-modify id)) + +(hiccups/defhtml template-contactinfo-modify [jsonobj] + (ck-form/template-generic-form (get jsonobj "form") (namespace ::x))) + +(defn handler-contactinfo-modify [response] + (let [jsonobj (js->clj (js/JSON.parse response))] + (auth-notifications jsonobj) + (dommy/set-html! (dommy/sel1 :#modify-title) (get jsonobj "title")) + (dommy/set-html! (dommy/sel1 :#modify-body) (template-contactinfo-modify jsonobj)) + (.modal (jquery "#modify")))) + +(defn render-contactinfo-modify [id] + (POST "/resumes/contactinfo/modify" + {:format :raw + :params {:id id} + :handler handler-contactinfo-modify})) + +;; contactinfo-modify-submit + +(defn on-contactinfo-modify-submit-clicked [] + (when (-> (jquery "#contactinfo-modify-form") + (.get "0") + (.checkValidity)) + (.modal (jquery "#modify") "hide") + (render-contactinfo-modify-submit))) + +(defn handler-contactinfo-modify-submit [response] + (let [jsonobj (js->clj (js/JSON.parse response))] + (auth-notifications jsonobj) + (on-menu-clicked "/resumes/contactinfo"))) + +(defn render-contactinfo-modify-submit [] + (POST "/resumes/contactinfo/modify/submit" + {:format :raw + :params {:id (dommy/value (dommy/sel1 :#id)) + :address (dommy/value (dommy/sel1 :#address)) + :city (dommy/value (dommy/sel1 :#city)) + :state_id (dommy/value (dommy/sel1 :#state_id)) + :phone (dommy/value (dommy/sel1 :#phone)) + :email (dommy/value (dommy/sel1 :#email)) + :visastatus_id (dommy/value (dommy/sel1 :#visastatus_id))} + :handler handler-contactinfo-modify-submit})) + +;; contactinfo-delete + +(defn on-contactinfo-delete-clicked [id name] + (when (js/confirm (str "Are you sure you want to delete " name "? This action cannot be undone.")) + (render-contactinfo-delete id))) + +(defn handler-contactinfo-delete [response] + (let [jsonobj (js->clj (js/JSON.parse response))] + (auth-notifications jsonobj) + (on-menu-clicked "/resumes/contactinfo"))) + +(defn render-contactinfo-delete [id] + (DELETE (str "/resumes/contactinfo/delete/" id) + {:format :raw + :handler handler-contactinfo-delete})) + ;; location (defn on-menu-clicked [handler] @@ -1203,7 +1409,8 @@ (= handler "/contact-us") (render-contact-us) (= handler "/messages") (render-messages) (= handler "/users") (render-users) - (= handler "/resumes") (render-resumes))) + (= handler "/resumes") (render-resumes) + (= handler "/resumes/contactinfo") (render-contactinfo))) (defn handler-location [response] (let [jsonobj (js->clj (js/JSON.parse response))] diff --git a/lisp/webapps/resume/site.lisp b/lisp/webapps/resume/site.lisp index 80bdbe1..2142c9c 100644 --- a/lisp/webapps/resume/site.lisp +++ b/lisp/webapps/resume/site.lisp @@ -152,6 +152,27 @@ (defmacro .resumes-delete () `(resumes-delete-json id)) +(defmacro .contactinfo () + `(contactinfo-json)) + +(defmacro .contactinfo-view () + `(contactinfo-view-json)) + +(defmacro .contactinfo-add () + `(contactinfo-add-json)) + +(defmacro .contactinfo-add-submit () + `(contactinfo-add-submit-json address city state_id phone email visastatus_id)) + +(defmacro .contactinfo-modify () + `(contactinfo-modify-json id)) + +(defmacro .contactinfo-modify-submit () + `(contactinfo-modify-submit-json id address city state_id phone email visastatus_id)) + +(defmacro .contactinfo-delete () + `(contactinfo-delete-json id)) + (define-endpoint ("/" :method :get) () .base) (define-endpoint ("/location" :method :post) (&post (location :parameter-type 'string)) .location) (define-endpoint ("/home" :method :get) () .home-get) @@ -189,7 +210,6 @@ (define-endpoint ("/users/modify/submit" :method :post) (&post (id :parameter-type 'integer) (role_groups :parameter-type 'string) (username :parameter-type 'string) (first_name :parameter-type 'string) (last_name :parameter-type 'string) (email :parameter-type 'string) (phone :parameter-type 'string)) .users-modify-submit) (define-endpoint ("/users/toggle-active" :method :post) (&post (id :parameter-type 'integer)) .users-toggle-active) (define-endpoint ("/users/delete/:id" :method :delete) (&path (id 'integer)) .users-delete) - (define-endpoint ("/resumes" :method :get) () .resumes) (define-endpoint ("/resumes/view" :method :get) () .resumes-view) (define-endpoint ("/resumes/add" :method :post) () .resumes-add) @@ -197,3 +217,10 @@ (define-endpoint ("/resumes/modify" :method :post) (&post (id :parameter-type 'integer)) .resumes-modify) (define-endpoint ("/resumes/modify/submit" :method :post) (&post (id :parameter-type 'integer) (name :parameter-type 'string)) .resumes-modify-submit) (define-endpoint ("/resumes/delete/:id" :method :delete) (&path (id 'integer)) .resumes-delete) +(define-endpoint ("/resumes/contactinfo" :method :get) () .contactinfo) +(define-endpoint ("/resumes/contactinfo/view" :method :get) () .contactinfo-view) +(define-endpoint ("/resumes/contactinfo/add" :method :post) () .contactinfo-add) +(define-endpoint ("/resumes/contactinfo/add/submit" :method :post) (&post (address :parameter-type 'string) (city :parameter-type 'string) (state_id :parameter-type 'integer) (phone :parameter-type 'string) (email :parameter-type 'string) (visastatus_id :parameter-type 'integer)) .contactinfo-add-submit) +(define-endpoint ("/resumes/contactinfo/modify" :method :post) (&post (id :parameter-type 'integer)) .contactinfo-modify) +(define-endpoint ("/resumes/contactinfo/modify/submit" :method :post) (&post (id :parameter-type 'integer) (address :parameter-type 'string) (city :parameter-type 'string) (state_id :parameter-type 'integer) (phone :parameter-type 'string) (email :parameter-type 'string) (visastatus_id :parameter-type 'integer)) .contactinfo-modify-submit) +(define-endpoint ("/resumes/contactinfo/delete/:id" :method :delete) (&path (id 'integer)) .contactinfo-delete) diff --git a/sql/functions/contact.insert_contact_us_post.sql b/sql/functions/contact.insert_contact_us_post.sql index 739f084..7ca4495 100644 --- a/sql/functions/contact.insert_contact_us_post.sql +++ b/sql/functions/contact.insert_contact_us_post.sql @@ -30,15 +30,7 @@ begin p_email, p_phone, p_comments - ); - - select id into l_id - from contact.contact_us_posts - where first_name = p_first_name - and last_name = p_last_name - and email = p_email - and phone = p_phone - and comments = p_comments; + ) returning id into l_id; return l_id; end; diff --git a/sql/functions/resume.insert_contactinfo.sql b/sql/functions/resume.insert_contactinfo.sql new file mode 100644 index 0000000..428e69b --- /dev/null +++ b/sql/functions/resume.insert_contactinfo.sql @@ -0,0 +1,45 @@ +drop function resume.insert_contactinfo ( + p_user_id int, + p_state_id bigint, + p_visastatus_id bigint, + p_address character varying, + p_city character varying, + p_phone character varying, + p_email character varying +); + +create or replace function resume.insert_contactinfo ( + p_user_id int, + p_state_id bigint, + p_visastatus_id bigint, + p_address character varying, + p_city character varying, + p_phone character varying, + p_email character varying +) +returns bigint +as $$ +declare + l_id bigint; +begin + insert into resume.contactinfo ( + user_id, + state_id, + visastatus_id, + address, + city, + phone, + email + ) values ( + p_user_id, + p_state_id, + p_visastatus_id, + p_address, + p_city, + p_phone, + p_email + ) returning id into l_id; + + return l_id; +end; +$$ language plpgsql; diff --git a/sql/functions/resume.insert_resume.sql b/sql/functions/resume.insert_resume.sql index eb56897..99ac786 100644 --- a/sql/functions/resume.insert_resume.sql +++ b/sql/functions/resume.insert_resume.sql @@ -18,12 +18,7 @@ begin ) values ( p_user_id, p_name - ); - - select id into l_id - from resume.resume - where user_id = p_user_id - and name = p_name; + ) returning id into l_id; return l_id; end; diff --git a/sql/tables/resume.contactinfo.sql b/sql/tables/resume.contactinfo.sql index 9290da0..8523270 100644 --- a/sql/tables/resume.contactinfo.sql +++ b/sql/tables/resume.contactinfo.sql @@ -2,6 +2,7 @@ drop table resume.contactinfo cascade; create table resume.contactinfo ( id serial8 primary key, + user_id bigint not null references auth.users(id), address character varying(255) not null, city character varying(255) not null, state_id bigint not null references resume.states(id), diff --git a/sql/views/resume.contactinfo_v.sql b/sql/views/resume.contactinfo_v.sql new file mode 100644 index 0000000..4c4eb79 --- /dev/null +++ b/sql/views/resume.contactinfo_v.sql @@ -0,0 +1,17 @@ +drop view resume.contactinfo_v cascade; + +create or replace view resume.contactinfo_v as +select c.id, + c.user_id, + c.address, + c.city, + c.state_id, + s.state as state_name, + s.abbr as state_abbr, + c.phone, + c.email, + c.visastatus_id, + v.status as visastatus +from resume.contactinfo c +inner join resume.states s on c.state_id = s.id +inner join resume.visastatus v on c.visastatus_id = v.id; |
