Create reminders in the database
This commit is contained in:
parent
463c528ce7
commit
43ff9fa78c
|
@ -746,4 +746,44 @@ $(function() {
|
||||||
});
|
});
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
$('#reminder_form').live('submit', function() {
|
||||||
|
var submitButton = $("#reminder_form input[type='submit']");
|
||||||
|
$(submitButton).attr("disabled", true);
|
||||||
|
$.ajax({
|
||||||
|
type: 'POST',
|
||||||
|
url: '/reminders.json',
|
||||||
|
data: {
|
||||||
|
'commit': submitButton.val(),
|
||||||
|
'utf8': '✓',
|
||||||
|
'authenticity_token': $('#sign_out_form input[name="authenticity_token"]').val(),
|
||||||
|
'reminder': {
|
||||||
|
'from_user_id': $('#reminder_from_user_id').val(),
|
||||||
|
'to_user_id': $('#reminder_to_user_id').val(),
|
||||||
|
'hydrant_id': activeHydrantId
|
||||||
|
}
|
||||||
|
},
|
||||||
|
beforeSend: function() {
|
||||||
|
$('#info_window').hide();
|
||||||
|
$('#loader').show();
|
||||||
|
},
|
||||||
|
error: function(jqXHR) {
|
||||||
|
$('#loader').hide();
|
||||||
|
$('#info_window').show();
|
||||||
|
$(submitButton).attr("disabled", false);
|
||||||
|
},
|
||||||
|
success: function(data) {
|
||||||
|
$.ajax({
|
||||||
|
type: 'GET',
|
||||||
|
url: '/info_window',
|
||||||
|
data: {
|
||||||
|
'hydrant_id': activeHydrantId
|
||||||
|
},
|
||||||
|
success: function(data) {
|
||||||
|
activeInfoWindow.setContent(data);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return false;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
class RemindersController < ApplicationController
|
||||||
|
respond_to :json
|
||||||
|
|
||||||
|
def create
|
||||||
|
puts params[:reminder].inspect
|
||||||
|
@reminder = Reminder.new(params[:reminder])
|
||||||
|
|
||||||
|
if @reminder.save
|
||||||
|
render(:json => @reminder)
|
||||||
|
else
|
||||||
|
render(:json => {"errors" => @reminder.errors}, :status => 500)
|
||||||
|
end
|
||||||
|
# ReminderMailer.send_reminder
|
||||||
|
# @reminder.sent = true
|
||||||
|
# @reminder.save!
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,2 @@
|
||||||
|
module RemindersHelper
|
||||||
|
end
|
|
@ -0,0 +1,2 @@
|
||||||
|
class ReminderMailer < ActionMailer::Base
|
||||||
|
end
|
|
@ -0,0 +1,5 @@
|
||||||
|
= form_for :reminder, :url => reminders_path, :html => {:id => "reminder_form", :method => "post"} do |f|
|
||||||
|
= f.hidden_field "from_user_id", :value => current_user.id
|
||||||
|
= f.hidden_field "to_user_id", :value => @hydrant.user.id
|
||||||
|
= f.hidden_field "hydrant_id", :value => @hydrant.id
|
||||||
|
= f.submit "Send reminder to shovel"
|
|
@ -4,8 +4,9 @@
|
||||||
%h3
|
%h3
|
||||||
= "of #{@hydrant.user.organization}"
|
= "of #{@hydrant.user.organization}"
|
||||||
- if user_signed_in?
|
- if user_signed_in?
|
||||||
= render :partial => 'users/edit_profile'
|
= render :partial => 'users/reminder'
|
||||||
= render :partial => 'hydrants/steal'
|
= render :partial => 'hydrants/steal'
|
||||||
|
= render :partial => 'users/edit_profile'
|
||||||
= render :partial => 'sessions/sign_out'
|
= render :partial => 'sessions/sign_out'
|
||||||
- else
|
- else
|
||||||
= render :partial => 'sessions/sign_in'
|
= render :partial => 'sessions/sign_in'
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%h2
|
%h2
|
||||||
Thank you for adopting this hydrant!
|
Thank you for adopting this hydrant!
|
||||||
= render :partial => 'users/edit_profile'
|
|
||||||
= render :partial => 'hydrants/abandon'
|
= render :partial => 'hydrants/abandon'
|
||||||
|
= render :partial => 'users/edit_profile'
|
||||||
= render :partial => 'sessions/sign_out'
|
= render :partial => 'sessions/sign_out'
|
||||||
|
|
|
@ -8,5 +8,6 @@ AdoptAHydrant::Application.routes.draw do
|
||||||
get 'info_window' => 'info_window#index', :as => 'info_window'
|
get 'info_window' => 'info_window#index', :as => 'info_window'
|
||||||
get 'sitemap' => 'sitemaps#index', :as => 'sitemap'
|
get 'sitemap' => 'sitemaps#index', :as => 'sitemap'
|
||||||
resource :hydrants
|
resource :hydrants
|
||||||
|
resource :reminders
|
||||||
root :to => 'main#index'
|
root :to => 'main#index'
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,10 +5,12 @@ class CreateReminders < ActiveRecord::Migration
|
||||||
t.integer :from_user_id, :null => false
|
t.integer :from_user_id, :null => false
|
||||||
t.integer :to_user_id, :null => false
|
t.integer :to_user_id, :null => false
|
||||||
t.integer :hydrant_id, :null => false
|
t.integer :hydrant_id, :null => false
|
||||||
|
t.boolean :sent, :default => false
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index :reminders, :from_user_id
|
add_index :reminders, :from_user_id
|
||||||
add_index :reminders, :to_user_id
|
add_index :reminders, :to_user_id
|
||||||
add_index :reminders, :hydrant_id
|
add_index :reminders, :hydrant_id
|
||||||
|
add_index :reminders, :sent
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -27,13 +27,15 @@ ActiveRecord::Schema.define(:version => 3) do
|
||||||
create_table "reminders", :force => true do |t|
|
create_table "reminders", :force => true do |t|
|
||||||
t.datetime "created_at"
|
t.datetime "created_at"
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at"
|
||||||
t.integer "from_user_id", :null => false
|
t.integer "from_user_id", :null => false
|
||||||
t.integer "to_user_id", :null => false
|
t.integer "to_user_id", :null => false
|
||||||
t.integer "hydrant_id", :null => false
|
t.integer "hydrant_id", :null => false
|
||||||
|
t.boolean "sent", :default => false
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index "reminders", ["from_user_id"], :name => "index_reminders_on_from_user_id"
|
add_index "reminders", ["from_user_id"], :name => "index_reminders_on_from_user_id"
|
||||||
add_index "reminders", ["hydrant_id"], :name => "index_reminders_on_hydrant_id"
|
add_index "reminders", ["hydrant_id"], :name => "index_reminders_on_hydrant_id"
|
||||||
|
add_index "reminders", ["sent"], :name => "index_reminders_on_sent"
|
||||||
add_index "reminders", ["to_user_id"], :name => "index_reminders_on_to_user_id"
|
add_index "reminders", ["to_user_id"], :name => "index_reminders_on_to_user_id"
|
||||||
|
|
||||||
create_table "users", :force => true do |t|
|
create_table "users", :force => true do |t|
|
||||||
|
|
Loading…
Reference in New Issue