forked from rubyforgood/partner
-
Notifications
You must be signed in to change notification settings - Fork 0
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
12 changed files
with
197 additions
and
5 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,23 @@ | ||
class Users::InvitationsController < Devise::InvitationsController | ||
layout "application" | ||
|
||
def create | ||
user = User.invite!( | ||
email: user_params[:email], | ||
name: user_params[:name], | ||
partner: current_partner, | ||
) | ||
flash[:success] = "You have invited #{user.name} to join your organization!" | ||
redirect_to users_path | ||
end | ||
|
||
def new | ||
@user = current_partner.users.new | ||
end | ||
|
||
private | ||
|
||
def user_params | ||
params.require(:user).permit(:name, :email) | ||
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 @@ | ||
class UsersController < ApplicationController | ||
def index | ||
@users = current_partner.users | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<% flash.each do |key, message| %> | ||
<div class="alert #{key} alert-#{key} alert-dismissible" role="alert"> | ||
<a href="#" class="close" data-dismiss="alert" aria-label="close" style="text-decoration: none;"><%= fa_icon('times') %></a> | ||
<%== message %> | ||
</div> | ||
<% 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,41 @@ | ||
<%= form_with(model: user, local: true) do |form| %> | ||
<div class="row"> | ||
<div class="col-md-12"> | ||
<% if user.errors.any? %> | ||
<div id="error_explanation"> | ||
<h2><%= pluralize(user.errors.count, "error") %> prohibited this user from being saved:</h2> | ||
|
||
<ul> | ||
<% user.errors.full_messages.each do |message| %> | ||
<li><%= message %></li> | ||
<% end %> | ||
</ul> | ||
</div> | ||
<% end %> | ||
|
||
<div class="tile"> | ||
<h3 class="tile-title">Invite a New User to <%= current_partner.name %></h3> | ||
<div class="tile-body"> | ||
|
||
<div class="form-horizontal"> | ||
<div class="form-group row"> | ||
<%= form.label :name, class: "control-label col-md-3"%> | ||
<%= form.text_field :name, class: "col-md-8 form-control" %> | ||
</div> | ||
</div> | ||
|
||
<div class="form-horizontal"> | ||
<div class="form-group row"> | ||
<%= form.label :email, class: "control-label col-md-3"%> | ||
<%= form.text_field :email, class: "col-md-8 form-control" %> | ||
</div> | ||
</div> | ||
|
||
<div class="actions"> | ||
<%= form.submit(class: 'btn btn-primary') %> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<% 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,36 @@ | ||
<div class="app-title"> | ||
<div> | ||
<h1><i class="fa fa-users"></i>Users</h1> | ||
</div> | ||
<ul class="app-breadcrumb breadcrumb"> | ||
<li class="breadcrumb-item"><i class="fa fa-users"></i></li> | ||
<li class="breadcrumb-item"><a href="#">Users</a></li> | ||
</ul> | ||
</div> | ||
|
||
<div class="row"> | ||
<div class="col-md-12"> | ||
<div class="tile"> | ||
<h3><%= current_partner.name %> Users </h3> | ||
<%= link_to "Invite new user", new_user_invitation_path, class: "btn btn-sam btn-primary pull-right" %> | ||
|
||
<table class="table table-striped"> | ||
<thead> | ||
<tr> | ||
<th scope="col">Name</th> | ||
<th scope="col">Email</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<% @users.each do |user| %> | ||
<tr> | ||
<td><%= user.name %></td> | ||
<td><%= user.email %></td> | ||
</tr> | ||
<% end %> | ||
</tbody> | ||
</table> | ||
<hr> | ||
</div> | ||
</div> | ||
</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,54 @@ | ||
<div class="app-title"> | ||
<div> | ||
<h1><i class="fa fa-new"></i>New User</h1> | ||
</div> | ||
<ul class="app-breadcrumb breadcrumb"> | ||
<li class="breadcrumb-item"><i class="fa fa-users"></i></li> | ||
<li class="breadcrumb-item"><a href="#">New User</a></li> | ||
</ul> | ||
</div> | ||
|
||
<%= form_for resource, :as => resource_name, :url => invitation_path(resource_name), :html => {:method => :post} do |form| %> | ||
<div class="row"> | ||
<div class="col-md-12"> | ||
<% if @user.errors.any? %> | ||
<div id="error_explanation"> | ||
<h2><%= pluralize(@user.errors.count, "error") %> prohibited this user from being saved:</h2> | ||
|
||
<ul> | ||
<% @user.errors.full_messages.each do |message| %> | ||
<li><%= message %></li> | ||
<% end %> | ||
</ul> | ||
</div> | ||
<% end %> | ||
|
||
<div class="tile"> | ||
<h3 class="tile-title">Invite a New User to <%= current_partner.name %></h3> | ||
<div class="tile-body"> | ||
|
||
<div class="form-horizontal"> | ||
<div class="form-group row"> | ||
<%= form.label :name, class: "control-label col-md-3"%> | ||
<%= form.text_field :name, class: "col-md-8 form-control" %> | ||
</div> | ||
</div> | ||
|
||
<div class="form-horizontal"> | ||
<div class="form-group row"> | ||
<%= form.label :email, class: "control-label col-md-3"%> | ||
<%= form.text_field :email, class: "col-md-8 form-control" %> | ||
</div> | ||
</div> | ||
|
||
<div class="actions"> | ||
<%= form.submit(class: 'btn btn-primary') %> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<% end %> | ||
<%= link_to 'Back', users_path %> |
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,5 @@ | ||
class AddNameToUsers < ActiveRecord::Migration[5.2] | ||
def change | ||
add_column :users, :name, :string | ||
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 |
---|---|---|
|
@@ -19,6 +19,7 @@ | |
partner_status: "verified" | ||
) | ||
User.create( | ||
name: Faker::Name.name, | ||
password: "password", | ||
password_confirmation: "password", | ||
email: "[email protected]", | ||
|
@@ -84,6 +85,7 @@ | |
executive_director_email: "[email protected]" | ||
) | ||
User.create( | ||
name: Faker::Name.name, | ||
password: "password", | ||
password_confirmation: "password", | ||
email: "[email protected]", | ||
|
@@ -132,6 +134,7 @@ | |
executive_director_email: "[email protected]" | ||
) | ||
User.create( | ||
name: Faker::Name.name, | ||
password: "password", | ||
password_confirmation: "password", | ||
email: "[email protected]", | ||
|
@@ -157,6 +160,7 @@ | |
executive_director_email: "[email protected]" | ||
) | ||
User.create( | ||
name: Faker::Name.name, | ||
password: "password", | ||
password_confirmation: "password", | ||
email: "[email protected]", | ||
|