-
-
Notifications
You must be signed in to change notification settings - Fork 1
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
Showing
43 changed files
with
419 additions
and
80 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
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
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,62 @@ | ||
# frozen_string_literal: true | ||
|
||
class UsersController < BaseController | ||
def index | ||
@users = @club.users.page(params[:page]) | ||
end | ||
|
||
def new | ||
@user = @club.users.build | ||
end | ||
|
||
def edit | ||
@user = @club.users.find(params[:id]) | ||
end | ||
|
||
def create | ||
@user = @club.users.build(user_params) | ||
@user.role = :collaborator | ||
@user.password = 'password' | ||
|
||
if @user.save | ||
respond_to do |format| | ||
format.html { redirect_to new_club_user_url(@club), flash: { notice: I18n.t('users.created') } } | ||
format.turbo_stream { flash.now[:notice] = I18n.t('users.created') } | ||
end | ||
else | ||
respond_to do |format| | ||
format.html { render :new, status: :unprocessable_entity } | ||
format.turbo_stream | ||
end | ||
end | ||
end | ||
|
||
def update | ||
@user = @club.users.find(params[:id]) | ||
|
||
if @user.update(user_params) | ||
respond_to do |format| | ||
format.html { redirect_to club_users_url(@club), flash: { notice: I18n.t('users.updated') } } | ||
format.turbo_stream { flash.now[:notice] = I18n.t('users.updated') } | ||
end | ||
else | ||
respond_to do |format| | ||
format.html { render :edit, status: :unprocessable_entity } | ||
format.turbo_stream | ||
end | ||
end | ||
end | ||
|
||
def destroy | ||
@user = @club.users.find(params[:id]) | ||
@user.destroy | ||
|
||
redirect_to club_users_url(@club), flash: { success: I18n.t('users.destroyed') } | ||
end | ||
|
||
private | ||
|
||
def user_params | ||
params.require(:user).permit(:first_name, :last_name, :email, :picture) | ||
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
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,14 +1,15 @@ | ||
<%= simple_form_for club, html: { class: 'row' } do |f| %> | ||
<h3> | ||
Club | ||
</h3> | ||
<%= f.input :name %> | ||
<%= f.input :email %> | ||
<%= | ||
<%= turbo_frame_tag club do %> | ||
<%= simple_form_for club, html: { class: 'row' } do |f| %> | ||
<h3> | ||
Club | ||
</h3> | ||
<%= f.input :name %> | ||
<%= f.input :email %> | ||
<%= | ||
if club.picture.present? | ||
image_tag club.picture, class: 'img-fluid img-thumbnail rounded mx-auto d-block', style: 'max-width: 200px' | ||
end | ||
%> | ||
<%= f.submit 'Save', class: 'btn btn-primary' %> | ||
</div> | ||
<% end %> | ||
<%= f.submit 'Save', class: 'btn btn-primary' %> | ||
<% 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,5 @@ | ||
<%= turbo_stream.prepend 'flash', partial: 'flash' %> | ||
|
||
<%= turbo_stream.update @club do %> | ||
<%= render 'form', club: @club %> | ||
<% 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 @@ | ||
<%= render "form", group: @group %> |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<li class="page-item"> | ||
<%= link_to_unless current_page.first?, raw(t 'views.pagination.first'), url, remote: remote, class: 'page-link' %> | ||
</li> |
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,3 @@ | ||
<li class='page-item disabled'> | ||
<%= link_to raw(t 'views.pagination.truncate'), '#', class: 'page-link' %> | ||
</li> |
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,3 @@ | ||
<li class="page-item"> | ||
<%= link_to_unless current_page.last?, raw(t 'views.pagination.last'), url, remote: remote, class: 'page-link' %> | ||
</li> |
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,3 @@ | ||
<li class="page-item"> | ||
<%= link_to_unless current_page.last?, raw(t 'views.pagination.next'), url, rel: 'next', remote: remote, class: 'page-link' %> | ||
</li> |
Oops, something went wrong.