Skip to content

Commit

Permalink
add namespaces controller
Browse files Browse the repository at this point in the history
  • Loading branch information
ismail Akbudak committed Jun 21, 2016
1 parent b1b0386 commit c4536a9
Show file tree
Hide file tree
Showing 39 changed files with 332 additions and 102 deletions.
28 changes: 28 additions & 0 deletions lib/cybele/app_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,36 @@ def generate_welcome_page

def setup_namespaces
generate 'devise Admin name:string surname:string'

copy_file 'app/controllers/hq/application_controller.rb', 'app/controllers/hq/application_controller.rb'

copy_file 'app/controllers/hq/dashboard_controller.rb', 'app/controllers/hq/dashboard_controller.rb'
template 'app/views/hq/dashboard/index.html.haml.erb', 'app/views/hq/dashboard/index.html.haml', force: true

copy_file 'app/controllers/hq/passwords_controller.rb', 'app/controllers/hq/passwords_controller.rb'
directory 'app/views/hq/passwords', 'app/views/hq/passwords'

copy_file 'app/controllers/hq/registrations_controller.rb', 'app/controllers/hq/registrations_controller.rb'
directory 'app/views/hq/registrations', 'app/views/hq/registrations'

copy_file 'app/controllers/hq/sessions_controller.rb', 'app/controllers/hq/sessions_controller.rb'
directory 'app/views/hq/sessions', 'app/views/hq/sessions'

# User
copy_file 'app/controllers/user/user_application_controller.rb', 'app/controllers/user/user_application_controller.rb'

copy_file 'app/controllers/user/dashboard_controller.rb', 'app/controllers/user/dashboard_controller.rb'
directory 'app/views/user/dashboard', 'app/views/user/dashboard'

copy_file 'app/controllers/user/passwords_controller.rb', 'app/controllers/user/passwords_controller.rb'
directory 'app/views/user/passwords', 'app/views/user/passwords'

copy_file 'app/controllers/user/registrations_controller.rb', 'app/controllers/user/registrations_controller.rb'
directory 'app/views/user/registrations', 'app/views/user/registrations'

copy_file 'app/controllers/user/sessions_controller.rb', 'app/controllers/user/sessions_controller.rb'
directory 'app/views/user/sessions', 'app/views/user/sessions'

end

def set_time_zone
Expand Down
10 changes: 10 additions & 0 deletions templates/app/controllers/hq/passwords_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class Hq::PasswordsController < Devise::PasswordsController
layout 'hq/login'

private

def after_resetting_password_path_for(resource)
hq_root_path
end

end
20 changes: 20 additions & 0 deletions templates/app/controllers/hq/registrations_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
class Hq::RegistrationsController < Devise::RegistrationsController
layout 'hq/application'
before_action :authenticate_admin!
before_action :redirect_admin, only: [:new, :create, :destroy]
add_breadcrumb I18n.t('activerecord.models.admin'), :hq_root_path

def edit
end

private

def redirect_admin
redirect_to hq_root_path
end

def after_update_path_for(resource)
hq_root_path
end

end
8 changes: 8 additions & 0 deletions templates/app/controllers/user/dashboard_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class User::DashboardController < User::UserApplicationController

add_breadcrumb I18n.t('dock.dashboard'), :user_dashboard_index_path

def index
end

end
10 changes: 10 additions & 0 deletions templates/app/controllers/user/passwords_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class User::PasswordsController < Devise::PasswordsController
layout 'user/login'

private

def after_resetting_password_path_for(resource)
user_root_path
end

end
34 changes: 34 additions & 0 deletions templates/app/controllers/user/profiles_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
class User::ProfilesController < User::UserApplicationController

before_action :set_profile, only: [:show, :edit, :update]
add_breadcrumb I18n.t('dock.profile'), :user_profile_path

def show
add_breadcrumb @profile.full_name, user_profile_path
respond_with([:user, @profile])
end

def edit
add_breadcrumb t('tooltips.edit'), edit_user_profile_path
end

def update
@profile.update(profile_params)
respond_with([:user, @profile], location: user_profile_path)
end

private

def set_profile
@profile = current_user
end

def profile_params
params.require(:user)
.permit(
:name,
:surname,
:timezone
)
end
end
20 changes: 20 additions & 0 deletions templates/app/controllers/user/registrations_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
class User::RegistrationsController < Devise::RegistrationsController
layout 'user/application'
before_action :authenticate_user!
before_action :redirect_user, only: [:new, :create, :destroy]
add_breadcrumb I18n.t('activerecord.models.user'), :user_root_path

def edit
end

private

def redirect_user
redirect_to user_root_path
end

def after_update_path_for(resource)
user_root_path
end

end
16 changes: 16 additions & 0 deletions templates/app/controllers/user/sessions_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class User::SessionsController < Devise::SessionsController
layout 'user/login'

private

# Overwriting the sign_out redirect path method
def after_sign_in_path_for(resource_or_scope)
user_root_path
end

# Overwriting the sign_out redirect path method
def after_sign_out_path_for(resource_or_scope)
new_user_session_path
end

end
8 changes: 8 additions & 0 deletions templates/app/controllers/user/user_application_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
require 'application_responder'

class User::UserApplicationController < ActionController::Base
layout 'user/application'
before_action :authenticate_user!
self.responder = ApplicationResponder
respond_to :html, :json
end
11 changes: 6 additions & 5 deletions templates/app/views/devise/confirmations/new.html.haml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
%h2 Resend confirmation instructions
= simple_form_for(resource, :as => resource_name, :url => confirmation_path(resource_name), :html => { :method => :post }) do |f|
%h2
= t('devise.confirmation.new.title')
= simple_form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: { method: :post }) do |f|
= f.error_notification
= f.full_error :confirmation_token
.form-inputs
= f.input :email, :required => true, :autofocus => true
= f.input :email, required: true, autofocus: true
.form-actions
= f.button :submit, "Resend confirmation instructions"
= render "devise/shared/links"
= f.button :submit, t('devise.confirmation.btn.resend'), class: 'btn btn-primary'
= render 'devise/shared/links'
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
%p
Welcome #{@email}!
%p You can confirm your account email through the link below:
%p= link_to 'Confirm my account', confirmation_url(@resource, :confirmation_token => @resource.confirmation_token)
= t( 'email.salut', user: @resource.email )
%p
= "#{t( 'email.devise.confirmation_instruction.desc1')} :"
%p
= link_to t( 'email.devise.confirmation_instruction.btn_confirm'), confirmation_url(@resource, confirmation_token: @token)
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
%p
= t( 'email.salut', email: @resource.email )
= t( 'email.salut', user: @resource.email )
%p
= t( 'email.devise.reset_password.desc1')
%p= link_to t( 'email.devise.reset_password.change'), edit_password_url(@resource, :reset_password_token => @token)
%p= link_to t( 'email.devise.reset_password.change'), edit_password_url(@resource, reset_password_token: @token)
%p
= t( 'email.devise.reset_password.desc2')
%p
Expand Down
6 changes: 3 additions & 3 deletions templates/app/views/devise/passwords/edit.html.haml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
%h2= t('devise.password.edit.title')
= simple_form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :put }) do |f|
= simple_form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :put }) do |f|
= f.error_notification
= f.input :reset_password_token, :as => :hidden
= f.input :reset_password_token, as: :hidden
= f.full_error :reset_password_token
.form-inputs
= f.input :password, label: t('devise.password.edit.new_password'), required: true, autofocus: true
= f.input :password_confirmation, label: t('devise.password.edit.confirmation'), required: true
.form-actions
= f.button :submit, t('devise.password.edit.button'), class: 'btn btn-primary'
= render "devise/shared/links"
= render 'devise/shared/links'
6 changes: 3 additions & 3 deletions templates/app/views/devise/passwords/new.html.haml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
%h2= t('devise.password.reset.title')
= simple_form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :post }) do |f|
= simple_form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f|
= f.error_notification
.form-inputs
= f.input :email, :required => true, :autofocus => true
= f.input :email, required: true, autofocus: true
.form-actions
= f.button :submit, t('devise.password.reset.instructions'), class: 'btn btn-primary'
%br
= render "devise/shared/links"
= render 'devise/shared/links'
16 changes: 5 additions & 11 deletions templates/app/views/devise/registrations/edit.html.haml
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
%h2
= t('devise.registration.title', model: resource.class.model_name.human )
= simple_form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f|
= simple_form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f|
= f.error_notification
.form-inputs
= f.input :email, :required => true, :autofocus => true
- if devise_mapping.confirmable? && resource.pending_reconfirmation?
%p
Currently waiting confirmation for: #{resource.unconfirmed_email}
= f.input :password, :autocomplete => "off", hint: t('devise.registration.hint_password'), :required => false
= f.input :password_confirmation, :required => false
= f.input :current_password, hint: t('devise.registration.hint_current_password'), :required => true
= f.input :email, required: true, autofocus: true
= f.input :password, autocomplete: 'off', hint: t('devise.registration.hint_password'), required: false
= f.input :password_confirmation, required: false
= f.input :current_password, hint: t('devise.registration.hint_current_password'), required: true
.form-actions
= f.button :submit, t('btn.update'), class: 'btn btn-primary'
%h3 Cancel my account
%p
Unhappy? #{link_to "Cancel my account", registration_path(resource_name), :data => { :confirm => "Are you sure?" }, :method => :delete}
= link_to t('btn.back'), :back
24 changes: 18 additions & 6 deletions templates/app/views/devise/registrations/new.html.haml
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
%h2
= t('devise.registration.new.title', model: resource.class.model_name.human)
= simple_form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f|
%hr/
- if devise_mapping.omniauthable?
- resource_class.omniauth_providers.each do |provider|
= link_to omniauth_authorize_path(resource_name, provider), class: 'btn btn-lg btn-primary btn-block' do
%i.fa.fa-facebook
= t('devise.shared.links.signup_with', name: provider.to_s.titleize)
%hr/
%h3.text-center
= t('view.or')
%hr/
= simple_form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f|
= f.error_notification
.form-inputs
= f.input :name, :autofocus => true
= f.input :email, :required => true
= f.input :password, :required => true
= f.input :password_confirmation, :required => true
= f.input :email, required: true
= f.input :password, required: true
= f.input :password_confirmation, required: true
= f.input :name, required: true
= f.input :surname, required: true
= f.input :time_zone, input_html: { class: 'chosen-select'}, include_blank: t('view.select'), required: true
.form-actions
= f.button :submit, t('devise.registration.new.button'), class: 'btn btn-primary'
= render "devise/shared/links"
= render 'devise/shared/links'
2 changes: 1 addition & 1 deletion templates/app/views/devise/sessions/new.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
= f.input :remember_me, label: t('devise.session.remember_me'), as: :boolean if devise_mapping.rememberable?
.form-actions
= f.button :submit, t('devise.session.button'), class: 'btn btn-primary'
= render "devise/shared/links"
= render 'devise/shared/links'
4 changes: 3 additions & 1 deletion templates/app/views/devise/shared/_links.haml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@
- if devise_mapping.omniauthable?
- resource_class.omniauth_providers.each do |provider|
= link_to t('devise.shared.links.signin_with', name: provider.to_s.titleize), omniauth_authorize_path(resource_name, provider)
%br/
%br/
= link_to t('navbar.home_page'), root_path
%br/
8 changes: 4 additions & 4 deletions templates/app/views/devise/unlocks/new.html.haml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
%h2 Resend unlock instructions
= simple_form_for(resource, :as => resource_name, :url => unlock_path(resource_name), :html => { :method => :post }) do |f|
= simple_form_for(resource, as: resource_name, url: unlock_path(resource_name), html: { method: :post }) do |f|
= f.error_notification
= f.full_error :unlock_token
.form-inputs
= f.input :email, :required => true, :autofocus => true
= f.input :email, required: true, autofocus: true
.form-actions
= f.button :submit, "Resend unlock instructions"
= render "devise/shared/links"
= f.button :submit, 'Resend unlock instructions'
= render 'devise/shared/links'
15 changes: 0 additions & 15 deletions templates/app/views/hq/admin_profiles/_form.html.haml

This file was deleted.

3 changes: 0 additions & 3 deletions templates/app/views/hq/admin_profiles/edit.html.haml

This file was deleted.

3 changes: 0 additions & 3 deletions templates/app/views/hq/admin_profiles/new.html.haml

This file was deleted.

13 changes: 0 additions & 13 deletions templates/app/views/hq/admin_profiles/show.html.haml

This file was deleted.

12 changes: 12 additions & 0 deletions templates/app/views/hq/passwords/edit.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
%h2= t('devise.password.edit.title')
= simple_form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :put }) do |f|
= f.error_notification
= f.input :reset_password_token, as: :hidden
= f.full_error :reset_password_token
.form-inputs
= f.input :password, required: true, autofocus: true
= f.input :password_confirmation, required: true
.form-actions
= f.button :submit, t('devise.password.edit.button') , class: 'btn btn-primary'
%hr
= render 'devise/shared/links'
10 changes: 10 additions & 0 deletions templates/app/views/hq/passwords/new.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
%h2= t('devise.password.new.title')
= simple_form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f|
= f.error_notification
.form-inputs
= f.input :email, required: true, autofocus: true
.form-actions
= f.button :submit, t('devise.password.reset.instructions'), class: 'btn btn-primary'

%hr
= render 'devise/shared/links'
Loading

0 comments on commit c4536a9

Please sign in to comment.