-
Notifications
You must be signed in to change notification settings - Fork 10
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
hamitturkukaya
committed
Apr 18, 2014
1 parent
0c4f887
commit 0f86715
Showing
17 changed files
with
227 additions
and
105 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 |
---|---|---|
@@ -1,2 +1,5 @@ | ||
.idea/ | ||
*.gem | ||
*.gem | ||
*.log | ||
.bundle/ | ||
*.bundle/install.log |
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 |
---|---|---|
|
@@ -191,17 +191,27 @@ def generate_exception_notification | |
|
||
def add_exception_notification_to_environments | ||
config = <<-CODE | ||
config.middleware.use ExceptionNotification::Rack, | ||
:email => { | ||
:email_prefix => "[Whatever] ", | ||
:sender_address => %{"notifier" <[email protected]>}, | ||
:exception_recipients => %w{[email protected]} | ||
} | ||
config.middleware.use ExceptionNotification::Rack, | ||
:email => { | ||
:email_prefix => "[Whatever] ", | ||
:sender_address => %{"notifier" <[email protected]>}, | ||
:exception_recipients => %w{[email protected]} | ||
} | ||
CODE | ||
|
||
configure_environment('production', config) | ||
configure_environment('staging', config) | ||
|
||
inject_into_file 'config/initializers/exception_notification.rb', :before => 'config.add_notifier :email, {' do <<-RUBY | ||
unless Rails.env == 'development' | ||
RUBY | ||
end | ||
|
||
inject_into_file 'config/initializers/exception_notification.rb', :before => '# Campfire notifier sends notifications to your Campfire room.' do <<-RUBY | ||
end | ||
RUBY | ||
end | ||
|
||
end | ||
|
||
def leftovers | ||
|
@@ -252,33 +262,30 @@ def generate_hq_namespace | |
def setup_profile_editors | ||
# Inserting routes | ||
inject_into_file 'config/routes.rb', :after => "namespace :hq do\n" do <<-RUBY | ||
# Routing for admin profile editing | ||
match '/profile', to: 'profile#edit', via: :get | ||
match '/profile', to: 'profile#update', via: [:patch, :put] | ||
root to: 'dashboard#index' | ||
resource :admin_profile, except: [:destroy], path: 'profile' | ||
RUBY | ||
end | ||
|
||
inject_into_file 'config/routes.rb', :after => "'welcome#index'\n" do <<-RUBY | ||
# Routing for user profile editing | ||
match '/profile', to: 'profile#edit', via: :get | ||
match '/profile', to: 'profile#update', via: [:patch, :put] | ||
resource :user_profile, except: [:destroy], path: 'profile' | ||
RUBY | ||
end | ||
|
||
# Copying HAML templates | ||
copy_file 'app/views/hq/profile/edit.html.haml', 'app/views/hq/profile/edit.html.haml' | ||
copy_file 'app/views/profile/edit.html.haml', 'app/views/profile/edit.html.haml' | ||
|
||
copy_file 'app/controllers/profile_controller.rb', 'app/controllers/profile_controller.rb' | ||
end | ||
|
||
def set_time_zone | ||
add_set_user_time_zone_method_to_application_controller | ||
add_time_zone_to_user | ||
end | ||
|
||
def create_profile | ||
add_profile_models | ||
add_profile_controllers | ||
add_profile_views | ||
end | ||
|
||
def create_hierapolis_theme | ||
remove_file 'lib/templates/rails/responders_controller/controller.rb' | ||
remove_file 'lib/templates/haml/scaffold/_form.html.haml' | ||
|
@@ -420,6 +427,12 @@ def add_time_zone_to_user | |
generate 'migration AddTimeZoneToUser time_zone:string -s' | ||
end | ||
|
||
def add_profile_models | ||
say 'Creating Profile Models' | ||
generate 'model user_profile first_name:string last_name:string gsm:string user:references -s' | ||
generate 'model admin_profile first_name:string last_name:string gsm:string admin:references -s' | ||
end | ||
|
||
def add_set_user_time_zone_method_to_application_controller | ||
say 'Add set_user_time_zone method to application controller' | ||
inject_into_file 'app/controllers/application_controller.rb', :after => 'protected' do <<-CODE | ||
|
@@ -433,9 +446,32 @@ def set_user_time_zone | |
inject_into_file 'app/controllers/application_controller.rb', :after => 'class ApplicationController < ActionController::Base' do <<-CODE | ||
before_filter :set_user_time_zone | ||
respond_to :html, :json | ||
CODE | ||
end | ||
end | ||
|
||
def add_profile_controllers | ||
copy_file 'app/controllers/hq/admin_profiles_controller.rb', 'app/controllers/hq/admin_profiles_controller.rb' | ||
copy_file 'app/controllers/user_profiles_controller.rb', 'app/controllers/user_profiles_controller.rb' | ||
end | ||
|
||
def add_profile_views | ||
directory 'app/views/hq/admin_profiles', 'app/views/hq/admin_profiles' | ||
directory 'app/views/user_profiles', 'app/views/user_profiles' | ||
|
||
inject_into_file 'app/models/user.rb', :after => ":recoverable, :rememberable, :trackable, :validatable\n" do <<-RUBY | ||
has_one :user_profile | ||
accepts_nested_attributes_for :user_profile | ||
RUBY | ||
end | ||
|
||
inject_into_file 'app/models/admin.rb', :after => ":recoverable, :rememberable, :trackable, :validatable\n" do <<-RUBY | ||
has_one :admin_profile | ||
accepts_nested_attributes_for :admin_profile | ||
RUBY | ||
end | ||
end | ||
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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# encoding: UTF-8 | ||
class Hq::AdminProfilesController < Hq::ApplicationController | ||
before_action :set_admin_profile, only: [:show, :edit, :update, :destroy] | ||
add_breadcrumb I18n.t('activerecord.models.admin_profiles'), :hq_admin_profile_path | ||
|
||
def show | ||
if current_admin.admin_profile.present? | ||
add_breadcrumb @admin_profile.first_name, hq_admin_profile_path | ||
respond_with([:hq, @admin_profile]) | ||
else | ||
redirect_to new_hq_admin_profile_path | ||
end | ||
end | ||
|
||
def new | ||
add_breadcrumb t('tooltips.new'), new_hq_admin_profile_path | ||
@admin_profile = current_admin.build_admin_profile | ||
respond_with([:hq, @admin_profile]) | ||
end | ||
|
||
def edit | ||
add_breadcrumb @admin_profile.id, hq_admin_profile_path | ||
add_breadcrumb t('tooltips.edit'), edit_hq_admin_profile_path | ||
end | ||
|
||
def create | ||
@admin_profile = current_admin.build_admin_profile(admin_profile_params) | ||
@admin_profile.save | ||
respond_with([:hq, @admin_profile], location: hq_admin_profile_path) | ||
end | ||
|
||
def update | ||
@admin_profile.update(admin_profile_params) | ||
respond_with([:hq, @admin_profile], location: hq_admin_profile_path) | ||
end | ||
|
||
private | ||
|
||
def set_admin_profile | ||
@admin_profile = current_admin.admin_profile | ||
end | ||
|
||
def admin_profile_params | ||
params.require(:admin_profile).permit(:first_name, :gsm, :last_name) | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,46 @@ | ||
# encoding: UTF-8 | ||
class UserProfilesController < ApplicationController | ||
before_action :set_user_profile, only: [:show, :edit, :update, :destroy] | ||
add_breadcrumb I18n.t('activerecord.models.user_profiles'), :user_profile_path | ||
|
||
def show | ||
if current_user.user_profile.present? | ||
add_breadcrumb @user_profile.first_name, user_profile_path | ||
respond_with(@user_profile) | ||
else | ||
redirect_to new_user_profile_path | ||
end | ||
end | ||
|
||
def new | ||
add_breadcrumb t('tooltips.new'), new_user_profile_path | ||
@user_profile = current_user.build_user_profile | ||
respond_with(@user_profile) | ||
end | ||
|
||
def edit | ||
add_breadcrumb @user_profile.id, user_profile_path | ||
add_breadcrumb t('tooltips.edit'), edit_user_profile_path | ||
end | ||
|
||
def create | ||
@user_profile = current_user.build_user_profile(user_profile_params) | ||
@user_profile.save | ||
respond_with(@user_profile, location: user_profile_path) | ||
end | ||
|
||
def update | ||
@user_profile.update(user_profile_params) | ||
respond_with(@user_profile, location: user_profile_path) | ||
end | ||
|
||
private | ||
|
||
def set_user_profile | ||
@user_profile = current_user.user_profile | ||
end | ||
|
||
def user_profile_params | ||
params.require(:user_profile).permit(:first_name, :gsm, :last_name) | ||
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,15 @@ | ||
.panel.panel-default | ||
.panel-heading | ||
%i.icon-edit.icon-large | ||
= yield :form_title | ||
.panel-body | ||
= simple_form_for([:hq, @admin_profile], url: hq_admin_profile_path) do |f| | ||
= f.error_notification | ||
|
||
.form-inputs | ||
= f.input :first_name | ||
= f.input :last_name | ||
= f.input :gsm | ||
.form-actions | ||
= f.button :submit, class: 'btn btn-default' | ||
= link_to t('cancel'), hq_admin_profile_path, class: 'btn' |
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 @@ | ||
- content_for :form_title do | ||
= t('tt.edit', resource_name: AdminProfile.model_name.human) | ||
= render 'form' |
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 @@ | ||
- content_for :form_title do | ||
= t('tt.new', resource_name: AdminProfile.model_name.human) | ||
= render 'form' |
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 @@ | ||
- content_for :toolbar do | ||
= link_to edit_hq_admin_profile_path, class: 'btn btn-default' do | ||
%i.icon-pencil | ||
= t('action_button.edit') | ||
.panel.panel-default | ||
.panel-heading | ||
%i.icon-edit.icon-large | ||
= t('tt.show', resource_name: AdminProfile.model_name.human) | ||
.panel-body | ||
= show_for @admin_profile do |s| | ||
= s.attribute :first_name | ||
= s.attribute :last_name | ||
= s.attribute :gsm |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,16 @@ | ||
.panel.panel-default | ||
.panel-heading | ||
%i.icon-edit.icon-large | ||
= yield :form_title | ||
.panel-body | ||
= simple_form_for(@user_profile, url: user_profile_path) do |f| | ||
= f.error_notification | ||
|
||
.form-inputs | ||
= f.input :first_name | ||
= f.input :last_name | ||
= f.input :gsm | ||
|
||
.form-actions | ||
= f.button :submit, class: 'btn btn-default' | ||
= link_to t('cancel'), user_profile_path, class: 'btn' |
Oops, something went wrong.