Skip to content

Commit c1eabb2

Browse files
authored
Merge pull request #721 from coopdevs/develop
Release v4.4.0
2 parents 4b88177 + 5d56ea6 commit c1eabb2

22 files changed

+210
-87
lines changed

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ gem 'sidekiq', '~> 6.5'
2525
gem 'sidekiq-cron', '~> 1.9.1'
2626
gem 'aws-sdk-s3', '~> 1.94', require: false
2727
gem 'image_processing', '~> 1.12'
28+
gem 'active_storage_validations', '~> 1.1.3'
2829

2930
# Assets
3031
gem 'jquery-rails', '~> 4.4.0'

Gemfile.lock

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ GEM
3939
erubi (~> 1.4)
4040
rails-dom-testing (~> 2.0)
4141
rails-html-sanitizer (~> 1.1, >= 1.2.0)
42+
active_storage_validations (1.1.3)
43+
activejob (>= 5.2.0)
44+
activemodel (>= 5.2.0)
45+
activestorage (>= 5.2.0)
46+
activesupport (>= 5.2.0)
4247
activeadmin (2.9.0)
4348
arbre (~> 1.2, >= 1.2.1)
4449
formtastic (>= 3.1, < 5.0)
@@ -447,6 +452,7 @@ PLATFORMS
447452
ruby
448453

449454
DEPENDENCIES
455+
active_storage_validations (~> 1.1.3)
450456
activeadmin (~> 2.9.0)
451457
aws-sdk-s3 (~> 1.94)
452458
bootsnap (~> 1.12.0)

app/controllers/application_controller.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ class ApplicationController < ActionController::Base
66
MissingTOSAcceptance = Class.new(Exception)
77
OutadedTOSAcceptance = Class.new(Exception)
88

9-
append_before_action :check_for_terms_acceptance!, unless: :devise_controller?
9+
before_action :set_locale
10+
before_action :check_for_terms_acceptance!, unless: :devise_controller?
1011
before_action :configure_permitted_parameters, if: :devise_controller?
11-
before_action :set_locale,
12-
:set_current_organization,
12+
before_action :set_current_organization,
1313
:store_user_location
1414

1515
rescue_from MissingTOSAcceptance, OutadedTOSAcceptance do

app/controllers/petitions_controller.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ class PetitionsController < ApplicationController
33

44
def create
55
petition = Petition.new petition_params
6+
petition.status = "pending"
67

78
if petition.save
89
OrganizationNotifier.new_petition(petition).deliver_now
@@ -13,7 +14,7 @@ def create
1314
flash[:error] = t('errors.internal_server_error.description')
1415
end
1516

16-
redirect_to organizations_path
17+
redirect_back fallback_location: organization_path(petition.organization)
1718
end
1819

1920
def update
@@ -38,6 +39,6 @@ def manage
3839
private
3940

4041
def petition_params
41-
params.permit(%i[organization_id user_id status])
42+
params.permit(%i[organization_id user_id])
4243
end
4344
end

app/helpers/application_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def gravatar_url(user, size = 32)
2727
def organization_logo
2828
org = @organization || @current_organization
2929

30-
return unless org && org.logo.attached?
30+
return unless org && org.logo.attached? && org.errors.details[:logo].blank?
3131
return if "#{controller_name}##{action_name}".in? %w(organizations#index pages#show)
3232

3333
content_tag(:div, class: "row organization-logo") do

app/models/concerns/taggable.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ def tag_cloud
4242
end
4343

4444
def find_like_tag(pattern)
45-
all_tags.uniq.select { |t| t =~ /#{pattern}/i }
45+
transliterated_pattern = pattern.present? ? ActiveSupport::Inflector.transliterate(pattern) : ""
46+
all_tags.uniq.select { |t| ActiveSupport::Inflector.transliterate(t) =~ /#{transliterated_pattern}/i }
4647
end
4748

4849
# Builds a hash where the keys are the capital letters of the tags and the

app/models/organization.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ class Organization < ApplicationRecord
2727

2828
validates :name, presence: true, uniqueness: true
2929

30+
LOGO_CONTENT_TYPES = %w(image/jpeg image/png image/gif)
31+
validates :logo, content_type: LOGO_CONTENT_TYPES
32+
3033
before_validation :ensure_url
3134
after_create :create_account
3235

app/views/organizations/_form.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
<%= f.input :address %>
1010
<%= f.input :neighborhood %>
1111
<%= f.input :city %>
12-
<%= f.input :logo %>
12+
<%= f.input :logo, input_html: { accept: Organization::LOGO_CONTENT_TYPES.join(',') } %>
1313
<%= f.button :submit %>
1414
<% end %>

app/views/organizations/_organizations_row.html.erb

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,6 @@
55
<td><%= link_to(org.web, org.web) if org.web.present? %></td>
66
<td><%= org.members.count %></td>
77
<td>
8-
<% if current_user %>
9-
<% petition = current_user.petitions.where(organization_id: org.id).last %>
10-
11-
<% if member = Member.where(user: current_user, organization: org).first %>
12-
<%= link_to t('users.user_rows.delete_membership'),
13-
member,
14-
method: :delete,
15-
data: { confirm: t('users.user_rows.sure_delete', organization_name: org.name) },
16-
class: 'btn btn-danger' %>
17-
<% elsif petition && !current_user.was_member?(petition) %>
18-
<span class="badge"><%= petition.status %></span>
19-
<% else %>
20-
<%= link_to t('petitions.apply'),
21-
petitions_path(user_id: current_user.id, organization_id: org.id, status: 'pending'),
22-
method: :post,
23-
class: 'btn btn-default' %>
24-
<% end %>
25-
<% end %>
8+
<%= render "organizations/petition_button", organization: org %>
269
</td>
2710
</tr>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<% if current_user %>
2+
<% petition = current_user.petitions.where(organization_id: organization.id).last %>
3+
4+
<% if member = Member.where(user: current_user, organization: organization).first %>
5+
<%= link_to t('users.user_rows.delete_membership'),
6+
member,
7+
method: :delete,
8+
data: { confirm: t('users.user_rows.sure_delete', organization_name: organization.name) },
9+
class: 'btn btn-danger' %>
10+
<% elsif petition && !current_user.was_member?(petition) %>
11+
<span class="badge"><%= petition.status %></span>
12+
<% else %>
13+
<%= link_to t('petitions.apply'),
14+
petitions_path(user_id: current_user.id, organization_id: organization.id),
15+
method: :post,
16+
class: 'btn btn-default' %>
17+
<% end %>
18+
<% end %>

0 commit comments

Comments
 (0)