Skip to content

Commit

Permalink
complete notice manage
Browse files Browse the repository at this point in the history
  • Loading branch information
karidyang committed Oct 20, 2013
1 parent 3b2c544 commit dd3fe14
Show file tree
Hide file tree
Showing 138 changed files with 815 additions and 525 deletions.
5 changes: 3 additions & 2 deletions Gemfile
Expand Up @@ -13,6 +13,7 @@ gem 'yajl-ruby', :require => 'yajl'
#gem 'nokogiri'
gem 'authlogic'
gem 'json'
gem 'magic_encoding'

# Paginator
gem 'kaminari'
Expand Down Expand Up @@ -81,8 +82,8 @@ gem 'capistrano'

# Debugger (ruby-debug for Ruby 1.8.7+, ruby-debug19 for Ruby 1.9.2+)
# gem 'ruby-debug'
gem 'ruby-debug19'

#gem 'ruby-debug19'
gem 'debugger'
# Background Processing
# gem 'delayed_job'
# gem 'resque'
Expand Down
66 changes: 31 additions & 35 deletions Gemfile.lock
Expand Up @@ -28,50 +28,55 @@ GEM
activesupport (3.2.12)
i18n (~> 0.6)
multi_json (~> 1.0)
archive-tar-minitar (0.5.2)
arel (3.0.2)
authlogic (3.2.0)
activerecord (>= 3.0.0)
activesupport (>= 3.0.0)
authlogic (3.3.0)
activerecord (>= 3.2)
activesupport (>= 3.2)
bootstrap-will_paginate (0.0.6)
will_paginate
builder (3.0.4)
capistrano (2.15.4)
capistrano (2.15.5)
highline
net-scp (>= 1.0.0)
net-sftp (>= 2.0.0)
net-ssh (>= 2.0.14)
net-ssh-gateway (>= 1.1.0)
carrierwave (0.8.0)
carrierwave (0.9.0)
activemodel (>= 3.2.0)
activesupport (>= 3.2.0)
json (>= 1.7)
columnize (0.3.6)
debugger (1.6.1)
columnize (>= 0.3.1)
debugger-linecache (~> 1.2.0)
debugger-ruby_core_source (~> 1.2.3)
debugger-linecache (1.2.0)
debugger-ruby_core_source (1.2.3)
erubis (2.7.0)
highline (1.6.19)
hike (1.2.1)
i18n (0.6.4)
hike (1.2.3)
i18n (0.6.5)
journey (1.0.4)
jquery-rails (2.1.4)
railties (>= 3.0, < 5.0)
thor (>= 0.14, < 2.0)
json (1.7.7)
json (1.8.0)
kaminari (0.14.1)
actionpack (>= 3.0.0)
activesupport (>= 3.0.0)
linecache19 (0.5.12)
ruby_core_source (>= 0.1.4)
magic_encoding (0.0.2)
mail (2.4.4)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.21)
multi_json (1.7.1)
mysql2 (0.3.11)
net-scp (1.1.0)
mime-types (1.25)
multi_json (1.8.0)
mysql2 (0.3.13)
net-scp (1.1.2)
net-ssh (>= 2.6.5)
net-sftp (2.1.2)
net-ssh (>= 2.6.5)
net-ssh (2.6.6)
net-ssh (2.7.0)
net-ssh-gateway (1.2.0)
net-ssh (>= 2.6.5)
polyglot (0.3.3)
Expand All @@ -97,36 +102,26 @@ GEM
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (>= 0.14.6, < 2.0)
rake (10.0.3)
rake (10.1.0)
rdoc (3.12.2)
json (~> 1.4)
ruby-debug-base19 (0.11.25)
columnize (>= 0.3.1)
linecache19 (>= 0.5.11)
ruby_core_source (>= 0.1.4)
ruby-debug19 (0.11.6)
columnize (>= 0.3.1)
linecache19 (>= 0.5.11)
ruby-debug-base19 (>= 0.11.19)
ruby-ole (1.2.11.6)
ruby_core_source (0.1.5)
archive-tar-minitar (>= 0.5.2)
sass (3.2.7)
ruby-ole (1.2.11.7)
sass (3.2.10)
sass-rails (3.2.6)
railties (~> 3.2.0)
sass (>= 3.1.10)
tilt (~> 1.3)
spreadsheet (0.8.5)
spreadsheet (0.9.0)
ruby-ole (>= 1.0)
sprockets (2.2.2)
hike (~> 1.2)
multi_json (~> 1.0)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sqlite3 (1.3.7)
thor (0.17.0)
tilt (1.3.6)
treetop (1.4.12)
sqlite3 (1.3.8)
thor (0.18.1)
tilt (1.4.1)
treetop (1.4.15)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.37)
Expand All @@ -142,14 +137,15 @@ DEPENDENCIES
bootstrap-will_paginate (= 0.0.6)
capistrano
carrierwave
debugger
jquery-rails (= 2.1.4)
json
kaminari
magic_encoding
mime-types
mysql2
rails (= 3.2.12)
rake
ruby-debug19
sass
sass-rails
spreadsheet
Expand Down
56 changes: 15 additions & 41 deletions app/controllers/accounts_controller.rb
@@ -1,4 +1,4 @@
# coding: utf-8
# -*- encoding : utf-8 -*-
class AccountsController < ApplicationController
before_filter :require_user
#around_filter do |controller, action|
Expand All @@ -13,9 +13,8 @@ class AccountsController < ApplicationController
# GET /accounts
# GET /accounts.xml
def index
if !@current_user.has_privilege?('accounts', 'index')
flash[:now] = '你没有浏览预存款的权限,请联系管理员'
render_403
unless @current_user.has_privilege?('accounts', 'index')
miss_privilege
return
end
@house_id = params[:house_id]
Expand All @@ -25,10 +24,8 @@ def index
# DELETE /accounts/1
# DELETE /accounts/1.xml
def destroy
if !@current_user.has_privilege?('accounts', 'destroy')

flash[:now] = '你没有删除预存款的权限,请联系管理员'
render_403
unless @current_user.has_privilege?('accounts', 'destroy')
miss_privilege
return
end

Expand All @@ -40,48 +37,27 @@ def destroy
end

def history
if !@current_user.has_privilege?('accounts', 'history')

flash[:now] = '你没有查看预存款历史的权限'
render_403
unless @current_user.has_privilege?('accounts', 'history')
miss_privilege
return
end
@account = Account.find(params[:id])
@details = @account.account_details.paginate(:page => params[:page])
end

def add_pre_money
if !@current_user.has_privilege?('accounts', 'add_pre_money')
flash[:now] = '你没有添加预存款的权限,请联系管理员'
render_403
unless @current_user.has_privilege?('accounts', 'add_pre_money')
miss_privilege
return
end
@house = House.find(params[:house_id])
if request.post?
#@detail = AccountDetail.new
#@detail.unit_price=params[:unitPrice]
#@detail.record = params[:record]
#@detail.can_push=params[:can_push]
#@detail.money = params[:money]
#
#@account = Account.find_by_item_id_and_house_id(params[:item_id], params[:house_id])
#@charge = Charge.find(params[:item_id])
#
#if @account.nil?
# @account = Account.create(:house_id=>params[:house_id],
# :house_code=>params[:house_code],
# :item_id=>params[:item_id],
# :item_name=>@charge.item_name,
# :plot_id=>params[:plot_id])
#
#end
#
#@account.transcation_in(@detail)

if Account.add_pre_money(params, @current_user.name)
redirect_to :controller => 'home', :action => :index, :id => params[:house_id]
else
@item = Charge.find_all_by_plot_id(session[:current_plot])
flash.now[:error] = '预存款错误'
@items = Charge.find_all_by_plot_id(session[:current_plot])
render 'add_pre_money'
end
else
Expand All @@ -91,9 +67,8 @@ def add_pre_money
end

def delete_detail
if !@current_user.has_privilege?('accounts', 'delete_detail')
flash[:now] = '你没有删除预存款明细的权限,请联系管理员'
render_403
unless @current_user.has_privilege?('accounts', 'delete_detail')
miss_privilege
return
end
@detail = AccountDetail.find(params['detail_id'])
Expand All @@ -107,9 +82,8 @@ def delete_detail
end

def transcation
if !@current_user.has_privilege?('accounts', 'transcation')
flash[:now] = '你没有转账的权限,请联系管理员'
render_403
unless @current_user.has_privilege?('accounts', 'transcation')
miss_privilege
return
end
if request.post?
Expand Down
11 changes: 8 additions & 3 deletions app/controllers/application_controller.rb
@@ -1,4 +1,4 @@
# coding: utf-8
# -*- encoding : utf-8 -*-
class ApplicationController < ActionController::Base
respond_to :html, :xml
protect_from_forgery
Expand All @@ -18,6 +18,11 @@ def render_403
render_optional_error_file(403)
end

def miss_privilege
flash.now[:error] = '缺少权限,请联系管理员'
render_403
end

def render_optional_error_file(status_code)
status = status_code.to_s
if %w['403' '404' '422' '500'].include?(status)
Expand Down Expand Up @@ -52,11 +57,11 @@ def current_plot
end

def has_privilege?(model, operator, msg)
if !@current_user.has_privilege?(model, operator)
unless @current_user.has_privilege?(model, operator)
flash[:notice] = msg
return false
end
return true
true
end

private
Expand Down
33 changes: 12 additions & 21 deletions app/controllers/areas_controller.rb
@@ -1,4 +1,4 @@
# coding: utf-8
# -*- encoding : utf-8 -*-
class AreasController < ApplicationController
before_filter :require_user
#around_filter do |controller, action|
Expand All @@ -12,9 +12,8 @@ class AreasController < ApplicationController
# GET /areas
# GET /areas.xml
def index
if !@current_user.has_privilege?('areas', 'index')
flash[:now] = '你没有浏览楼栋的权限,请联系管理员'
render_403
unless @current_user.has_privilege?('areas', 'index')
miss_privilege
return
end
if params.has_key?('plot_id')
Expand All @@ -34,9 +33,8 @@ def plot_areas
# GET /areas/1
# GET /areas/1.xml
def show
if !@current_user.has_privilege?('areas', 'show')
flash[:now] = '你没有查看楼栋的权限,请联系管理员'
render_403
unless @current_user.has_privilege?('areas', 'show')
miss_privilege
return
end

Expand All @@ -51,8 +49,7 @@ def new
@area = Area.new
respond_with (@area)
else
flash[:now] = '你没有添加楼栋的权限,请联系管理员'
render_403
miss_privilege
end
end

Expand All @@ -61,8 +58,7 @@ def edit
if @current_user.has_privilege?('areas', 'update')
@area = Area.find(params[:id])
else
flash[:now] = '你没有修改楼栋的权限,请联系管理员'
render_403
miss_privilege
end
end

Expand All @@ -72,15 +68,14 @@ def create
if @current_user.has_privilege?('areas', 'create')
@area = Area.new(params[:area])
if @area.save
redirect_to(area_path, :now => '新增楼栋成功')
redirect_to(area_path, :notice => '新增楼栋成功')

else
render :action => 'new'

end
else
flash[:now] = '你没有添加楼栋的权限,请联系管理员'
render_403
miss_privilege
end

end
Expand All @@ -91,16 +86,14 @@ def update
if @current_user.has_privilege?('areas', 'update')
@area = Area.find(params[:id])
if @area.update_attributes(params[:area])
redirect_to(area_path, :now => '保存楼栋信息成功.')
redirect_to(area_path, :notice => '保存楼栋信息成功.')

else
render :action => 'edit'

end
else
flash[:now] = '你没有修改楼栋的权限,请联系管理员'
render_403

miss_privilege
end

end
Expand All @@ -115,9 +108,7 @@ def destroy
end
redirect_to area_path
else

flash[:now] = '你没有删除楼栋的权限,请联系管理员'
render_403
miss_privilege
end
end
end

0 comments on commit dd3fe14

Please sign in to comment.