Skip to content

Commit

Permalink
Merge pull request #39 from mdidier9/HasPhoneController
Browse files Browse the repository at this point in the history
Has phone controller
  • Loading branch information
danarmstrong-io committed May 24, 2014
2 parents fa71007 + 93895f4 commit 1910c1d
Show file tree
Hide file tree
Showing 16 changed files with 112 additions and 3 deletions.
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.0.0-p451
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
source 'https://rubygems.org'

gem 'rack-cors', :require => 'rack/cors'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.0'

Expand Down
2 changes: 2 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ GEM
method_source (~> 0.8)
slop (~> 3.4)
rack (1.5.2)
rack-cors (0.2.9)
rack-test (0.6.2)
rack (>= 1.0)
rails (4.0.0)
Expand Down Expand Up @@ -201,6 +202,7 @@ DEPENDENCIES
omniauth-facebook (= 1.4.0)
pg
pry
rack-cors
rails (= 4.0.0)
rails_12factor
rspec-rails (~> 2.14.2)
Expand Down
3 changes: 3 additions & 0 deletions app/assets/javascripts/phones.js.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
3 changes: 3 additions & 0 deletions app/assets/stylesheets/phones.css.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the phones controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
2 changes: 1 addition & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class ApplicationController < ActionController::Base
before_filter :require_login
before_filter :require_login
protect_from_forgery with: :exception

private
Expand Down
58 changes: 58 additions & 0 deletions app/controllers/phones_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
class PhonesController < ApplicationController
skip_before_filter :require_login, :only => [:recieve_request_get_events, :recieve_request_create_event] #add the phone controller pages in here

respond_to :json

def recieve_request_get_events
p "THIS IS INSIDE GET EVENTS ACTION ********************"
# p params #not sure there is even going to be params
@all_pingas = Pinga.all
p @all_pingas
respond_with @all_pingas
end


def recieve_request_create_event
p "THIS IS INSIDE CREATE EVENT ACTION ********************"

#geocode it with geocode gem (look for a method that can allow me to convert the address to the to the lat long)

@create_event_data = params[:data]

p @create_event_data

respond_with @create_event_data



#TO DO
#---------------------------------------------------------------------------

#this is currently the format of the new_ping hash that we are getting from the phone
#----------------------------------------------------------------------------------------
# {"title"=>"", "description"=>"", "category"=>"Social", "start_time"=>"6:00 PM", "end_time"=>"8:00 PM", "address"=>""}



#this is currently the format of the new_ping properties that is defined in our migrations
#----------------------------------------------------------------------------------------

#CHECK t.string :title
#CHECK t.string :description
#NO (determine in web app --- method) t.string :status
#CHECK t.datetime :start_time
#CHECK t.datetime :end_time
#CHECK t.string :address
#NO (get from the the address) t.float :latitude
#NO (get from the phone using bubblewraps's location obj) t.float :longitude
#NO (need to somehow get the user information from the phone) t.integer :creator_id #user_id
#CHECK t.timestamps (this will be created when it is entered in the database)



#QUESTIONS
#---------------------------------------------------------------------------------
#How do we want to sanitize data? (trailing space?, newline? )
end

end
2 changes: 1 addition & 1 deletion app/controllers/sessions_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class SessionsController < ActionController::Base
skip_before_filter :require_login, :only => [:new, :create]
skip_before_filter :require_login, :only => [:new, :create] #add the phone controller pages in here

def new
end
Expand Down
2 changes: 2 additions & 0 deletions app/helpers/phones_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module PhonesHelper
end
1 change: 1 addition & 0 deletions app/views/phones/recieve_request_create_event.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<h1>This is to confirm that the recieve_request_create_event action has been called within the phone controller</h1>
1 change: 1 addition & 0 deletions app/views/phones/recieve_request_get_events.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<h1>This is to confirm that the recieve_request_get_events action has been called within the phone controller</h1>
7 changes: 6 additions & 1 deletion app/views/pingas/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@

<div class="container" style='width: 1100px; height: 520px;'>

<div class="map">
<%= render partial: "shared/map" %>
<% if flash[:notice] %>
<div class="flash-notice">
<p class="flash-text"><%= flash[:notice] %></p>
Expand Down Expand Up @@ -48,4 +53,4 @@
</div>
</div>
<%= link_to "Create Ping!", new_pinga_path, 'class' => 'button', 'data-no-turbolink' => true %>
</div>
</div>
6 changes: 6 additions & 0 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,11 @@ class Application < Rails::Application
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de
config.middleware.use Rack::Cors do
allow do
origins '*'
resource '*', :headers => :any, :methods => [:get, :post, :options]
end
end
end
end
5 changes: 5 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,9 @@
match 'auth/:provider/callback', to: 'sessions#create', via: [:get, :post]
match 'auth/failure', to: redirect('/'), via: [:get, :post]
match 'signout', to: 'sessions#destroy', as: 'signout', via: [:delete]


#connect to iphone
match 'phone/get_events', to: 'phones#recieve_request_get_events', via: [:get]
match 'phone/create_event', to: 'phones#recieve_request_create_event', via: [:get]
end
5 changes: 5 additions & 0 deletions spec/controllers/phones_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
require 'spec_helper'

describe PhonesController do

end
15 changes: 15 additions & 0 deletions spec/helpers/phones_helper_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
require 'spec_helper'

# Specs in this file have access to a helper object that includes
# the PhonesHelper. For example:
#
# describe PhonesHelper do
# describe "string concat" do
# it "concats two strings with spaces" do
# expect(helper.concat_strings("this","that")).to eq("this that")
# end
# end
# end
describe PhonesHelper do
pending "add some examples to (or delete) #{__FILE__}"
end

0 comments on commit 1910c1d

Please sign in to comment.