enju_event 0.1.19 → 0.2.0.beta.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. checksums.yaml +4 -4
  2. data/README.rdoc +3 -3
  3. data/Rakefile +9 -15
  4. data/app/controllers/concerns/enju_event/controller.rb +13 -0
  5. data/app/controllers/event_categories_controller.rb +13 -2
  6. data/app/controllers/event_export_files_controller.rb +13 -3
  7. data/app/controllers/event_import_files_controller.rb +14 -4
  8. data/app/controllers/event_import_results_controller.rb +12 -1
  9. data/app/controllers/events_controller.rb +18 -8
  10. data/app/controllers/participates_controller.rb +11 -1
  11. data/app/controllers/places_controller.rb +64 -0
  12. data/app/jobs/event_export_file_job.rb +7 -0
  13. data/app/jobs/event_import_file_job.rb +7 -0
  14. data/app/models/event.rb +6 -5
  15. data/app/models/event_category.rb +3 -4
  16. data/app/models/event_export_file.rb +4 -5
  17. data/app/models/event_export_file_transition.rb +4 -4
  18. data/app/models/event_import_file.rb +8 -9
  19. data/app/models/event_import_file_transition.rb +4 -4
  20. data/app/models/event_import_result.rb +2 -3
  21. data/app/models/participate.rb +2 -3
  22. data/app/models/place.rb +18 -0
  23. data/app/policies/event_category_policy.rb +23 -0
  24. data/app/policies/event_export_file_policy.rb +21 -0
  25. data/app/policies/event_import_file_policy.rb +21 -0
  26. data/app/policies/event_import_result_policy.rb +21 -0
  27. data/app/policies/event_policy.rb +21 -0
  28. data/app/policies/participate_policy.rb +21 -0
  29. data/app/policies/place_policy.rb +21 -0
  30. data/app/views/event_categories/index.html.erb +4 -4
  31. data/app/views/event_categories/show.html.erb +1 -1
  32. data/app/views/events/_calendar.html.erb +1 -1
  33. data/app/views/events/{index.mobile.erb → index.html+phone.erb} +6 -6
  34. data/app/views/events/index.html.erb +11 -12
  35. data/app/views/events/index.rss.builder +2 -2
  36. data/app/views/events/{show.mobile.erb → show.html+phone.erb} +0 -0
  37. data/app/views/events/show.html.erb +2 -2
  38. data/app/views/picture_files/_index_event.html.erb +4 -4
  39. data/app/views/places/_form.html.erb +37 -0
  40. data/app/views/places/edit.html.erb +6 -0
  41. data/app/views/places/index.html.erb +35 -0
  42. data/app/views/places/new.html.erb +5 -0
  43. data/app/views/places/show.html.erb +29 -0
  44. data/config/routes.rb +1 -0
  45. data/db/migrate/20151128142913_create_places.rb +15 -0
  46. data/db/migrate/20151201163718_add_place_id_to_event.rb +6 -0
  47. data/db/migrate/20160703184258_add_most_recent_to_event_import_file_transitions.rb +9 -0
  48. data/db/migrate/20160703184311_add_most_recent_to_event_export_file_transitions.rb +9 -0
  49. data/lib/enju_event.rb +0 -19
  50. data/lib/enju_event/version.rb +1 -1
  51. data/lib/tasks/enju_event_tasks.rake +1 -1
  52. data/spec/controllers/event_categories_controller_spec.rb +58 -58
  53. data/spec/controllers/event_export_files_controller_spec.rb +6 -6
  54. data/spec/controllers/event_import_files_controller_spec.rb +4 -4
  55. data/spec/controllers/event_import_results_controller_spec.rb +2 -2
  56. data/spec/controllers/events_controller_spec.rb +6 -6
  57. data/spec/controllers/participates_controller_spec.rb +54 -54
  58. data/spec/dummy/app/controllers/application_controller.rb +8 -4
  59. data/spec/dummy/app/models/user.rb +2 -2
  60. data/spec/dummy/config/application.rb +5 -24
  61. data/spec/dummy/config/environments/development.rb +25 -14
  62. data/spec/dummy/config/environments/production.rb +50 -31
  63. data/spec/dummy/config/environments/test.rb +19 -14
  64. data/spec/dummy/config/routes.rb +3 -0
  65. data/spec/dummy/db/migrate/20140821151023_create_colors.rb +14 -0
  66. data/spec/dummy/db/migrate/20150924115059_create_withdraws.rb +13 -0
  67. data/spec/dummy/db/migrate/20151213070943_add_translation_table_to_library_group.rb +13 -0
  68. data/spec/dummy/db/migrate/20151213072705_add_footer_banner_to_library_group.rb +9 -0
  69. data/spec/dummy/db/schema.rb +52 -1
  70. data/spec/fixtures/event_categories.yml +3 -4
  71. data/spec/fixtures/event_export_files.yml +4 -4
  72. data/spec/fixtures/event_import_files.yml +8 -8
  73. data/spec/fixtures/event_import_results.yml +2 -3
  74. data/spec/fixtures/events.yml +7 -7
  75. data/spec/fixtures/participates.yml +2 -3
  76. data/spec/models/event_category_spec.rb +3 -4
  77. data/spec/models/event_export_file_spec.rb +5 -5
  78. data/spec/models/event_import_file_spec.rb +9 -9
  79. data/spec/models/event_import_result_spec.rb +2 -3
  80. data/spec/models/event_spec.rb +4 -3
  81. data/spec/models/participate_spec.rb +2 -3
  82. data/spec/support/devise.rb +2 -2
  83. metadata +132 -25
  84. data/app/models/enju_event/ability.rb +0 -43
  85. data/app/workers/event_export_file_queue.rb +0 -7
  86. data/app/workers/event_import_file_queue.rb +0 -7
  87. data/lib/enju_event/import_file.rb +0 -13
  88. data/spec/dummy/app/models/ability.rb +0 -41
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 06bb27ceb84bfa7db77a7c733455b7c1f075172a
4
- data.tar.gz: 6188605aae86bc08d855df1842cc612346ab99c7
3
+ metadata.gz: 74666d6077a6991f5f0a7e436b07df60fc75186b
4
+ data.tar.gz: a7e12ff62c20667138919b5bfbe3b78f3cbe3edf
5
5
  SHA512:
6
- metadata.gz: 0160b09125f5a0377ee930c7e69d021cb41afef6333a7dea3ad8d36d21e62c7f28e2b358ac62d035d91feae9df6c1e6e7d95b81ea77ff438a7bda987f5c561f9
7
- data.tar.gz: caa4ad44b410940adbc60eb917c86f38d71b981996b2438b138d839557b07420af6065ae24645a21385bd8014f06a7ec508ee703c6eca8fad503501542a11cdf
6
+ metadata.gz: 62463138f2cac977d0472fba7460ddbaefdd643b3ce80d902fbbb72661135bb577ce139a44e2d067b8830e4cb477081053eb9aa531e563e59210dac04fde9124
7
+ data.tar.gz: 90ce3da43038e500f493c8d256f083db2d4fd955987959fc8b7ad6cef56161e801e51d8c51436f56f436173339dfa3ce76aaea25d4a539f87648e9097a9a5824
@@ -1,7 +1,7 @@
1
1
  = EnjuEvent
2
- {<img src="https://travis-ci.org/next-l/enju_event.svg?branch=1.1" alt="Build Status" />}[https://travis-ci.org/next-l/enju_event]
3
- {<img src="https://coveralls.io/repos/next-l/enju_event/badge.svg?branch=1.1&service=github" alt="Coverage Status" />}[https://coveralls.io/github/next-l/enju_event?branch=1.1]
4
- {<img src="https://hakiri.io/github/next-l/enju_event/1.1.svg" alt="security" />}[https://hakiri.io/github/next-l/enju_event/1.1]
2
+ {<img src="https://travis-ci.org/next-l/enju_event.svg?branch=1.2" alt="Build Status" />}[https://travis-ci.org/next-l/enju_event]
3
+ {<img src="https://coveralls.io/repos/next-l/enju_event/badge.svg?branch=1.2&service=github" alt="Coverage Status" />}[https://coveralls.io/github/next-l/enju_event?branch=1.2]
4
+ {<img src="https://hakiri.io/github/next-l/enju_event/1.2.svg" alt="security" />}[https://hakiri.io/github/next-l/enju_event/1.2]
5
5
 
6
6
  This project rocks and uses MIT-LICENSE.
7
7
 
data/Rakefile CHANGED
@@ -1,16 +1,10 @@
1
- #!/usr/bin/env rake
2
1
  begin
3
2
  require 'bundler/setup'
4
3
  rescue LoadError
5
4
  puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
5
  end
7
- begin
8
- require 'rdoc/task'
9
- rescue LoadError
10
- require 'rdoc/rdoc'
11
- require 'rake/rdoctask'
12
- RDoc::Task = Rake::RDocTask
13
- end
6
+
7
+ require 'rdoc/task'
14
8
 
15
9
  RDoc::Task.new(:rdoc) do |rdoc|
16
10
  rdoc.rdoc_dir = 'rdoc'
@@ -24,10 +18,11 @@ APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
24
18
  load 'rails/tasks/engine.rake'
25
19
 
26
20
 
27
- Bundler::GemHelper.install_tasks
21
+ load 'rails/tasks/statistics.rake'
28
22
 
29
- require 'rspec/core'
30
- require 'rspec/core/rake_task'
23
+
24
+
25
+ Bundler::GemHelper.install_tasks
31
26
 
32
27
  require 'rake/testtask'
33
28
 
@@ -38,9 +33,8 @@ Rake::TestTask.new(:test) do |t|
38
33
  t.verbose = false
39
34
  end
40
35
 
41
- RSpec::Core::RakeTask.new(:spec) do |spec|
42
- spec.pattern = FileList['spec/**/*_spec.rb']
43
- end
44
36
 
37
+ require "rspec/core/rake_task"
45
38
 
46
- task :default => :spec
39
+ RSpec::Core::RakeTask.new("spec")
40
+ task default: :spec
@@ -0,0 +1,13 @@
1
+ module EnjuEvent
2
+ module Controller
3
+
4
+ private
5
+
6
+ def get_event
7
+ if params[:event_id]
8
+ @event = Event.find(params[:event_id])
9
+ authorize @event, :show?
10
+ end
11
+ end
12
+ end
13
+ end
@@ -1,9 +1,11 @@
1
1
  class EventCategoriesController < ApplicationController
2
- load_and_authorize_resource
2
+ before_action :set_event_category, only: [:show, :edit, :update, :destroy]
3
+ before_action :check_policy, only: [:index, :new, :create]
4
+
3
5
  # GET /event_categories
4
6
  # GET /event_categories.json
5
7
  def index
6
- @event_categories = EventCategory.all
8
+ @event_categories = EventCategory.order(:position)
7
9
 
8
10
  respond_to do |format|
9
11
  format.html # index.html.erb
@@ -82,6 +84,15 @@ class EventCategoriesController < ApplicationController
82
84
  end
83
85
 
84
86
  private
87
+ def set_event_category
88
+ @event_category = EventCategory.find(params[:id])
89
+ authorize @event_category
90
+ end
91
+
92
+ def check_policy
93
+ authorize EventCategory
94
+ end
95
+
85
96
  def event_category_params
86
97
  params.require(:event_category).permit(:name, :display_name, :note)
87
98
  end
@@ -1,5 +1,6 @@
1
1
  class EventExportFilesController < ApplicationController
2
- load_and_authorize_resource
2
+ before_action :set_event_export_file, only: [:show, :edit, :update, :destroy]
3
+ before_action :check_policy, only: [:index, :new, :create]
3
4
 
4
5
  # GET /event_export_files
5
6
  # GET /event_export_files.json
@@ -60,7 +61,7 @@ class EventExportFilesController < ApplicationController
60
61
  respond_to do |format|
61
62
  if @event_export_file.save
62
63
  if @event_export_file.mode == 'export'
63
- Resque.enqueue(EventExportFileQueue, @event_export_file.id)
64
+ EventExportFileJob.perform_later(@event_export_file)
64
65
  end
65
66
  format.html { redirect_to @event_export_file, notice: t('export.successfully_created', model: t('activerecord.models.event_export_file')) }
66
67
  format.json { render json: @event_export_file, status: :created, location: @event_export_file }
@@ -77,7 +78,7 @@ class EventExportFilesController < ApplicationController
77
78
  respond_to do |format|
78
79
  if @event_export_file.update_attributes(event_export_file_params)
79
80
  if @event_export_file.mode == 'export'
80
- EventExportFileQueue.perform(@event_export_file.id)
81
+ EventExportFileJob.perform_later(@event_export_file)
81
82
  end
82
83
  format.html { redirect_to @event_export_file, notice: t('controller.successfully_updated', model: t('activerecord.models.event_export_file')) }
83
84
  format.json { head :no_content }
@@ -100,6 +101,15 @@ class EventExportFilesController < ApplicationController
100
101
  end
101
102
 
102
103
  private
104
+ def set_event_export_file
105
+ @event_export_file = EventExportFile.find(params[:id])
106
+ authorize @event_export_file
107
+ end
108
+
109
+ def check_policy
110
+ authorize EventExportFile
111
+ end
112
+
103
113
  def event_export_file_params
104
114
  params.require(:event_export_file).permit(:mode)
105
115
  end
@@ -1,6 +1,7 @@
1
1
  class EventImportFilesController < ApplicationController
2
- load_and_authorize_resource
3
- before_filter :prepare_options, only: [:new, :edit]
2
+ before_action :set_event_import_file, only: [:show, :edit, :update, :destroy]
3
+ before_action :check_policy, only: [:index, :new, :create]
4
+ before_action :prepare_options, only: [:new, :edit]
4
5
 
5
6
  # GET /event_import_files
6
7
  # GET /event_import_files.json
@@ -61,7 +62,7 @@ class EventImportFilesController < ApplicationController
61
62
  respond_to do |format|
62
63
  if @event_import_file.save
63
64
  if @event_import_file.mode == 'import'
64
- Resque.enqueue(EventImportFileQueue, @event_import_file.id)
65
+ EventImportFileJob.perform_later(@event_import_file)
65
66
  end
66
67
  format.html { redirect_to @event_import_file, notice: t('import.successfully_created', model: t('activerecord.models.event_import_file')) }
67
68
  format.json { render json: @event_import_file, status: :created, location: @event_import_file }
@@ -79,7 +80,7 @@ class EventImportFilesController < ApplicationController
79
80
  respond_to do |format|
80
81
  if @event_import_file.update_attributes(event_import_file_params)
81
82
  if @event_import_file.mode == 'import'
82
- Resque.enqueue(EventImportFileQueue, @event_import_file.id)
83
+ EventImportFileJob.perform_later(@event_import_file)
83
84
  end
84
85
  format.html { redirect_to @event_import_file, notice: t('controller.successfully_updated', model: t('activerecord.models.event_import_file')) }
85
86
  format.json { head :no_content }
@@ -103,6 +104,15 @@ class EventImportFilesController < ApplicationController
103
104
  end
104
105
 
105
106
  private
107
+ def set_event_import_file
108
+ @event_import_file = EventImportFile.find(params[:id])
109
+ authorize @event_import_file
110
+ end
111
+
112
+ def check_policy
113
+ authorize EventImportFile
114
+ end
115
+
106
116
  def event_import_file_params
107
117
  params.require(:event_import_file).permit(
108
118
  :event_import, :edit_mode, :user_encoding, :mode,
@@ -1,5 +1,7 @@
1
1
  class EventImportResultsController < ApplicationController
2
- load_and_authorize_resource
2
+ before_action :set_event_import_result, only: [:show, :edit, :update, :destroy]
3
+ before_action :check_policy, only: [:index, :new, :create]
4
+
3
5
  # GET /event_import_results
4
6
  # GET /event_import_results.json
5
7
  def index
@@ -38,6 +40,15 @@ class EventImportResultsController < ApplicationController
38
40
  end
39
41
 
40
42
  private
43
+ def set_event_import_result
44
+ @event_import_result = EventImportResult.find(params[:id])
45
+ authorize @event_import_result
46
+ end
47
+
48
+ def check_policy
49
+ authorize EventImportResult
50
+ end
51
+
41
52
  def event_import_result_params
42
53
  params.require(:event_import_result).permit(
43
54
  :event_id, :event_import_file_id, :body #, as: :admin
@@ -1,12 +1,11 @@
1
- # -*- encoding: utf-8 -*-
2
1
  class EventsController < ApplicationController
3
- load_and_authorize_resource
4
- before_filter :get_library, :get_agent
5
- before_filter :get_libraries, except: :destroy
6
- before_filter :prepare_options
7
- before_filter :store_page, only: :index
8
- after_filter :solr_commit, only: [:create, :update, :destroy]
9
- after_filter :convert_charset, only: :index
2
+ before_action :store_page, only: :index
3
+ before_action :set_event, only: [:show, :edit, :update, :destroy]
4
+ before_action :check_policy, only: [:index, :new, :create]
5
+ before_action :get_library, :get_agent
6
+ before_action :get_libraries, except: :destroy
7
+ before_action :prepare_options
8
+ after_action :convert_charset, only: :index
10
9
 
11
10
  # GET /events
12
11
  # GET /events.json
@@ -45,6 +44,7 @@ class EventsController < ApplicationController
45
44
 
46
45
  respond_to do |format|
47
46
  format.html # index.html.erb
47
+ format.html.phone
48
48
  format.json
49
49
  format.rss { render layout: false }
50
50
  format.txt
@@ -60,6 +60,7 @@ class EventsController < ApplicationController
60
60
 
61
61
  respond_to do |format|
62
62
  format.html # show.html.erb
63
+ format.html.phone
63
64
  format.json { render json: @event }
64
65
  end
65
66
  end
@@ -144,6 +145,15 @@ class EventsController < ApplicationController
144
145
  end
145
146
 
146
147
  private
148
+ def set_event
149
+ @event = Event.find(params[:id])
150
+ authorize @event
151
+ end
152
+
153
+ def check_policy
154
+ authorize Event
155
+ end
156
+
147
157
  def event_params
148
158
  params.require(:event).permit(
149
159
  :library_id, :event_category_id, :name, :note, :start_at,
@@ -1,5 +1,6 @@
1
1
  class ParticipatesController < ApplicationController
2
- load_and_authorize_resource
2
+ before_action :set_participate, only: [:show, :edit, :update, :destroy]
3
+ before_action :check_policy, only: [:index, :new, :create]
3
4
 
4
5
  # GET /participates
5
6
  # GET /participates.json
@@ -80,6 +81,15 @@ class ParticipatesController < ApplicationController
80
81
  end
81
82
 
82
83
  private
84
+ def set_participate
85
+ @participate = Participate.find(params[:id])
86
+ authorize @participate
87
+ end
88
+
89
+ def check_policy
90
+ authorize Participate
91
+ end
92
+
83
93
  def participate_params
84
94
  params.require(:participate).permit(:agent_id, :event_id)
85
95
  end
@@ -0,0 +1,64 @@
1
+ class PlacesController < ApplicationController
2
+ before_action :set_place, only: [:show, :edit, :update, :destroy]
3
+ before_action :check_policy, only: [:index, :new, :create]
4
+
5
+ # GET /places
6
+ def index
7
+ @places = Place.all
8
+ end
9
+
10
+ # GET /places/1
11
+ def show
12
+ end
13
+
14
+ # GET /places/new
15
+ def new
16
+ @place = Place.new
17
+ end
18
+
19
+ # GET /places/1/edit
20
+ def edit
21
+ end
22
+
23
+ # POST /places
24
+ def create
25
+ @place = Place.new(place_params)
26
+
27
+ if @place.save
28
+ redirect_to @place, notice: 'Place was successfully created.'
29
+ else
30
+ render :new
31
+ end
32
+ end
33
+
34
+ # PATCH/PUT /places/1
35
+ def update
36
+ if @place.update(place_params)
37
+ redirect_to @place, notice: 'Place was successfully updated.'
38
+ else
39
+ render :edit
40
+ end
41
+ end
42
+
43
+ # DELETE /places/1
44
+ def destroy
45
+ @place.destroy
46
+ redirect_to places_url, notice: 'Place was successfully destroyed.'
47
+ end
48
+
49
+ private
50
+ # Use callbacks to share common setup or constraints between actions.
51
+ def set_place
52
+ @place = Place.find(params[:id])
53
+ autorize @place
54
+ end
55
+
56
+ def check_policy
57
+ authorize Place
58
+ end
59
+
60
+ # Only allow a trusted parameter "white list" through.
61
+ def place_params
62
+ params.require(:place).permit(:term, :city, :country_id, :latitude, :longitude)
63
+ end
64
+ end
@@ -0,0 +1,7 @@
1
+ class EventExportFileJob < ActiveJob::Base
2
+ queue_as :enju_leaf
3
+
4
+ def perform(event_export_file)
5
+ event_export_file.export!
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ class EventImportFileJob < ActiveJob::Base
2
+ queue_as :enju_leaf
3
+
4
+ def perform(event_import_file)
5
+ event_import_file.import_start
6
+ end
7
+ end
@@ -1,4 +1,3 @@
1
- # -*- encoding: utf-8 -*-
2
1
  class Event < ActiveRecord::Base
3
2
  scope :closing_days, -> { includes(:event_category).where('event_categories.name' => 'closed') }
4
3
  scope :on, lambda {|datetime| where('start_at >= ? AND start_at < ?', datetime.beginning_of_day, datetime.tomorrow.beginning_of_day + 1)}
@@ -8,6 +7,7 @@ class Event < ActiveRecord::Base
8
7
 
9
8
  belongs_to :event_category, validate: true
10
9
  belongs_to :library, validate: true
10
+ belongs_to :place
11
11
  has_many :picture_files, as: :picture_attachable
12
12
  has_many :participates, dependent: :destroy
13
13
  has_many :agents, through: :participates
@@ -66,7 +66,7 @@ class Event < ActiveRecord::Base
66
66
  all_day
67
67
  )
68
68
  lines = []
69
- Event.all.map{|e|
69
+ Event.find_each.map{|e|
70
70
  line = []
71
71
  line << e.name
72
72
  line << e.event_category.name
@@ -91,13 +91,14 @@ end
91
91
  # id :integer not null, primary key
92
92
  # library_id :integer not null
93
93
  # event_category_id :integer not null
94
- # name :string(255)
94
+ # name :string
95
95
  # note :text
96
96
  # start_at :datetime
97
97
  # end_at :datetime
98
98
  # all_day :boolean default(FALSE), not null
99
99
  # deleted_at :datetime
100
100
  # display_name :text
101
- # created_at :datetime not null
102
- # updated_at :datetime not null
101
+ # created_at :datetime
102
+ # updated_at :datetime
103
+ # place_id :integer
103
104
  #
@@ -11,11 +11,10 @@ end
11
11
  # Table name: event_categories
12
12
  #
13
13
  # id :integer not null, primary key
14
- # name :string(255) not null
14
+ # name :string not null
15
15
  # display_name :text
16
16
  # note :text
17
17
  # position :integer
18
- # created_at :datetime not null
19
- # updated_at :datetime not null
18
+ # created_at :datetime
19
+ # updated_at :datetime
20
20
  #
21
-
@@ -1,7 +1,6 @@
1
1
  class EventExportFile < ActiveRecord::Base
2
2
  include Statesman::Adapters::ActiveRecordQueries
3
3
  include ExportFile
4
- enju_export_file_model
5
4
 
6
5
  if ENV['ENJU_STORAGE'] == 's3'
7
6
  has_attached_file :event_export, storage: :s3,
@@ -58,11 +57,11 @@ end
58
57
  #
59
58
  # id :integer not null, primary key
60
59
  # user_id :integer
61
- # event_export_file_name :string(255)
62
- # event_export_content_type :string(255)
60
+ # event_export_file_name :string
61
+ # event_export_content_type :string
63
62
  # event_export_file_size :integer
64
63
  # event_export_updated_at :datetime
65
64
  # executed_at :datetime
66
- # created_at :datetime not null
67
- # updated_at :datetime not null
65
+ # created_at :datetime
66
+ # updated_at :datetime
68
67
  #