Skip to content

Commit

Permalink
Rename admin to parents.
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Gratigny committed Apr 28, 2021
1 parent 9ca8fc1 commit 548d841
Show file tree
Hide file tree
Showing 69 changed files with 13,486 additions and 692 deletions.
9 changes: 9 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ class ApplicationController < ActionController::Base
before_action :set_current_family
helper_method :current_family
helper_method :find_family_from_cookie
helper_method :redirect_path
around_action :set_time_zone, if: :current_family_present?

def require_code!
Expand Down Expand Up @@ -34,4 +35,12 @@ def set_time_zone(&block)
Time.use_zone(current_family.current_time_zone, &block)
end

def redirect_path(args = {})
if params[:return_path].present?
params[:return_path]
else
build_redirect_path(args)
end
end

end
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Admin::ActivitiesController < Admin::BaseController
class Parents::ActivitiesController < Parents::BaseController
before_action :set_activity, only: %i[ show edit update destroy ]

# GET /admin/activities or /admin/activities.json
Expand All @@ -25,7 +25,7 @@ def create

respond_to do |format|
if @activity.save
format.html { redirect_to [:admin, :activities], notice: "Activity was successfully created." }
format.html { redirect_to [:parents, :activities], notice: "Activity was successfully created." }
format.json { render :show, status: :created, location: @activity }
else
format.html { render :new, status: :unprocessable_entity }
Expand All @@ -38,7 +38,7 @@ def create
def update
respond_to do |format|
if @activity.update(activity_params)
format.html { redirect_to [:admin, :activities], notice: "Activity was successfully updated." }
format.html { redirect_to [:parents, :activities], notice: "Activity was successfully updated." }
format.json { render :show, status: :ok, location: @activity }
else
format.html { render :edit, status: :unprocessable_entity }
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/parents/activity_signup_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class Parents::ActivitySignupController < ApplicationController
end
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
class Admin::BaseController < ApplicationController

class Parents::BaseController < ApplicationController
before_action :authenticate_user!
before_action :force_setup

layout "parents"

layout "admin"
def force_setup
return if controller_name.include?("signups") || !request.get?
redirect_to [:edit, :parents, :signup] unless current_user.family.signup.complete?
end

if ["production"].include?(Rails.env)
before_action :http_auth
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Admin::FamiliesController < Admin::BaseController
class Parents::FamiliesController < Parents::BaseController
before_action :set_admin_family, only: [:show, :edit, :update ]

# GET /admin/families/1 or /admin/families/1.json
Expand All @@ -9,11 +9,10 @@ def show
def edit
end

# PATCH/PUT /admin/families/1 or /admin/families/1.json
def update
respond_to do |format|
if @family.update(permitted_params)
format.html { redirect_to [:admin, :family], notice: "Family was successfully updated." }
format.html { redirect_to redirect_path, notice: "Family was successfully updated." }
format.json { render :show, status: :ok, location: @family }
else
format.html { render :edit, status: :unprocessable_entity }
Expand All @@ -22,6 +21,10 @@ def update
end
end

def build_redirect_path(args = {})
[:parents, :family]
end

private

# Use callbacks to share common setup or constraints between actions.
Expand Down
22 changes: 22 additions & 0 deletions app/controllers/parents/family_signups_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
class Parents::FamilySignupsController < Parents::BaseController
include SignupControllerModule

before_action :find_family

def edit
if current_family.signup_complete?
current_family.signup.complete_step!(signup_step)
end
end

private

def signup_step
SignupStep::Family.new
end

def find_family
@family = current_family
end

end
2 changes: 2 additions & 0 deletions app/controllers/parents/kid_signup_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class Parents::KidSignupController < ApplicationController
end
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Admin::KidsController < Admin::BaseController
class Parents::KidsController < Parents::BaseController
before_action :set_kid, only: %i[ show edit update destroy ]

before_action :build_collection
Expand Down Expand Up @@ -26,7 +26,7 @@ def create

respond_to do |format|
if @kid.save
format.html { redirect_to [:admin, @kid], notice: "Kid was successfully created." }
format.html { redirect_to [:parents, @kid], notice: "Kid was successfully created." }
format.json { render :show, status: :created, location: @kid }
else
format.html { render :new, status: :unprocessable_entity }
Expand All @@ -39,7 +39,7 @@ def create
def update
respond_to do |format|
if @kid.update(kid_params)
format.html { redirect_to [:admin, @kid], notice: "Kid was successfully updated." }
format.html { redirect_to [:parents, @kid], notice: "Kid was successfully updated." }
format.json { render :show, status: :ok, location: @kid }
else
format.html { render :edit, status: :unprocessable_entity }
Expand All @@ -52,7 +52,7 @@ def update
def destroy
@kid.destroy
respond_to do |format|
format.html { redirect_to [:admin, :kids], notice: "Kid was successfully destroyed." }
format.html { redirect_to [:parents, :kids], notice: "Kid was successfully destroyed." }
format.json { head :no_content }
end
end
Expand Down
7 changes: 7 additions & 0 deletions app/controllers/parents/signups_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class Parents::SignupsController < Parents::BaseController
include SignupControllerModule

def edit
redirect_to [:edit, :parents, "#{@signup.current_signup_step}_signup", return_path: url_for([:edit, :parents, "#{@signup.current_signup_step}_signup"])]
end
end
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Admin::TimeLogsController < Admin::BaseController
class Parents::TimeLogsController < Parents::BaseController
before_action :set_time_log, only: %i[ show edit update destroy ]

# GET /time_logs or /time_logs.json
Expand All @@ -25,7 +25,7 @@ def create

respond_to do |format|
if @time_log.save
format.html { redirect_to [:admin, :time_logs], notice: "Time log was successfully created." }
format.html { redirect_to [:parents, :time_logs], notice: "Time log was successfully created." }
format.json { render :show, status: :created, location: @time_log }
else
format.html { render :new, status: :unprocessable_entity }
Expand All @@ -38,7 +38,7 @@ def create
def update
respond_to do |format|
if @time_log.update(time_log_params)
format.html { redirect_to [:admin, @time_log], notice: "Time log was successfully updated." }
format.html { redirect_to [:parents, @time_log], notice: "Time log was successfully updated." }
format.json { render :show, status: :ok, location: @time_log }
else
format.html { render :edit, status: :unprocessable_entity }
Expand All @@ -51,7 +51,7 @@ def update
def destroy
@time_log.destroy
respond_to do |format|
format.html { redirect_to [:admin, :time_logs], notice: "Time log was successfully destroyed." }
format.html { redirect_to [:parents, :time_logs], notice: "Time log was successfully destroyed." }
format.json { head :no_content }
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/registrations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ def create
private

def configure_permitted_parameters
devise_parameter_sanitizer.permit(:sign_up, keys: [:first_name, :last_name, :family_name])
devise_parameter_sanitizer.permit(:sign_up, keys: [:first_name, :last_name])
end
end
2 changes: 1 addition & 1 deletion app/controllers/time_logs_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def update
def destroy
@time_log.destroy
respond_to do |format|
format.html { redirect_to [:admin, :time_logs], notice: "Time log was successfully destroyed." }
format.html { redirect_to [:parents, :time_logs], notice: "Time log was successfully destroyed." }
format.json { head :no_content }
end
end
Expand Down
27 changes: 27 additions & 0 deletions app/enums/signup_step.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
class SignupStep < ClassyEnum::Base
def last_step?
false
end
end

class SignupStep::Family < SignupStep
def step_number
1
end
end

class SignupStep::Kid < SignupStep
def step_number
2
end
end

class SignupStep::Activity < SignupStep
def step_number
3
end

def last_step?
true
end
end
2 changes: 2 additions & 0 deletions app/helpers/family_signups_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module FamilySignupsHelper
end
2 changes: 2 additions & 0 deletions app/helpers/parents/activity_signup_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module Parents::ActivitySignupHelper
end
2 changes: 2 additions & 0 deletions app/helpers/parents/family_signup_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module Parents::FamilySignupHelper
end
2 changes: 2 additions & 0 deletions app/helpers/parents/family_signups_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module Parents::FamilySignupsHelper
end
2 changes: 2 additions & 0 deletions app/helpers/parents/kid_signup_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module Parents::KidSignupHelper
end
2 changes: 2 additions & 0 deletions app/helpers/parents/setups_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module Parents::SetupsHelper
end
9 changes: 9 additions & 0 deletions app/javascript/application/javascripts/index.js.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<% files_glob = Rails.application.root.join('app', 'javascript', 'application', 'javascripts', 'lib', '**', '*.js') %>
<% Dir.glob(files_glob).each do |file| %>
import '<%= file %>';
<% end %>

<% files_glob = Rails.application.root.join('app', 'javascript', 'application', 'javascripts', 'coffeescript', '**', '*.coffee') %>
<% Dir.glob(files_glob).each do |file| %>
import '<%= file %>';
<% end %>
Loading

0 comments on commit 548d841

Please sign in to comment.