-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
084b4ae
commit 7ecda3c
Showing
14 changed files
with
160 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.user-snippet__title { | ||
margin: 0; | ||
color: var(--red); | ||
} |
14 changes: 14 additions & 0 deletions
14
app/controllers/admin/hackathons/subscriptions_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
class Admin::Hackathons::SubscriptionsController < Admin::BaseController | ||
before_action :set_subscription | ||
|
||
def destroy | ||
@subscription.unsubscribe | ||
redirect_to admin_user_path(@subscription.subscriber) | ||
end | ||
|
||
private | ||
|
||
def set_subscription | ||
@subscription = Hackathon::Subscription.find(params[:id]) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class Admin::Users::EmailAddressesController < Admin::BaseController | ||
include UserScoped | ||
|
||
def edit | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class Admin::Users::NamesController < Admin::BaseController | ||
include UserScoped | ||
|
||
def edit | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
class Admin::UsersController < Admin::BaseController | ||
before_action :set_user, except: :index | ||
|
||
def index | ||
@pagy, @users = pagy User.all.order(created_at: :desc) | ||
end | ||
|
||
def show | ||
end | ||
|
||
def update | ||
if @user.update(user_params) | ||
redirect_to admin_user_path(@user) | ||
else | ||
flash.now[:notice] = @user.errors.full_messages.to_sentence | ||
|
||
respond_to do |format| | ||
format.turbo_stream { render turbo_stream: turbo_stream.replace("flash", partial: "shared/flash") } | ||
|
||
format.html { render :edit, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
private | ||
|
||
def set_user | ||
@user = User.find(params[:id]) | ||
end | ||
|
||
def user_params | ||
params.require(:user).permit(:name, :email_address) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module UserScoped | ||
extend ActiveSupport::Concern | ||
|
||
included do | ||
before_action :set_user | ||
end | ||
|
||
private | ||
|
||
def set_user | ||
@user = User.find(params[:user_id]) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
<div style="display: flex; gap: var(--spacing-2) var(--spacing-4); flex-wrap: wrap"> | ||
<%= render "admin/header/nav/link", title: "Hackathons", link: admin_hackathons_path %> | ||
<%= render "admin/header/nav/link", title: "Users", link: admin_users_path %> | ||
<%= render "admin/header/nav/link", title: "New Submission", link: new_hackathons_submission_path %> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<%= link_to admin_user_path(user), style: "text-decoration: none;" do %> | ||
<article id="<%= dom_id(user) %>" class="card interactive"> | ||
<h2 class="user-snippet__title"><%= user.display_name %></h2> | ||
<p><%= user.email_address %></p> | ||
</article> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<turbo-frame id="email_address"> | ||
<%= form_with model: @user, url: admin_user_path(@user), data: {controller: "form"} do |form| %> | ||
<h2> | ||
<%= form.text_field :email_address, required: true, data: | ||
{action: "click@document->form#submitOnClickOutside keydown->form#submitOnEnter"} %> | ||
</h2> | ||
<% end %> | ||
</turbo-frame> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<% page :narrow %> | ||
<% @nav_active_item = admin_users_path %> | ||
<h1 class="title">Users</h1> | ||
|
||
<%= render partial: "snippet", collection: @users, as: :user %> | ||
|
||
<%== pagy_nav(@pagy) %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<turbo-frame id="name"> | ||
<%= form_with model: @user, url: admin_user_path(@user), data: {controller: "form"} do |form| %> | ||
<h1> | ||
<%= form.text_field :name, data: | ||
{action: "click@document->form#submitOnClickOutside keydown->form#submitOnEnter"} %> | ||
</h1> | ||
<% end %> | ||
</turbo-frame> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<% content_for :title, (@user.display_name) %> | ||
|
||
<article id="<%= dom_id(@user) %>"> | ||
<turbo-frame id="name"> | ||
<h1> | ||
🪪 | ||
<%= @user.display_name %> | ||
<%= link_to "✏️", edit_admin_user_name_path(@user), class: "hidden-link text--small" %> | ||
</h1> | ||
</turbo-frame> | ||
|
||
<turbo-frame id="email_address"> | ||
<h2> | ||
📧 | ||
<%= @user.email_address %> | ||
<%= link_to "✏️", edit_admin_user_email_address_path(@user), class: "hidden-link text--small" %> | ||
</h2> | ||
</turbo-frame> | ||
|
||
<turbo-frame id="subscriptions"> | ||
<% if @user.subscriptions.active.any? %> | ||
<div class="mt3"> | ||
<h3>Active Subscriptions</h3> | ||
<ul> | ||
<% @user.subscriptions.active.each do |subscription| %> | ||
<li> | ||
<%= subscription.location %> | ||
<%= link_to "⛔", admin_subscription_path(subscription), | ||
style: "text-decoration: none;", "data-turbo-method": "delete", | ||
"data-turbo-confirm": "Remove this subscription for #{subscription.location}?" %> | ||
</li> | ||
<% end %> | ||
</ul> | ||
</div> | ||
<% end %> | ||
</turbo-frame> | ||
|
||
<%= render "events/timeline", {eventable: @user} %> | ||
</article> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters