Allow closing accounts

Closes #37
This commit is contained in:
ricola 2026-04-20 14:17:52 -06:00
parent 1acc369774
commit 29bd105072
10 changed files with 115 additions and 15 deletions

View file

@ -7,15 +7,17 @@
<tr>
<th><%= _("Email") %></th>
<th><%= _("Created") %></th>
<th><%= _("Closed") %></th>
<th><%= _("Admin") %></th>
<th><%= _("Votes") %></th>
<th><%= _("Ratings") %></th>
</tr>
</thead>
<% @users.sort_by { |user| user.email }.each do |user| %>
<% all_users.each do |user| %>
<tr>
<td><a href="/users/<%= user.id %>"><%= user.email %></a></td>
<td><%= format_date(user.created_at) %></td>
<td><%= active(user) ? nil : format_date(user.closed_at) %></td>
<td><%= user.admin %></td>
<td><%= user.votes.length %></td>
<td><%= user.ratings.length %></td>

View file

@ -1,5 +1,9 @@
<h1 class="mb-5"><%= _("Login") %></h1>
<% if @closed %>
<p class="alert alert-success mb-4"><%= _("Your account was closed successfully.") %></p>
<% end %>
<% if @error %>
<div class="alert alert-warning mb-4">
<p><%= _("Incorrect email or password.") %></p>

11
views/users_close.erb Normal file
View file

@ -0,0 +1,11 @@
<h1 class="mb-5"><%= _("Closing account %{email}") % { email: @user.email } %></h1>
<p><%= _("Do you really want to close the account for %{email}?") % { email: @user.email } %></p>
<p><%= _("Past votes and ratings created by this account will remain available, but the account will no longer be able to log in, create new votes, or participate in open votes.") %></p>
<p><%= _("This action cannot be undone.") %></p>
<form action="/users/<%= @user.id %>/close" method="post" class="mb-5">
<button type="submit" class="btn btn-danger"><%= _("Close account") %></button>
</form>

View file

@ -4,7 +4,15 @@
<p><%= _("Updated: %{date}") % { date: format_date(@user.updated_at) } %></p>
<p class="mb-5"><%= _("Admin: %{admin}") % { admin: @user.admin ? _("Yes") : _("No") } %></p>
<p><%= _("Admin: %{admin}") % { admin: @user.admin ? _("Yes") : _("No") } %></p>
<% if @user.closed_at %>
<p class="mb-5"><%= _("Closed: %{date}") % { date: format_date(@user.closed_at) } %></p>
<% else %>
<form action="/users/<%= @user.id %>/close" method="get" class="mb-5">
<button type="submit" class="btn btn-outline-danger"><%= _("Close account") %></button>
</form>
<% end %>
<h2 class="mb-4"><%= _("Organized votes") %></h2>

View file

@ -175,7 +175,7 @@
<% end %>
</tr>
</thead>
<% all_users_sorted.each do |user| %>
<% users_for_vote(@vote).each do |user| %>
<tr>
<td><%= user.email %></td>
<% @vote.candidates.each do |candidate| %>

View file

@ -66,7 +66,7 @@
<h2 class="mb-4"><%= _("Participants") + " (#{@vote.ratings.collect { |rating| rating.user }.uniq.count})" %></h2>
<ul class="mb-5">
<% all_users_sorted.each do |user| %>
<% users_for_vote(@vote).each do |user| %>
<li>
<% if @vote.ratings.collect { |rating| rating.user }.include?(user) %>
<span>