Skip to content

Commit

Permalink
Merge branch 'integration' into higly-experimental/enforce-robots-txt
Browse files Browse the repository at this point in the history
  • Loading branch information
munen committed Jul 29, 2014
2 parents 70ebb03 + 813fcea commit 2866b84
Show file tree
Hide file tree
Showing 46 changed files with 415 additions and 126 deletions.
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ source 'https://rubygems.org'
gem 'rails', '4.0.2'

#gem 'turbolinks'
gem 'protected_attributes' # support legacy 'attr_accessible'

gem 'rails-i18n'
gem 'pg'
Expand Down
3 changes: 0 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,6 @@ GEM
polyglot (0.3.3)
private_pub (1.0.3)
faye
protected_attributes (1.0.5)
activemodel (>= 4.0.1, < 5.0)
pry (0.9.12.4)
coderay (~> 1.0)
method_source (~> 0.8)
Expand Down Expand Up @@ -470,7 +468,6 @@ DEPENDENCIES
pg_search!
poltergeist
private_pub
protected_attributes
pry-rails
rack-cache
rails (= 4.0.2)
Expand Down
6 changes: 5 additions & 1 deletion app/controllers/api/messages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def create
good = good || @talk.venue.users.include?(user)
return render text: 'Computer says no', status: 740 unless good

message = @talk.messages.build(params[:message])
message = @talk.messages.build(message_params)
message.user = user
message.save!

Expand Down Expand Up @@ -43,4 +43,8 @@ def verified_request?
super || form_authenticity_token == request.headers['X-XSRF-TOKEN']
end

def message_params
params.require(:message).permit(:content)
end

end
10 changes: 6 additions & 4 deletions app/controllers/api/social_shares_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class Api::SocialSharesController < ApplicationController
before_filter :authenticate_user!

def create
@social_share = SocialShare.new(params[:social_share])
@social_share = SocialShare.new(social_share_params)
@social_share.request_ip = request.remote_addr
@social_share.user_agent = request.user_agent
@social_share.user_id = current_user.id
Expand All @@ -18,9 +18,11 @@ def create
end

private

def social_share_params
params.require(:social_share).permit(:request_ip, :user_agent,
:shareable_id, :shareable_type,
:social_network)
params.require(:social_share).permit( :shareable_id,
:shareable_type,
:social_network )
end

end
4 changes: 2 additions & 2 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ def store_location

before_filter :update_sanitized_params, if: :devise_controller?

# strong parameters for devise
def update_sanitized_params
devise_parameter_sanitizer.for(:sign_up) do |u|
u.permit(:firstname, :lastname, :accept_terms_of_use,
:email, :password, :password_confirmation)
u.permit(UsersController::PERMITTED_ATTRS)
end
end

Expand Down
6 changes: 5 additions & 1 deletion app/controllers/comments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def create
authorize! :create, Comment

venue = Venue.find(params[:venue_id])
comment = venue.comments.build(params[:comment])
comment = venue.comments.build(comment_params)
comment.user = current_user

if comment.save
Expand All @@ -29,4 +29,8 @@ def send_email(comment, users)
end
end

def comment_params
params.require(:comment).permit(:content)
end

end
2 changes: 2 additions & 0 deletions app/controllers/embed_talks_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
class EmbedTalksController < ApplicationController

after_action :allow_iframe, only: :show

def show
Expand All @@ -14,4 +15,5 @@ def show
def allow_iframe
response.headers.except! 'X-Frame-Options'
end

end
2 changes: 2 additions & 0 deletions app/controllers/errors_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
class ErrorsController < ApplicationController

skip_before_filter :check_browser

# Handling exceptions dynamically using middleware.
Expand All @@ -16,4 +17,5 @@ def show
# Dedicated landing page for outdated browsers
def upgrade_browser
end

end
36 changes: 36 additions & 0 deletions app/controllers/reminders_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# TODO use cancan for authorization
class RemindersController < ApplicationController

before_action :authenticate_user!

# GET /reminders
def index
@reminders = current_user.reminders
end

# POST /reminders
def create
@reminder = Reminder.new
@reminder.user = current_user

rememberable ||= Talk.find(params[:talk_id])
rememberable ||= Venue.find(params[:venue_id])
raise "Cannot find Rememberable with #{params.inspect}" if rememberable.nil?
@reminder.rememberable = rememberable

if @reminder.save
redirect_to rememberable, notice: I18n.t('reminders.create.success')
else
redirect_to rememberable, error: I18n.t('reminders.create.failure')
end
end

# DELETE /reminders/1
def destroy
@reminder = Reminder.find(params[:id])
@reminder.destroy
redirect_to current_user, anchor: 'reminders',
notice: I18n.t('reminders.destroy.success')
end

end
11 changes: 8 additions & 3 deletions app/controllers/search_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ class SearchController < ApplicationController

PER_PAGE = 10

before_action :set_query

# POST /search
def create
redirect_to "/search/1/" + u(params[:query])
redirect_to "/search/1/" + u(@query)
end

# GET /search/1/:query
def show
@query = params[:query]

@results = PgSearch.multisearch(@query).
paginate(page: params[:page], per_page: PER_PAGE)

Expand All @@ -33,4 +33,9 @@ def u(str)
ERB::Util.url_encode(str)
end

def set_query
params.permit(:query)
@query = params[:query]
end

end
3 changes: 2 additions & 1 deletion app/controllers/talks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ def talk_params
params.require(:talk).permit(:title, :teaser, :starts_at_date,
:starts_at_time, :duration,
:description, :collect, :image,
:tag_list, :guest_list, :language)
:tag_list, :guest_list, :language,
:format)
end

end
8 changes: 4 additions & 4 deletions app/controllers/users/omniauth_callbacks_controller.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
require 'pp'

class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController

include Devise::Controllers::Rememberable

def facebook
logger.debug("OmniauthCallbacks#facebook - omniauth.auth: \n #{request.env['omniauth.auth']}\n")
logger.debug("OmniauthCallbacks#facebook - omniauth.auth: \n" +
" #{request.env['omniauth.auth']}\n")
@user = User.find_for_facebook_oauth(request.env["omniauth.auth"], current_user)

unless @user.valid?
logger.warn("OmniAuthCallbacks#facebook - user invalid: @user.inspect")
flash[:error] = @user.errors.full_message(:email, "is in use")
redirect_to new_user_registration_url and return
end

if @user.persisted?
flash[:notice] = I18n.t "devise.omniauth_callbacks.success", :kind => "Facebook"
remember_me(@user)
Expand Down
11 changes: 10 additions & 1 deletion app/controllers/users/registrations_controller.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
class Users::RegistrationsController < Devise::RegistrationsController

def new
resource = build_resource(params[:user])
resource = build_resource(user_params)
respond_with resource
end

def create
@guest_user = session[:guest_user_id] = nil
super
end

private

def user_params
return {} unless params[:user] # for redirect on subscribe
params.require(:user).permit(:firstname, :lastname, :email)
end

end
19 changes: 17 additions & 2 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
class UsersController < ApplicationController

PERMITTED_ATTRS = [ :firstname,
:lastname,
:accept_terms_of_use,
:email,
:avatar,
:header,
:password,
:password_confirmation ]

before_filter :authenticate_user!, :only => [:edit,:update,:destroy]

# layout "application", :only => [:welcome]
Expand Down Expand Up @@ -47,7 +56,7 @@ def edit
# POST /users
# POST /users.json
def create
@user = User.new(params[:user])
@user = User.new(user_params)

respond_to do |format|
if @user.save
Expand All @@ -69,7 +78,7 @@ def update
authorize! :update, @user

respond_to do |format|
if @user.update_attributes(params[:user])
if @user.update_attributes(user_params)
format.html do
redirect_to @user, flash: { notice: I18n.t("flash.actions.update.notice") }
end
Expand Down Expand Up @@ -100,4 +109,10 @@ def destroy
end
end

private

def user_params
params.require(:user).permit(PERMITTED_ATTRS)
end

end
19 changes: 11 additions & 8 deletions app/controllers/venues_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ def show
format.html do
@upcoming_talks = @venue.talks.where(state: [:prelive, :live]).ordered
@archived_talks = @venue.talks.archived.ordered

@participation =
@venue.participations.find_by(user_id: current_user.id)

@show_join = @participation.nil? &&
current_user != @venue.user
end
Expand All @@ -51,9 +51,6 @@ def new

# GET /venues/1/edit
def edit
if params[:renew]
@renew = true
end
authorize! :edit, @venue
respond_to do |format|
format.html {}
Expand All @@ -64,7 +61,7 @@ def edit
# POST /venues
# POST /venues.json
def create
@venue = Venue.new(params[:venue])
@venue = Venue.new(venue_params)
@venue.user = current_user

authorize! :create, @venue
Expand All @@ -90,7 +87,7 @@ def update
authorize! :update, @venue

respond_to do |format|
if @venue.update_attributes(params[:venue])
if @venue.update_attributes(venue_params)
format.html { redirect_to @venue, notice: 'Venue was successfully updated.' }
format.json { head :no_content }
else
Expand All @@ -113,7 +110,7 @@ def destroy
end
end

def tags # TODO: check if needed
def tags
scope = ActsAsTaggableOn::Tag.where(["name ILIKE ?", "%#{params[:q]}%"])
tags = scope.paginate(:page => params[:page], :per_page => params[:limit] || 10)
render json: { tags: tags, total: scope.count }
Expand All @@ -131,4 +128,10 @@ def set_venue
@venue = Venue.find(params[:id])
end

# Only allow a trusted parameter "white list" through.
def venue_params
params.require(:venue).permit(:title, :teaser, :description,
:image, :tag_list)
end

end
2 changes: 0 additions & 2 deletions app/models/appearance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
# * user_id [integer] - belongs to :user
class Appearance < ActiveRecord::Base

attr_accessible :user_id

validates :user, :talk, presence: true

belongs_to :user
Expand Down
2 changes: 0 additions & 2 deletions app/models/comment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
# * user_id [integer, not null] - belongs to :user
class Comment < ActiveRecord::Base

attr_accessible :content

belongs_to :commentable, polymorphic: true
belongs_to :user

Expand Down
2 changes: 0 additions & 2 deletions app/models/message.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
# * user_id [integer] - belongs to :user
class Message < ActiveRecord::Base

attr_accessible :content

belongs_to :user
belongs_to :talk

Expand Down
6 changes: 6 additions & 0 deletions app/models/reminder.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class Reminder < ActiveRecord::Base
belongs_to :user
belongs_to :rememberable, polymorphic: true

validates :user, presence: true
end
2 changes: 0 additions & 2 deletions app/models/setting.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ class Setting < ActiveRecord::Base

validates :key, :value, presence: true

attr_accessible :key, :value

class << self
def get(key)
# try to find an entry in the db
Expand Down
Loading

0 comments on commit 2866b84

Please sign in to comment.