Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Close button #112

Open
wants to merge 2 commits into
base: close-button
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion app/controllers/apprenticeships_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,36 @@ def cancel
end
redirect_to :back, :flash => { warning: "Blarf. The following error(s) occured while attempting to cancel your apprenticeship: #{error_msg}".html_safe} and return
end

#---- close
def close
if @apprenticeship.fill && @apprenticeship.deliver_close
redirect_to apprenticeships_path, :flash => { :warning => "Your apprenticeship was closed."} and return
else
raise
end
rescue
error_msg = " "
@apprenticeship.errors.each do |field, msg|
error_msg << "<br/>"
error_msg << msg
end
redirect_to :back, :flash => { warning: "Blarf. The following error(s) occured while attempting to close your apprenticeship: #{error_msg}".html_safe} and return
end
#---- reopen
def reopen
if @apprenticeship.reopen && @apprenticeship.deliver_reopen
redirect_to :back, :flash => {:success => "Great! Your apprenticeship is open for applications again."} and return
else
raise
end
rescue
error_msg = " "
@apprenticeship.errors.each do |field, msg|
error_msg << "<br/>"
error_msg << msg
end
redirect_to :back, :flash => { warning: "Blarf. The following error(s) occured while attempting to reopen your apprenticeship: #{error_msg}".html_safe} and return
end
#---- accept
def accept
if @apprenticeship.accept && @apprenticeship.deliver_accept
Expand Down
28 changes: 28 additions & 0 deletions app/models/apprenticeship.rb
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,34 @@ def deliver_cancel_applicants
return true
end

def deliver_close
Pony.mail({
:to => "#{user.name}<#{user.email}>",
:from => "Diana & Cheyenne<[email protected]>",
:reply_to => "GirlsGuild<[email protected]>",
:subject => "Your apprenticeship has been closed - #{topic} with #{user.name}",
:html_body => %(<h1>Bam!</h1>
<p>You've closed your apprenticeship. This means that it will appear to be full and you won't receive more applications.</p>
<p>~<br/>Thanks,</br>The GirlsGuild Team</p>),
:bcc => "[email protected]",
})
return true
end

def deliver_reopen
Pony.mail({
:to => "#{user.name}<#{user.email}>",
:from => "Diana & Cheyenne<[email protected]>",
:reply_to => "GirlsGuild<[email protected]>",
:subject => "Your apprenticeship has been reopened - #{topic} with #{user.name}",
:html_body => %(<h1>Wowsers!</h1>
<p>You've reopened your apprenticeship for applications. We'll keep you posted as new applications come in.</p>
<p>~<br/>Thanks,</br>The GirlsGuild Team</p>),
:bcc => "[email protected]",
})
return true
end

def deliver_reject
Pony.mail({
:to => "#{user.name}<#{user.email}>",
Expand Down
4 changes: 3 additions & 1 deletion app/models/signup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ def make_stamp
end

def check_capacity
self.event.fill! if self.event.max_capacity_met?
if self.event.max_capacity_met? && !self.event.filled?
self.event.fill!
end
end

def state_label_class
Expand Down
2 changes: 1 addition & 1 deletion app/views/app_signups/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@

/ = link_to "Decline Apprentice", {:action => "decline", id: @app_signup, :controller => "app_signups"}, :method => :post, class: "btn btn-danger pull-left", :data => { :confirm => 'Are you sure you want to decline this applicant? Declining cannot be undone.'}

- if @app_signup.event.filled?
- if @app_signup.event.max_capacity_met?
= link_to "Accept Apprentice", app_signup_path(@app_signup), rel: 'popover', data: {placement: "top", content: "Sorry, you can't accept this applicant because you've already filled your apprenticeship. Let us know if this is an error or if you'd like to accept another apprentice."},class: "btn btn-success pull-right disabled"
- else
/%a.btn.btn-warning.center{:href => scheduleinterview_path} Schedule an Interview
Expand Down
10 changes: 8 additions & 2 deletions app/views/apprenticeships/_xedit.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -480,12 +480,18 @@
%br
%br
%br

- if current_user && current_user == @apprenticeship.user && [email protected]? && [email protected]? && [email protected]?
= link_to "Cancel Apprenticeship", { :controller => 'apprenticeships', :action => 'cancel', :id => @apprenticeship.id }, class: "btn btn-danger", :method => 'post', data: { :confirm => "Are you sure? Your apprenticeship will be saved in your Dashboard, but you'll have to resubmit it in order to post it again." }
%br
%br

- if current_user && current_user == @apprenticeship.user && @apprenticeship.accepted?
= link_to "Close Apprenticeship", { :controller => 'apprenticeships', :action => 'close', :id => @apprenticeship.id }, class: "btn btn-warning", :method => 'post', data: { :confirm => "Are you sure you want to stop accepting applications?" }
%br
%br
- if current_user && current_user == @apprenticeship.user && @apprenticeship.filled? && [email protected]_capacity_met?
= link_to "Re-Open Apprenticeship", { :controller => 'apprenticeships', :action => 'reopen', :id => @apprenticeship.id }, class: "btn btn-success", :method => 'post', data: { :confirm => "Are you sure you want to re-open your apprenticeship for applications?" }
%br
%br
- if current_user && current_user == @apprenticeship.user && @apprenticeship.started?
= link_to "Delete Apprenticeship", { :controller => 'apprenticeships', :action => 'destroy', :id => @apprenticeship.id }, class: "btn btn-small btn-danger pull-left", :method => 'delete', data: { :confirm => "Are you sure? You can't undo after you delete your apprenticeship. It will really be gone!" }
%br
Expand Down
4 changes: 4 additions & 0 deletions app/views/shared/_payment_info_saved.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
= f.hidden_field :stripe_card_token, :id => "stripe_card_token"
.alert.alert-success
%strong Thanks!
%span.message We've got your payment info on file. Go ahead and submit your listing!
2 changes: 2 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
collection do
post :cancel
post :accept
post :close
post :reopen
post :resubmit
get :duplicate
get :checkmarks
Expand Down
5 changes: 5 additions & 0 deletions db/migrate/20140426185540_add_stripe_customer_id_to_user.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddStripeCustomerIdToUser < ActiveRecord::Migration
def change
add_column :users, :StripeCustomerId, :integer
end
end
5 changes: 5 additions & 0 deletions db/migrate/20140426190139_change_column_name.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class ChangeColumnName < ActiveRecord::Migration
def change
rename_column :users, :StripeCustomerId, :stripe_customer_id
end
end
5 changes: 5 additions & 0 deletions db/migrate/20140426200053_add_maker_charge_id_to_signup.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddMakerChargeIdToSignup < ActiveRecord::Migration
def change
add_column :signups, :maker_charge_id, :integer
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class ChangeStripeCustomerIdInUsers < ActiveRecord::Migration
def up
change_column :users, :stripe_customer_id, :string
end

def down
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class ChangeMakerChargeIdOnSignups < ActiveRecord::Migration
def up
change_column :signups, :maker_charge_id, :string
end

def down
end
end
18 changes: 0 additions & 18 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,24 +108,6 @@
t.integer "user_id"
end

create_table "interviews", :force => true do |t|
t.integer "app_signup_id"
t.integer "user_id"
t.string "interview_time"
t.string "interview_location"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.text "interview_message"
end

create_table "messages", :force => true do |t|
t.string "message_text"
t.integer "user_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.integer "interview_id"
end

create_table "photos", :force => true do |t|
t.string "caption"
t.boolean "protected", :default => false
Expand Down