summaryrefslogtreecommitdiff
path: root/lisp/service/profile-service.lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/service/profile-service.lisp')
-rw-r--r--lisp/service/profile-service.lisp34
1 files changed, 26 insertions, 8 deletions
diff --git a/lisp/service/profile-service.lisp b/lisp/service/profile-service.lisp
index 9e37bbf..d2a9f05 100644
--- a/lisp/service/profile-service.lisp
+++ b/lisp/service/profile-service.lisp
@@ -3,22 +3,36 @@
(in-package :resume)
-(defclass profile-service (auth-service user)
+(defclass profile-service (auth-service)
((title :initarg :title
:initform nil
:accessor title))
(:documentation ""))
+(defclass profile/view-service (profile-service)
+ ((items :initarg items
+ :initform nil
+ :accessor items)
+ (location-p :initform nil))
+ (:documentation ""))
+
+(defclass profile/modify-service (profile/view-service)
+ ((form :initarg :form
+ :initform nil
+ :accessor form))
+ (:documentation ""))
+
(defun profile-json ()
(with-auth (instance profile-service "profile-modify")
- (setf (title instance) "Profile")
- (sanitize-rest-json instance)))
+ (setf (title instance) "Profile")))
(defun profile-view-json ()
- (with-auth (instance profile-service "profile-modify")
+ (with-auth (instance profile/view-service "profile-modify")
(let ((user (get-user)))
- (copy-from-record instance user))
- (sanitize-rest-json instance)))
+ (setf (items instance) `(,user)))
+ (sanitize-rest-json instance)
+ (loop for item in (items instance)
+ do (sanitize-json item))))
(defclass profile/modify-service (profile-service)
((form :initarg :form
@@ -30,7 +44,7 @@
(defun profile-modify-json ()
(with-auth (instance profile/modify-service "profile-modify")
(let ((user (get-user)))
- (sanitize-rest-json instance)
+ (sanitize-json user)
(setf (title instance) "Profile - Modify")
(setf (form instance) (make-form "profile-modify-form"
nil
@@ -54,8 +68,12 @@
(intersection `(,x) '(id)))
(sb-introspect:function-lambda-list #'profile-modify-submit-json))
do (setf (slot-value user param) (symbol-value param)))
- (copy-from-record instance user)
(update-user auth-pkg user)
(set-user user)
(setf (session-value :message) "Profile saved successfully."))
(setf (session-value :errormsg) "An error occured."))))))
+
+(define-endpoint ("/profile" :method :get) () profile-json)
+(define-endpoint ("/profile/view" :method :get) () profile-view-json)
+(define-endpoint ("/profile/modify" :method :post) () profile-modify-json)
+(define-endpoint ("/profile/modify/submit" :method :post) (&post (id :parameter-type 'integer) (username :parameter-type 'string) (first_name :parameter-type 'string) (last_name :parameter-type 'string) (email :parameter-type 'string) (phone :parameter-type 'string)) profile-modify-submit-json id username first_name last_name email phone)