Skip to content

Commit 6733752

Browse files
authored
Merge pull request #744 from coopdevs/develop
Release v5.2.0
2 parents 5fa056b + fb93484 commit 6733752

16 files changed

+24
-12
lines changed

Gemfile

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ gem 'pg', '~> 1.4'
1313
gem 'json_translate', '~> 4.0.0'
1414
gem 'devise', '~> 4.9.1'
1515
gem 'devise-i18n', '~> 1.11.0'
16+
gem 'invisible_captcha', '~> 2.3.0'
1617
gem 'http_accept_language', '~> 2.1.1'
1718
gem 'kaminari', '~> 1.2.1'
1819
gem 'simple_form', '~> 5.0.2'

Gemfile.lock

+3
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,8 @@ GEM
183183
has_scope (>= 0.6)
184184
railties (>= 6.0)
185185
responders (>= 2)
186+
invisible_captcha (2.3.0)
187+
rails (>= 5.2)
186188
jmespath (1.6.2)
187189
jquery-rails (4.4.0)
188190
rails-dom-testing (>= 1, < 3)
@@ -450,6 +452,7 @@ DEPENDENCIES
450452
has_scope (~> 0.7.2)
451453
http_accept_language (~> 2.1.1)
452454
image_processing (~> 1.12)
455+
invisible_captcha (~> 2.3.0)
453456
jquery-rails (~> 4.4.0)
454457
json_translate (~> 4.0.0)
455458
kaminari (~> 1.2.1)

README.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ of it and is prepared to be able to accommodate several Time Banks in a single i
1515
for this account with three levels of privileges: superadmin, admin (only manages a bank)
1616
and members of a bank.
1717

18-
![Users list](docs/images/usuarios.png)
19-
![Offers list](docs/images/ofertas.png)
18+
![Demo UI](docs/images/demo_ui.jpeg)
2019

2120
TimeOverflow is divided into 2 large blocks:
2221

app/admin/user.rb

+3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
ActiveAdmin.register User do
2+
config.batch_actions = true
3+
24
action_item :upload_csv, only: :index do
35
link_to I18n.t("active_admin.users.upload_from_csv"), action: "upload_csv"
46
end
@@ -15,6 +17,7 @@
1517
end
1618

1719
index do
20+
selectable_column
1821
column do |user|
1922
link_to image_tag(avatar_url(user, 24)), admin_user_path(user)
2023
end

app/controllers/users_controller.rb

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ class UsersController < ApplicationController
33
before_action :user_should_be_confirmed, except: %i[signup create please_confirm]
44
before_action :member_should_exist_and_be_active, except: %i[signup create edit show update please_confirm]
55

6+
invisible_captcha only: :create, if: -> { params[:from_signup].present? }
7+
68
has_scope :tagged_with, as: :tag
79

810
def index

app/jobs/organization_notifier_job.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# A weekly digest email.
22
#
33
# Strategy: go throught all organizations and take latest active posts from last week
4-
# posted by active members. Send an email to all active and online members
4+
# posted by active members. Send an email to all confirmed, active and online members
55
# with the email notifications enabled with those posts. Group emails by user's locale.
66

77
# Schedule defined in config/schedule.yml file.
@@ -24,11 +24,11 @@ def perform
2424
private
2525

2626
def users_by_locale(organization)
27-
with_notifications = organization.users.online_active.actives.notifications
28-
org_locales = with_notifications.pluck(:locale).uniq
27+
org_users = organization.users.online_active.actives.confirmed.notifications
28+
org_locales = org_users.pluck(:locale).uniq
2929

3030
org_locales.each_with_object({}) do |locale, hash|
31-
hash[locale] = with_notifications.where(locale: locale)
31+
hash[locale] = org_users.where(locale: locale)
3232
end
3333
end
3434
end

app/mailers/organization_notifier.rb

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ class OrganizationNotifier < ActionMailer::Base
22
default from: "\"TimeOverflow\" <info@timeoverflow.org>"
33

44
def recent_posts(posts, locale, users)
5-
# last 10 posts of offers and inquiries
65
@offers = posts.where(type: "Offer").take(10)
76
@inquiries = posts.where(type: "Inquiry").take(10)
87

app/models/user.rb

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class User < ApplicationRecord
4141
scope :actives, -> { joins(:members).where(members: { active: true }) }
4242
scope :online_active, -> { where("sign_in_count > 0") }
4343
scope :notifications, -> { where(notifications: true) }
44+
scope :confirmed, -> { where.not(confirmed_at: nil) }
4445

4546
validates :username, presence: true
4647
validates :email, presence: true, uniqueness: true

app/views/users/_form.html.erb

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<%= show_error_messages!(@user) %>
22
<%= simple_form_for @user do |f| %>
33
<%= f.hidden_field :locale, value: I18n.locale %>
4+
<%= invisible_captcha %>
45

56
<div class="form-inputs">
67
<%= f.input :username %>

config/initializers/active_admin.rb

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
config.current_user_method = :current_user
88
config.logout_link_path = :destroy_user_session_path
99
config.logout_link_method = :delete
10-
config.batch_actions = false
1110
config.comments = false
1211
config.namespace :admin do |admin|
1312
admin.build_menu :utility_navigation do |menu|
+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
InvisibleCaptcha.setup do |config|
2+
config.timestamp_enabled = !Rails.env.test?
3+
config.spinner_enabled = !Rails.env.test?
4+
end

docs/images/demo_ui.jpeg

642 KB
Loading

docs/images/ofertas.png

-71 KB
Binary file not shown.

docs/images/usuarios.png

-86.6 KB
Binary file not shown.

spec/controllers/users_controller_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -441,8 +441,8 @@
441441

442442
let(:uploaded_file) do
443443
Rack::Test::UploadedFile.new(
444-
Rails.root.join("docs/images/ofertas.png"),
445-
"image/png"
444+
Rails.root.join("docs/images/demo_ui.jpeg"),
445+
"image/jpeg"
446446
)
447447
end
448448

spec/mailers/organization_notifier_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
let(:test_organization) { Fabricate(:organization) }
33
let!(:offer) { Fabricate(:offer, organization: test_organization) }
44
let!(:inquiry) { Fabricate(:inquiry, organization: test_organization) }
5-
let(:user) { Fabricate(:user, email: "user@example.com", locale: :en) }
5+
let(:user) { Fabricate(:user, email: "user@timeoverflow.org", locale: :en) }
66
let(:member) { Fabricate(:member, organization: test_organization, user: user) }
77

88
describe "send an email" do
@@ -17,7 +17,7 @@
1717
let(:mail) { OrganizationNotifier.recent_posts(test_organization.posts, :en, [user]) }
1818

1919
it "receive email only active and online users" do
20-
expect(mail.bcc).to eql(["user@example.com"])
20+
expect(mail.bcc).to eql(["user@timeoverflow.org"])
2121
end
2222
it "to should be null" do
2323
expect(mail.to).to be_nil

0 commit comments

Comments
 (0)