feat(panettone): Add a settings page

Add a user settings page, with a single checkbox that allows disabling
receiving all email notifications.

Change-Id: Ibef2a497cd59f93b695ff8b9cd36047e514e00c2
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2806
Tested-by: BuildkiteCI
Reviewed-by: sterni <sternenseemann@systemli.org>
Reviewed-by: tazjin <mail@tazj.in>
This commit is contained in:
Griffin Smith 2021-04-03 14:27:37 -04:00 committed by glittershark
parent 8d3ab61e7c
commit 3ec15ec9f9
4 changed files with 70 additions and 6 deletions

View file

@ -75,10 +75,12 @@
(who:htm (:a :href "/" "All Issues")))
(if *user*
(who:htm
(:form :class "form-link log-out"
:method "post"
:action "/logout"
(:input :type "submit" :value "Log Out")))
(:div :class "nav-group"
(:a :href "/settings" "Settings")
(:form :class "form-link log-out"
:method "post"
:action "/logout"
(:input :type "submit" :value "Log Out"))))
(who:htm
(:a :href
(format nil
@ -169,6 +171,27 @@
(:input :type "submit"
:value "Submit"))))))
(defun render/settings ()
(let ((settings (model:settings-for-user (dn *user*))))
(render ()
(:div
:class "settings-page"
(:header
(:h1 "Settings"))
(:form
:method :post :action "/settings"
(:div
(:label :class "checkbox"
(:input :type "checkbox"
:name "enable-email-notifications"
:id "enable-email-notifications"
:checked (model:enable-email-notifications-p
settings))
"Enable Email Notifications"))
(:div :class "form-group"
(:input :type "submit"
:value "Save Settings")))))))
(defun created-by-at (issue)
(check-type issue model:issue)
(who:with-html-output (*standard-output*)
@ -438,6 +461,17 @@
(let ((issues (model:list-issues :status :open)))
(render/index :issues issues)))
(defroute settings ("/settings" :method :get :decorators (@auth)) ()
(render/settings))
(defroute save-settings ("/settings" :method :post :decorators (@auth))
(&post enable-email-notifications)
(let ((settings (model:settings-for-user (dn *user*))))
(model:update-user-settings
settings
'model:enable-email-notifications enable-email-notifications)
(render/settings)))
(defroute handle-closed-issues
("/issues/closed" :decorators (@auth-optional)) ()
(let ((issues (model:list-issues :status :closed)))