From 4667f340c11ec99c196b3330913ffe0b9e89921a Mon Sep 17 00:00:00 2001 From: Hong ChulJu Date: Sat, 21 Mar 2015 20:46:08 +0900 Subject: [PATCH] Only authorized group can response to notice. --- Gemfile.lock | 87 +++++++++++++++++++++++------------------- app/models/response.rb | 6 +++ 2 files changed, 53 insertions(+), 40 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 5ed9ecf..1a645c3 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -27,11 +27,11 @@ GEM minitest (~> 5.1) thread_safe (~> 0.1) tzinfo (~> 1.1) - addressable (2.3.6) + addressable (2.3.7) arel (5.0.1.20140414130214) autoprefixer-rails (3.1.0.20140911) execjs - bcrypt (3.1.9) + bcrypt (3.1.10) bootstrap-sass (3.2.0.2) sass (~> 3.2) builder (3.2.2) @@ -52,7 +52,7 @@ GEM coffee-script (2.3.0) coffee-script-source execjs - coffee-script-source (1.8.0) + coffee-script-source (1.9.1) database_cleaner (1.3.0) devise (3.4.1) bcrypt (~> 3.0) @@ -61,7 +61,7 @@ GEM responders thread_safe (~> 0.1) warden (~> 1.2.3) - devise-i18n (0.11.2) + devise-i18n (0.11.4) diff-lcs (1.2.5) draper (1.4.0) actionpack (>= 3.0) @@ -69,48 +69,51 @@ GEM activesupport (>= 3.0) request_store (~> 1.0) erubis (2.7.0) - execjs (2.2.2) + execjs (2.4.0) factory_girl (4.4.0) activesupport (>= 3.0.0) factory_girl_rails (4.4.1) factory_girl (~> 4.4.0) railties (>= 3.0.0) fakeweb (1.3.0) - faraday (0.9.0) + faraday (0.9.1) multipart-post (>= 1.2, < 3) - ffi (1.9.6) + ffi (1.9.8) formatador (0.2.5) - friendly_id (5.0.4) + friendly_id (5.0.5) activerecord (>= 4.0.0) gimchi (0.2.1) - guard (2.8.2) + guard (2.12.5) formatador (>= 0.2.4) listen (~> 2.7) lumberjack (~> 1.0) + nenv (~> 0.1) + notiffany (~> 0.0) pry (>= 0.9.12) + shellany (~> 0.0) thor (>= 0.18.1) guard-rspec (4.3.1) guard (~> 2.1) rspec (>= 2.14, < 4.0) - hashie (3.3.1) + hashie (3.4.0) hike (1.2.3) hitimes (1.2.2) - i18n (0.6.11) - jbuilder (2.2.5) + i18n (0.7.0) + jbuilder (2.2.12) activesupport (>= 3.0.0, < 5) multi_json (~> 1.2) jquery-rails (3.1.2) railties (>= 3.0, < 5.0) thor (>= 0.14, < 2.0) - jquery-ui-rails (5.0.2) + jquery-ui-rails (5.0.3) railties (>= 3.2.16) - json (1.8.1) - jwt (1.0.0) - kaminari (0.16.1) + json (1.8.2) + jwt (1.4.1) + kaminari (0.16.3) actionpack (>= 3.0.0) activesupport (>= 3.0.0) - kgio (2.9.2) - listen (2.8.0) + kgio (2.9.3) + listen (2.9.0) celluloid (>= 0.15.2) rb-fsevent (>= 0.9.3) rb-inotify (>= 0.9) @@ -123,14 +126,18 @@ GEM method_source (0.8.2) mime-types (1.25.1) mini_portile (0.6.0) - minitest (5.4.3) - multi_json (1.10.1) + minitest (5.5.1) + multi_json (1.11.0) multi_xml (0.5.5) multipart-post (2.0.0) - netrc (0.8.0) + nenv (0.2.0) + netrc (0.10.3) newrelic_rpm (3.9.4.245) nokogiri (1.6.3.1) mini_portile (= 0.6.0) + notiffany (0.0.6) + nenv (~> 0.1) + shellany (~> 0.0) oauth2 (1.0.0) faraday (>= 0.8, < 0.10) jwt (~> 1.0) @@ -149,7 +156,7 @@ GEM oauth2 (~> 1.0) omniauth (~> 1.2) orm_adapter (0.5.0) - pg (0.17.1) + pg (0.18.1) phone (1.2.3) polyglot (0.3.5) pry (0.10.1) @@ -164,7 +171,7 @@ GEM quiet_assets (1.0.3) railties (>= 3.1, < 5.0) rack (1.5.2) - rack-test (0.6.2) + rack-test (0.6.3) rack (>= 1.0) rails (4.1.5) actionmailer (= 4.1.5) @@ -176,7 +183,7 @@ GEM bundler (>= 1.3.0, < 2.0) railties (= 4.1.5) sprockets-rails (~> 2.0) - rails-i18n (4.0.3) + rails-i18n (4.0.4) i18n (~> 0.6) railties (~> 4.0) rails-observers (0.1.2) @@ -184,7 +191,7 @@ GEM rails_12factor (0.0.3) rails_serve_static_assets rails_stdout_logging - rails_serve_static_assets (0.0.2) + rails_serve_static_assets (0.0.4) rails_stdout_logging (0.0.3) railties (4.1.5) actionpack (= 4.1.5) @@ -192,17 +199,16 @@ GEM rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) raindrops (0.13.0) - rake (10.3.2) + rake (10.4.2) rb-fsevent (0.9.4) rb-inotify (0.9.5) ffi (>= 0.5.0) - rdoc (4.1.2) - json (~> 1.4) + rdoc (4.2.0) read_activity (0.0.4) request_store (1.1.0) responders (1.1.2) railties (>= 3.2, < 4.2) - rest-client (1.7.2) + rest-client (1.7.3) mime-types (>= 1.16, < 3.0) netrc (~> 0.7) roo (1.13.2) @@ -229,15 +235,15 @@ GEM rspec-mocks (~> 3.0.0) rspec-support (~> 3.0.0) rspec-support (3.0.4) - ruby-ole (1.2.11.7) - rubyzip (1.1.6) + ruby-ole (1.2.11.8) + rubyzip (1.1.7) rufus-scheduler (3.0.9) tzinfo sass (3.2.19) - sass-rails (4.0.4) + sass-rails (4.0.5) railties (>= 4.0.0, < 5.0) sass (~> 3.2.2) - sprockets (~> 2.8, < 2.12) + sprockets (~> 2.8, < 3.0) sprockets-rails (~> 2.0) sdoc (0.4.1) json (~> 1.7, >= 1.7.7) @@ -247,38 +253,39 @@ GEM multi_json (~> 1.0) rubyzip (~> 1.0) websocket (~> 1.0) + shellany (0.0.1) show_me_the_cookies (2.5.0) capybara (~> 2.0) slack-notify (0.3.3) faraday (~> 0.9.0) json (~> 1.8) slop (3.6.0) - spreadsheet (1.0.0) + spreadsheet (1.0.3) ruby-ole (>= 1.0) - spring (1.1.3) - sprockets (2.11.3) + spring (1.3.3) + sprockets (2.12.3) hike (~> 1.2) multi_json (~> 1.0) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) - sprockets-rails (2.2.0) + sprockets-rails (2.2.4) actionpack (>= 3.0) activesupport (>= 3.0) sprockets (>= 2.8, < 4.0) sqlite3 (1.3.10) thor (0.19.1) - thread_safe (0.3.4) + thread_safe (0.3.5) tilt (1.4.1) timers (4.0.1) hitimes treetop (1.4.15) polyglot polyglot (>= 0.3.1) - turbolinks (2.5.2) + turbolinks (2.5.3) coffee-rails tzinfo (1.2.2) thread_safe (~> 0.1) - uglifier (2.5.3) + uglifier (2.7.1) execjs (>= 0.3.0) json (>= 1.8.0) unicorn (4.8.3) diff --git a/app/models/response.rb b/app/models/response.rb index 5f0c417..688ddc4 100644 --- a/app/models/response.rb +++ b/app/models/response.rb @@ -7,6 +7,7 @@ class Response < ActiveRecord::Base } STATUSES = %w(yes maybe no go wait) + PERMISSION_GROUP = %w(명예단원 정단원 예비단원) belongs_to :notice belongs_to :expense_record @@ -21,6 +22,7 @@ class Response < ActiveRecord::Base validates :user, uniqueness: { scope: :notice_id, message: "는 하나의 응답만을 할 수 있습니다." } validates :user, presence: true validates :notice, presence: true + validate :user_has_permission? def self.find_remaining_responses(club) cases = [] @@ -44,4 +46,8 @@ def destroy_public_activities activities = PublicActivity::Activity.where(trackable: self) activities.destroy_all end + + def user_has_permission? + errors.add(:base, "참가 권한이 없습니다.") unless PERMISSION_GROUP.include?(user.member_type) + end end \ No newline at end of file