Skip to content

Commit a118ba1

Browse files
authored
Merge pull request #429 from coopdevs/develop
Release v1.9.0
2 parents 7e28ed9 + aacb6c9 commit a118ba1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+563
-461
lines changed

.env.example

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010

1111

1212
# database setup:
13-
DATABASE_ADAPTER=postgres
1413
DATABASE_USER=postgres
15-
DATABASE_HOST=localhost
14+
DATABASE_NAME=timeoverflow_development
1615

1716
# host part of the url for mail links:
1817
MAIL_LINK_HOST=localhost:3000
18+
MAIL_LINK_PROTO=http
1919

2020
# a list of emails for superadmin users
2121

Gemfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ gem 'rails-i18n'
77
gem "rdiscount"
88
gem 'activeadmin', '~> 1.2.1'
99
gem 'has_scope'
10-
gem 'pundit'
10+
gem 'pundit', '~> 2.0.0'
1111
gem 'pg', '0.17.1'
1212
gem 'hstore_translate'
1313
gem 'dalli'
@@ -48,7 +48,7 @@ group :development do
4848
gem 'airbrussh', require: false
4949
gem 'localeapp', '2.1.1', require: false
5050
gem 'letter_opener', '1.4.1'
51-
gem 'dotenv-rails', '1.0.2'
51+
gem 'dotenv-rails', '2.5.0'
5252
end
5353

5454
group :development, :test do

Gemfile.lock

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,10 @@ GEM
126126
diff-lcs (1.3)
127127
domain_name (0.5.20170223)
128128
unf (>= 0.0.5, < 1.0.0)
129-
dotenv (1.0.2)
130-
dotenv-rails (1.0.2)
131-
dotenv (= 1.0.2)
129+
dotenv (2.5.0)
130+
dotenv-rails (2.5.0)
131+
dotenv (= 2.5.0)
132+
railties (>= 3.2, < 6.0)
132133
elasticsearch (1.0.8)
133134
elasticsearch-api (= 1.0.7)
134135
elasticsearch-transport (= 1.0.7)
@@ -152,7 +153,7 @@ GEM
152153
i18n (~> 0.5)
153154
faraday (0.9.1)
154155
multipart-post (>= 1.2, < 3)
155-
ffi (1.9.23)
156+
ffi (1.9.25)
156157
formtastic (3.1.5)
157158
actionpack (>= 3.2.13)
158159
formtastic_i18n (0.6.0)
@@ -237,7 +238,7 @@ GEM
237238
prawn-table (0.2.2)
238239
prawn (>= 1.3.0, < 3.0.0)
239240
public_suffix (2.0.5)
240-
pundit (0.3.0)
241+
pundit (2.0.0)
241242
activesupport (>= 3.0.0)
242243
rack (1.6.10)
243244
rack-protection (2.0.1)
@@ -321,7 +322,7 @@ GEM
321322
ruby-progressbar (~> 1.7)
322323
unicode-display_width (~> 1.0, >= 1.0.1)
323324
ruby-progressbar (1.9.0)
324-
rubyzip (1.2.1)
325+
rubyzip (1.2.2)
325326
rufus-scheduler (3.4.2)
326327
et-orbi (~> 1.0)
327328
sass (3.4.21)
@@ -412,7 +413,7 @@ DEPENDENCIES
412413
dalli
413414
database_cleaner (= 1.6.2)
414415
devise (~> 4.4.1)
415-
dotenv-rails (= 1.0.2)
416+
dotenv-rails (= 2.5.0)
416417
elasticsearch-model
417418
elasticsearch-rails
418419
fabrication
@@ -427,7 +428,7 @@ DEPENDENCIES
427428
pg (= 0.17.1)
428429
prawn (~> 2.2.0)
429430
prawn-table (~> 0.2.2)
430-
pundit
431+
pundit (~> 2.0.0)
431432
rails (~> 4.2)
432433
rails-i18n
433434
rails_12factor (= 0.0.3)

app/admin/organization.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,19 @@
2727
f.actions
2828
end
2929

30+
controller do
31+
def destroy
32+
resource.destroy
33+
34+
if resource == current_organization
35+
sign_out(current_user)
36+
redirect_to root_path
37+
else
38+
redirect_to admin_organizations_path
39+
end
40+
end
41+
end
42+
3043
filter :name
3144
filter :city, as: :select, collection: -> { Organization.pluck(:city).uniq }
3245
filter :neighborhood

app/controllers/organizations_controller.rb

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
class OrganizationsController < ApplicationController
2-
before_filter :load_resource, only: [:show, :edit, :update, :destroy, :set_current]
2+
before_filter :load_resource, only: [:show, :edit, :update, :set_current]
33

44
def new
55
@organization = Organization.new
6+
7+
authorize @organization
68
end
79

810
def index
9-
@organizations = Organization.all
11+
@organizations = Organization.all.page(params[:page]).per(25)
1012
end
1113

1214
def show
@@ -21,8 +23,10 @@ def show
2123
def create
2224
@organization = Organization.new(organization_params)
2325

26+
authorize @organization
27+
2428
if @organization.save
25-
redirect_to @organization, status: :created
29+
redirect_to @organization
2630
else
2731
render action: :new, status: :unprocessable_entity
2832
end
@@ -36,11 +40,6 @@ def update
3640
end
3741
end
3842

39-
def destroy
40-
@organization.destroy
41-
redirect_to organizations_path, notice: "deleted"
42-
end
43-
4443
# POST /organizations/:organization_id/set_current
4544
#
4645
def set_current
@@ -54,6 +53,8 @@ def set_current
5453

5554
def load_resource
5655
@organization = Organization.find(params[:id])
56+
57+
authorize @organization
5758
end
5859

5960
def organization_params

app/inputs/collection_select2_input.rb

Lines changed: 0 additions & 5 deletions
This file was deleted.

app/inputs/datepicker_input.rb

Lines changed: 0 additions & 6 deletions
This file was deleted.

app/jobs/create_push_notifications_job.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ def perform(event_id:)
66

77
raise 'A valid Event must be provided' unless event
88

9-
::PushNotifications::Creator.new(event: event).create!
9+
if event.post_id
10+
::PushNotifications::Creator::Post.new(event: event).create!
11+
else
12+
raise "You need to define a PushNotifications::Creator class for this event type ##{event.id}"
13+
end
1014
end
1115
end
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class SendPushNotificationsJob < ActiveJob::Base
2+
queue_as :cron
3+
4+
def perform
5+
push_notifications = PushNotification.where(processed_at: nil).limit(100)
6+
7+
::PushNotifications::Broadcast.new(
8+
push_notifications: push_notifications
9+
).send_notifications
10+
end
11+
end

app/models/event.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ class Event < ActiveRecord::Base
44
belongs_to :post
55
belongs_to :member
66
belongs_to :transfer
7+
has_many :push_notifications, dependent: :destroy
78

89
validates :action, presence: true
910
validate :resource_presence

0 commit comments

Comments
 (0)