Skip to content

Commit

Permalink
Add clear chong/wen/bao
Browse files Browse the repository at this point in the history
  • Loading branch information
zw963 committed May 29, 2024
1 parent 7e891db commit 872b39a
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 13 deletions.
6 changes: 6 additions & 0 deletions src/actions/me/clear_bao.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class Me::ClearBao < BrowserAction
put "/me/clear_bao" do
chong_wen_baos = ChongWenBaoQuery.new.user_id(current_user.id)
plain_text "ok"
end
end
11 changes: 11 additions & 0 deletions src/actions/me/clear_chong.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class Me::ClearChong < BrowserAction
put "/me/clear_chong" do
ChongWenBaoQuery.new.user_id(current_user.id).update(
chong_2023: false,
chong_2022: false,
chong_2021: false,
chong_2020: false
)
plain_text "ok"
end
end
6 changes: 6 additions & 0 deletions src/actions/me/clear_wen.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class Me::ClearWen < BrowserAction
put "/me/clear_wen" do
chong_wen_baos = ChongWenBaoQuery.new.user_id(current_user.id)
plain_text "ok"
end
end
48 changes: 35 additions & 13 deletions src/pages/me/show_page.cr
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,42 @@ class Me::ShowPage < MainLayout
def content
h2 "个人信息"
h3 "邮箱名: #{@current_user.email}"
# helpful_tips
end
link(
"清除用户冲数据",
Me::ClearChong,
class: "btn",
"hx-put": Me::ClearChong.path,
"hx-swap": "none",
"hx-include": "[name='_csrf']",
"hx-confirm": "确认要清除标记的冲数据吗?",
)

private def helpful_tips
h3 "Next, you may want to:"
ul do
li { link_to_authentication_guides }
li "Modify this page: src/pages/me/show_page.cr"
li "Change where you go after sign in: src/actions/home/index.cr"
end
end
br
br

link(
"清除用户稳数据",
Me::ClearWen,
class: "btn",
"hx-put": Me::ClearWen.path,
"hx-swap": "none",
"hx-include": "[name='_csrf']",
"hx-confirm": "确认要清除标记的稳数据吗?",
)

br
br

link(
"清除用户保数据",
Me::ClearChong,
class: "btn",
"hx-put": Me::ClearBao.path,
"hx-swap": "none",
"hx-include": "[name='_csrf']",
"hx-confirm": "确认要清除标记的保数据吗?",
)

private def link_to_authentication_guides
a "Check out the authentication guides",
href: "https://luckyframework.org/guides/authentication"
input(type: "hidden", value: context.session.get("X-CSRF-TOKEN"), name: "_csrf")
end
end

0 comments on commit 872b39a

Please sign in to comment.