master
E. Almqvist 3 years ago
parent 8599895cb2
commit c3e3b2f062
  1. 18
      src/app.rb
  2. 38
      src/views/admin/users/edit.slim
  3. 2
      src/views/stylesheets/style.sass

@ -245,7 +245,7 @@ get "/admin/users/:id/ban" do
flash[:error] = "Banned user '#{user.name}'" flash[:error] = "Banned user '#{user.name}'"
redirect "/admin" redirect back
end end
get "/admin/users/:id/unban" do get "/admin/users/:id/unban" do
@ -256,7 +256,15 @@ get "/admin/users/:id/unban" do
flash[:success] = "Unbanned user '#{user.name}'" flash[:success] = "Unbanned user '#{user.name}'"
redirect "/admin" redirect back
end
get "/admin/users/:id/edit" do
auth_denied unless get_current_user.admin?
id = params[:id].to_i
user = User.find_by_id id
serve :"admin/users/edit", {user: user}
end end
# ADMIN ROLE MANAGEMENT # ADMIN ROLE MANAGEMENT
@ -272,7 +280,7 @@ get "/admin/roles/:id/delete" do
Role.delete "id = ?", id Role.delete "id = ?", id
flash[:success] = "Removed role." flash[:success] = "Removed role."
redirect "/admin" redirect back
end end
get "/admin/roles/:id/edit" do get "/admin/roles/:id/edit" do
@ -331,7 +339,7 @@ post "/admin/roles/give" do
promoted_user = User.find_by_id user_id promoted_user = User.find_by_id user_id
flash[:success] = "Gave role '#{newrole.name}' to #{promoted_user.name}!" if resp flash[:success] = "Gave role '#{newrole.name}' to #{promoted_user.name}!" if resp
redirect "/admin" redirect back
else else
auth_denied "You are not permitted to give that role!", 403, "/admin" auth_denied "You are not permitted to give that role!", 403, "/admin"
end end
@ -354,5 +362,5 @@ post "/admin/roles" do
else else
flash[:error] = resp flash[:error] = resp
end end
redirect "/admin" redirect back
end end

@ -1,19 +1,29 @@
article.card.border
h2 = "Edit role '#{role.name}'"
.form-container .border
form action="/admin/roles/#{role.id}/update" method="post" h1.tcenter = "#{user.name} (id=#{user.id})"
label Role name nav.tcenter
input type="text" name="name" pattern="#{NAME_REGEX_STR}" maxlength="#{MAX_NAME_LEN}" oninput="this.reportValidity()" title="#{REGISTER_ERRORS[:name_desc]}" value="#{role.name}" - if user.banned?
a.green.inlbutton href="/admin/users/#{user.id}/unban"
| [UNBAN USER]
- else
a.red.inlbutton href="/admin/users/#{user.id}/ban"
| [BAN USER]
a.inlbutton href="/admin"
| [GO BACK]
label Role color .management-container
input type="color" name="color" value="#{role.color}" .border
h2.tcenter = "User Settings"
.form-container
form action="/user/update" method="post" enctype="multipart/form-data"
img.avatar_big src="#{user.avatar_url}" alt="Your avatar"
label Change avatar
input type="file" name="image" accept="image"
label Role flags int label Display name
input type="number" name="flags" value="#{role.flags}" input type="text" oninput="this.reportValidity()" title="May only contain alphabetical characters and must be between #{MIN_NAME_LEN} and #{MAX_NAME_LEN} characters long" maxlength="#{MAX_NAME_LEN}" name="displayname" value="#{user.name}" pattern="#{NAME_REGEX_STR}"
label Biography
textarea name="bio" cols="20" rows="5" title="Content length must be between #{MIN_BIO_LEN} and #{MAX_BIO_LEN} characters" pattern="#{BIO_REGEX_STR}" maxlength="#{MAX_BIO_LEN}" placeholder="Tell us about yourself!" value="#{user.bio_text}" = user.bio_text
input type="submit" value="Update" input type="submit" value="Update"
a.button href="/admin/roles/#{role.id}/delete"
| [DELETE ROLE]
a.button href="/admin"
| [GO BACK]

@ -156,7 +156,7 @@ a.button:hover
font-weight: bold font-weight: bold
animation: fade-in .9s ease-in alternate animation: fade-in .9s ease-in alternate
background: $bg_clr background: $bg_clr
transition: .4s opacity transition: .1s opacity
div:not(:last-child) div:not(:last-child)
margin-bottom: 1rem margin-bottom: 1rem

Loading…
Cancel
Save