Skip to content
Browse files

white spaces

  • Loading branch information...
1 parent 1afe79f commit 679dd05e44dba94251d2ac435abfddd7957a1dff @mkristian committed Jun 19, 2013
View
8 app/controllers/application_controller.rb
@@ -1,5 +1,5 @@
class ApplicationController < ActionController::Base
-
+
respond_to :json
protected
@@ -15,7 +15,7 @@ def login_and_password
auth = params[:authentication] || params
[ auth[:login] || auth[:email], auth[:password] ]
end
-
+
end
# old stuff
# protect_from_forgery
@@ -56,7 +56,7 @@ def login_and_password
# end
# def current_user(user = nil)
-# # TODO just put user_id and user.groups names into session
+# # TODO just put user_id and user.groups names into session
# session['user'] = user if user
# session['user']
# end
@@ -67,7 +67,7 @@ def login_and_password
# def remote_permission
# perm = RemotePermission.find_by_token(x_service_token)
-# raise "ip #{request.remote_ip} wrong authentication" unless perm
+# raise "ip #{request.remote_ip} wrong authentication" unless perm
# # if the perm.id == nil then do not check IP - needed when using clusters
# raise "ip #{request.remote_ip} not allowed" if (!perm.ip.blank? && request.remote_ip != perm.ip)
# end
View
10 app/controllers/applications_controller.rb
@@ -2,7 +2,7 @@ class ApplicationsController < LocalController
guard_filter( {} ) do |groups|
groups.select do |group|
- group.application == Application.ALL ||
+ group.application == Application.ALL ||
( application && group.application == application )
end
end
@@ -16,7 +16,7 @@ def group_url( *args )
def authorize_application
#TODO super(params[:id])
if params[:id]
- @application =
+ @application =
if updated_at
Application.optimistic_find(updated_at, params[:id])
else
@@ -56,7 +56,7 @@ def create
# authorize_app(@application)
@application.save
-
+
respond_with serializer( @application )
end
@@ -86,9 +86,9 @@ def group_create
end
def group_update
- group = application.group_update( current_user,
+ group = application.group_update( current_user,
params[ :group ][ :updated_at ],
- params[ :id ],
+ params[ :id ],
params[ :group ] )
# for audit log
View
4 app/controllers/configuration_controller.rb
@@ -13,14 +13,14 @@ def show
# PUT /configuration
def update
- @configuration = ::Configuration.optimistic_find( updated_at,
+ @configuration = ::Configuration.optimistic_find( updated_at,
::Configuration.instance.id )
params[:configuration] ||= {}
params[:configuration][:modified_by] = current_user
@configuration.update_attributes( params[:configuration] )
-
+
respond_with serializer( @configuration )
end
end
View
4 app/controllers/domains_controller.rb
@@ -30,15 +30,15 @@ def update
@domain.attributes = params[ :domain ]
if @domain.changed?
- @domain.modified_by = current_user
+ @domain.modified_by = current_user
@domain.save
end
respond_with serializer( @domain )
end
# DELETE /domains/1
- def destroy
+ def destroy
@domain = Domain.optimistic_find( updated_at, params[:id] )
@domain.destroy
View
6 app/controllers/groups_controller.rb
@@ -33,7 +33,7 @@ def index
# @application )
# params[:group][:modified_by] = current_user
-
+
# authorize_application_param( params[:group] )
# @group.update_attributes( params[:group] )
@@ -43,8 +43,8 @@ def index
# # DELETE /groups/1
# def destroy
- # @group = Group.filtered_optimistic_find( updated_at,
- # params[:id],
+ # @group = Group.filtered_optimistic_find( updated_at,
+ # params[:id],
# @application )
# @group.destroy
View
6 app/controllers/local_controller.rb
@@ -54,12 +54,12 @@ def csrf
protected
- def current_user(user = nil)
+ def current_user(user = nil)
if user
session['user'] = serializer(user).use(:session).to_hash['user']
@_current_user = user
else
- @_current_user ||=
+ @_current_user ||=
begin
data = session['user']
if data
@@ -73,7 +73,7 @@ def current_user(user = nil)
end
end
end
-
+
def current_groups
if current_user
app_ids = [Application.THIS.id, Application.ALL.id]
View
2 app/controllers/profile_controller.rb
@@ -1,5 +1,5 @@
class ProfileController < LocalController
-
+
#TODO cache_headers :private
# GET /profile
View
4 app/controllers/regions_controller.rb
@@ -30,15 +30,15 @@ def update
@region.attributes = params[ :region ]
if @region.changed?
- @region.modified_by = current_user
+ @region.modified_by = current_user
@region.save
end
respond_with serializer( @region )
end
# DELETE /regions/1
- def destroy
+ def destroy
@region = Region.optimistic_find( updated_at, params[:id] )
@region.destroy
View
2 app/controllers/remote/authentications_controller.rb
@@ -18,7 +18,7 @@ def reset_password
@authentication = "login/email: #{username}"
pwd = User.reset_password( username )
-
+
if pwd
render :inline => "password sent", :content_type => :text
else
View
2 app/controllers/remote/users_controller.rb
@@ -13,7 +13,7 @@ def last_changes_of_app
end
def setup
- @user = User.filtered_setup( params,
+ @user = User.filtered_setup( params,
remote_permission,
User.system_user )
respond_with serializer( @user ).use( :for_app )
View
4 app/controllers/sessions_controller.rb
@@ -24,7 +24,7 @@ def create
@session = Session.new( 'user' => user,
'idle_session_timeout' => Users::Application.config.idle_session_timeout,
'permissions' => guard.permissions( user.groups) )
-
+
respond_with serializer( @session )
else
@session = user.to_s
@@ -40,7 +40,7 @@ def destroy
# for the log
@session = current_user
- # reset session happens in the after filter which allows for
+ # reset session happens in the after filter which allows for
# audit log with username which happens in another after filter
head :ok
end
View
6 app/controllers/users_controller.rb
@@ -35,7 +35,7 @@ def show
# GET /users/1/at.json
def at
@user = User.filtered_find(params[:id], current_user)
-
+
respond_with serializer( @user )
end
@@ -56,8 +56,8 @@ def create
# PUT /users/1.json
def update
params[:user] ||= params
- @user = User.filtered_optimistic_find(params[:user][:updated_at],
- params[:id],
+ @user = User.filtered_optimistic_find(params[:user][:updated_at],
+ params[:id],
current_user)
params[:user][:modified_by] = current_user
View
2 app/guards/applications_guard.yml
@@ -1,5 +1,5 @@
applications:
- defaults: []
+ defaults: []
index:
- user-admin
- app-admin
View
2 app/guards/ats_guard.yml
@@ -1,5 +1,5 @@
ats:
- defaults: [at]
+ defaults: [at]
# index: []
# show: []
# new: []
View
2 app/guards/audits_guard.yml
@@ -1,5 +1,5 @@
audits:
- defaults: []
+ defaults: []
# index: []
# show: []
# new: []
View
2 app/guards/configuration_guard.yml
@@ -1,5 +1,5 @@
configuration:
- defaults: []
+ defaults: []
# index: []
# show: []
# new: []
View
2 app/guards/domains_guard.yml
@@ -1,5 +1,5 @@
domains:
- defaults: []
+ defaults: []
index: ['*']
# index: []
# show: []
View
2 app/guards/errors_guard.yml
@@ -1,5 +1,5 @@
errors:
- defaults: []
+ defaults: []
# index: []
# show: []
# new: []
View
2 app/guards/groups_guard.yml
@@ -1,5 +1,5 @@
groups:
- defaults: [app-admin]
+ defaults: [app-admin]
index: [user-admin, app-admin]
# show: []
# new: []
View
2 app/guards/regions_guard.yml
@@ -1,5 +1,5 @@
regions:
- defaults: []
+ defaults: []
index: ['*']
# show: []
# new: []
View
2 app/models/application.rb
@@ -18,7 +18,7 @@ def self.ALL
end
def self.ATS
- @ats ||=
+ @ats ||=
begin
ats = Application.new
ats.id = -1
View
6 app/models/domain.rb
@@ -16,11 +16,11 @@ def self.all_changed_after( from )
def self.all_changed_after_of_app( from, app )
set = unless from.blank?
- DomainsGroupsUser.joins( :group, :domain ).where( 'application_id = ? and domains.updated_at > ?',
- app.id,
+ DomainsGroupsUser.joins( :group, :domain ).where( 'application_id = ? and domains.updated_at > ?',
+ app.id,
from )
else
- DomainsGroupsUser.uniq.joins( :group => :application ).where( 'application_id = ?',
+ DomainsGroupsUser.uniq.joins( :group => :application ).where( 'application_id = ?',
app.id )
end
set.collect { |d| d.domain }.uniq
View
2 app/models/session.rb
@@ -10,7 +10,7 @@ def errors
[]
end
- def id
+ def id
''
end
end
View
40 app/models/user.rb
@@ -26,7 +26,7 @@ def validate_everything_else
end
if !groups.member?(Group.AT) && !at_token.blank?
errors.add(:groups, 'with given AT token the user must be member of the AT group')
- end
+ end
end
def self.reset_password(login)
@@ -36,15 +36,15 @@ def self.reset_password(login)
u # can be used for logging
end
end
-
+
def self.assert( login, password )
if password.blank?
"no password given with login: #{login}"
elsif login.blank?
"no login given"
end
end
-
+
def self.get_user( login, password )
result = assert( login, password )
if result
@@ -72,7 +72,7 @@ def self.check_password( user, password )
user.save
end
user
- end
+ end
end
def self.authenticate(login, password, token = nil)
@@ -100,7 +100,7 @@ def self.filtered_all(current_user)
if current_user.groups.member?(Group.AT)
users.delete_if { |user| !user.groups.member?(Group.AT) }
elsif current_user.groups.member?(Group.APP_ADMIN)
- users.delete_if do |user|
+ users.delete_if do |user|
g = user.groups.detect { |g| apps.member?(g.application) }
g.nil?
end
@@ -114,15 +114,15 @@ def self.filtered_all(current_user)
end
end
end
-
+
users
end
def self.filtered_find(id, current_user)
filtered(find(id), current_user)
end
- def self._groups( params, application )
+ def self._groups( params, application )
params[ :groups ].select do |g|
group = ( Group.where( :id => g[ :id ] ) + Group.where( :name => g[ :name ] ) ).first
if group && group.application == application
@@ -148,9 +148,9 @@ def self._user( login, email, name, application )
def self.filtered_setup( params, application, current_user )
groups = self._groups( params, application )
- user = self._user( params[ :login ], params[ :email ],
+ user = self._user( params[ :login ], params[ :email ],
params[ :name ], application )
-
+
user.deep_update_attributes( { :groups => groups },
current_user ) if groups
user
@@ -160,7 +160,7 @@ def self.system_user
self.first # assuming first == root or system
end
- def self.filtered(user, current_user)
+ def self.filtered(user, current_user)
unless current_user.root?
# restrict user to AT unless current_user is user_admin
# TODO maybe that should be part of the guard, i.e. 'all_users' action
@@ -192,17 +192,17 @@ def self.filtered_optimistic_find(updated_at, id, current_user)
filtered(optimistic_find(updated_at, id), current_user)
end
- def self.filtered_new(params, current_user)
+ def self.filtered_new(params, current_user)
manager = Manager.new(current_user)
- group_ids = manager.group_ids(nil,
+ group_ids = manager.group_ids(nil,
:groups => params.delete(:groups),
:group_ids => params.delete(:group_ids))
params[:group_ids] = group_ids
user = self.new(params)
user.user_manager(manager) if manager
user
end
-
+
def deep_save
save && (user_manager ? user_manager.update(self) : true)
end
@@ -211,11 +211,11 @@ def deep_update_attributes(params, current_user)
user_manager = Manager.new(current_user)
groups = params.delete(:groups)
group_ids = params.delete(:group_ids)
- group_ids = user_manager.group_ids(self,
- :groups => groups,
+ group_ids = user_manager.group_ids(self,
+ :groups => groups,
:group_ids => group_ids)
params[:group_ids] = group_ids
- update_attributes(params)
+ update_attributes(params)
valid? && user_manager.update(self)
end
@@ -260,11 +260,11 @@ def reset_password_and_save
def self.all_changed_after_of_app( from, app )
unless from.blank?
- User.uniq.joins( :groups => :application ).where( 'application_id = ? and users.updated_at > ?',
- app.id,
+ User.uniq.joins( :groups => :application ).where( 'application_id = ? and users.updated_at > ?',
+ app.id,
from )
else
- User.uniq.joins( :groups => :application ).where( 'application_id = ?',
+ User.uniq.joins( :groups => :application ).where( 'application_id = ?',
app.id )
end
end
@@ -331,7 +331,7 @@ def allowed_applications
end
def applications
- @applications ||=
+ @applications ||=
begin
apps = groups.collect { |g| g.application }.uniq
apps << Application.ATS if at?
View
4 app/serializers/session_serializer.rb
@@ -5,12 +5,12 @@ class SessionSerializer < Ixtlan::Babel::Serializer
add_context(:single,
:only => [:permissions, :idle_session_timeout],
- :include=> {
+ :include=> {
:user => {
:only => [:id, :login, :name],
:include => [:applications]
},
- :permissions => {
+ :permissions => {
:include => [:actions]
}
}
View
28 app/serializers/user_serializer.rb
@@ -6,34 +6,34 @@ class UserSerializer < Ixtlan::Babel::Serializer
add_context(:session,
:only => [:id],
- :include=> {
+ :include=> {
:groups => {
:only => [:id],
:include => {
- :domains => {
+ :domains => {
:only => [:id, :name]
},
- :locales => {
+ :locales => {
:only => [:id, :code]
},
- :regions => {
+ :regions => {
:only => [:id, :name]
},
:application => {
:only => [:id, :name]
- }
+ }
}
}
})
add_context(:for_app,
:only => [:id, :login, :name, :email, :updated_at],
- :include=> {
+ :include=> {
:groups => {
:only => [:id, :name],
:methods => [ :domains ],
:include => {
- :domains => {
+ :domains => {
:only => [:id, :name]
}
}
@@ -43,11 +43,11 @@ class UserSerializer < Ixtlan::Babel::Serializer
add_context(:update,
:only => [:id, :login, :name, :updated_at])
- add_context(:at_update,
- :only => [:id, :name, :at_token, :updated_at],
+ add_context(:at_update,
+ :only => [:id, :name, :at_token, :updated_at],
:root => 'at')
- add_context(:collection,
+ add_context(:collection,
:except => [:hashed, :hashed2, :created_at, :modified_by_id],
:methods => [:group_ids, :application_ids])
@@ -56,8 +56,8 @@ class UserSerializer < Ixtlan::Babel::Serializer
:except => [:hashed, :hashed2, :modified_by_id])
add_context(:single,
- :except => [:hashed, :hashed2, :modified_by_id],
- :include => {
+ :except => [:hashed, :hashed2, :modified_by_id],
+ :include => {
:modified_by => {
:only => [:id, :login, :name],
},
@@ -71,7 +71,7 @@ class UserSerializer < Ixtlan::Babel::Serializer
:methods => [:applications, :domains, :locales, :regions]
}
})
-
+
add_context(:authenticate,
:except => [:hashed, :hashed2, :created_at, :updated_at, :modified_by_id, :at_token, :email],
:include => {
@@ -89,7 +89,7 @@ class UserSerializer < Ixtlan::Babel::Serializer
}
})
-
+
def setup_associations(options = {})
methods = ((((options || {})[:include] || {})[:groups] || {})[:methods] || [])
[:applications, :application_ids, :domains, :locales, :regions ].each do |m|
View
22 app/storages/user_storage.rb
@@ -6,18 +6,18 @@ def initialize(model, manager)
@manager = manager
super(model)
end
-
+
def save
super && @manager.update(self)
end
-
+
def update_attributes(params)
groups = params.delete(:groups)
group_ids = params.delete(:group_ids)
- group_ids = @manager.group_ids(self,
- :groups => groups,
+ group_ids = @manager.group_ids(self,
+ :groups => groups,
:group_ids => group_ids)
-
+
params[:group_ids] = group_ids
super(params) && @manager.update(self)
end
@@ -26,7 +26,7 @@ def update_attributes(params)
def initialize(current_user)
@current_user = current_user
end
-
+
def all
users = User.includes(:groups)#.joins(:groups).where("groups_users.group_id" => current_user.groups)
@@ -38,7 +38,7 @@ def all
if @current_user.at?
users.delete_if { |user| !user.at? }
elsif @current_user.groups.app_admin?
- users.delete_if do |user|
+ users.delete_if do |user|
g = user.groups.detect { |g| apps.member?(g.application) }
g.nil?
end
@@ -52,7 +52,7 @@ def all
end
end
end
-
+
users
end
@@ -65,9 +65,9 @@ def optimistic_find(updated_at, id)
filtered(User.optimistic_find(updated_at, id))
end
- def new_user(params)
+ def new_user(params)
manager = Manager.new(@current_user)
- group_ids = manager.group_ids(nil,
+ group_ids = manager.group_ids(nil,
:groups => params.delete(:groups),
:group_ids => params.delete(:group_ids))
params[:group_ids] = group_ids
@@ -76,7 +76,7 @@ def new_user(params)
private
- def filtered(user)
+ def filtered(user)
unless @current_user.root?
# if current_user is AT restrict user to be AT
# unless current_user is user_admin
View
2 config/environments/development.rb
@@ -53,7 +53,7 @@ class MailDump
def initialize(values)
@settings = {}
end
-
+
attr_accessor :settings
def deliver!(mail)
View
2 config/initializers/remote_servers.rb
@@ -4,5 +4,5 @@
config = Ixtlan::Passwords.get( :rest ).get( :translations )
server.url = config.get( :url, "http://localhost:3000" )
server.options[ :headers ] = {'X-Service-Token' => config.get( :token, 'behappy' )}
- server.add_model( Locale, :locales )
+ server.add_model( Locale, :locales )
end
View
4 lib/ixtlan/users/association.rb
@@ -51,14 +51,14 @@ def update(user, groups = [])
end
current_ids = ids_method(user.id, group.id) & allowed_ids
-
+
target_ids = (group_map[group.id] || []) & allowed_ids
# delete associations
(current_ids - target_ids).each do |id|
return false unless @model.delete_all(["user_id=? and group_id=? and #{@id_sym}=?", user.id, group.id, id])
end
-
+
# add associations
(target_ids - current_ids).each do |id|
return false unless @model.create(:user_id => user.id, :group_id => group.id, @id_sym => id)
View
12 lib/ixtlan/users/manager.rb
@@ -28,7 +28,7 @@ def group_ids(user, params = nil)
group_ids = @groups.collect { |g| (g[:group] || g)[:id].to_i }
group_ids = new_group_ids(user, :group_ids => group_ids)
# adjust the groups to the allowed groups
- @groups.delete_if do |g|
+ @groups.delete_if do |g|
!group_ids.member?((g[:group] || g)[:id].to_i)
end
else
@@ -40,7 +40,7 @@ def group_ids(user, params = nil)
{ :id => g.is_a?(Fixnum) ? g : g.id }
end
end
- # TODO since we have already @groups as state we could return
+ # TODO since we have already @groups as state we could return
# only the groupids
group_ids
end
@@ -58,11 +58,11 @@ def current_group_ids
g.id
end
end
-
+
def requested_group_ids(params)
(params[:group_ids] || []).collect { |id| id.to_i }
end
-
+
def all_group_ids
@all_group_ids ||= Group.where(:application_id => allowed_applications).collect { |g| g.id }
end
@@ -71,7 +71,7 @@ def allowed_applications
@apps ||= @current_user.allowed_applications
end
- def allowed_group_ids(params)
+ def allowed_group_ids(params)
if current_user.root?
# all are allowed
requested_group_ids(params)
@@ -83,7 +83,7 @@ def allowed_group_ids(params)
all_group_ids & requested_group_ids(params)
end
end
-
+
def new_group_ids(user, params)
if current_user.root?
requested_group_ids(params)
View
12 lib/params_filter.rb
@@ -1,22 +1,22 @@
require 'ixtlan/babel/hash_filter'
class ParamsFilter < Ixtlan::Babel::HashFilter
-
+
attr_reader :updated_at, :params
-
+
def initialize
super
- options = { :except => [ :id,
- :created_at,
- :updated_at,
+ options = { :except => [ :id,
+ :created_at,
+ :updated_at,
:modified_by_id,
:application_ids,
:region_ids,
:locale_ids,
:domain_ids
] }
end
-
+
def filter(params)
if params
@updated_at = params[:updated_at]

0 comments on commit 679dd05

Please sign in to comment.
Something went wrong with that request. Please try again.