Skip to content

Commit

Permalink
Merge pull request #405 from coopdevs/develop
Browse files Browse the repository at this point in the history
Release v1.7.0
  • Loading branch information
enricostano authored Aug 16, 2018
2 parents fd90f27 + 867fa00 commit 0277034
Show file tree
Hide file tree
Showing 25 changed files with 272 additions and 130 deletions.
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ gem 'rufus-scheduler', '~> 3.4.2'

# Assets
gem 'jquery-rails', '>= 4.2.0'
gem 'jquery-ui-rails'
gem 'bootstrap-sass'
gem 'sass-rails', '~> 5.0.7'
gem 'coffee-rails'
Expand Down
3 changes: 0 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,6 @@ GEM
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
jquery-ui-rails (5.0.3)
railties (>= 3.2.16)
json (2.1.0)
kaminari (1.1.1)
activesupport (>= 4.1.0)
Expand Down Expand Up @@ -423,7 +421,6 @@ DEPENDENCIES
hstore_translate
http_accept_language (~> 2.1.1)
jquery-rails (>= 4.2.0)
jquery-ui-rails
kaminari (~> 1.1.1)
letter_opener (= 1.4.1)
localeapp (= 2.1.1)
Expand Down
2 changes: 0 additions & 2 deletions app/assets/javascripts/application.js.coffee
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#= require_self
#= require datepicker
#= require give_time
#= require tags
#= require mobile_app_libs
Expand Down
20 changes: 0 additions & 20 deletions app/assets/javascripts/datepicker.js.coffee

This file was deleted.

1 change: 0 additions & 1 deletion app/assets/javascripts/libs.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//= require jquery
//= require jquery_ujs
//= require jquery-ui
//= require jquery.validate
//= require bootstrap
//= require highcharts
Expand Down
9 changes: 0 additions & 9 deletions app/assets/stylesheets/application.css.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
/*
*= require_self
*/

@import "variables";
@import "bootstrap-sprockets";
@import "bootstrap-custom";
Expand Down Expand Up @@ -312,11 +308,6 @@ ul.statistics li{
padding-left: 1.5rem;
}

// if not navbar hidden datepicker in small windows
.ui-datepicker{
z-index: 1000 !important;
}

// fields that contain an error
.field_with_errors{
color: red;
Expand Down
1 change: 0 additions & 1 deletion app/assets/stylesheets/libs.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/*
*= require jquery-ui
*= require select2
*/
5 changes: 5 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class ApplicationController < ActionController::Base
end

rescue_from Pundit::NotAuthorizedError, with: :user_not_authorized
rescue_from ActiveRecord::RecordNotFound, with: :resource_not_found

helper_method :current_organization, :admin?, :superadmin?

Expand Down Expand Up @@ -118,4 +119,8 @@ def user_not_authorized
flash[:error] = "You are not authorized to perform this action."
redirect_to(request.referrer || root_path)
end

def resource_not_found
render 'errors/not_found', status: 404
end
end
28 changes: 22 additions & 6 deletions app/controllers/posts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ def edit
instance_variable_set("@#{resource}", post)
end

# GET /offers/:id
# GET /inquiries/:id
#
def show
scope = if current_user.present?
current_organization.posts.active.of_active_members
else
model.all.active.of_active_members
end
post = scope.find params[:id]
post = Post.active.of_active_members.find(params[:id])
update_current_organization!(post.organization)

instance_variable_set("@#{resource}", post)
end

Expand Down Expand Up @@ -115,4 +115,20 @@ def post_params
set_user_id(p)
end
end

# TODO: remove this horrible hack ASAP
#
# This hack set the current organization to the post's
# organization, both in session and controller instance variable.
#
# Before changing the current organization it's important to check that
# the current_user is an active member of the organization.
#
# @param organization [Organization]
def update_current_organization!(organization)
return unless current_user && current_user.active?(organization)

session[:current_organization_id] = organization.id
@current_organization = organization
end
end
4 changes: 2 additions & 2 deletions app/models/member.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class Member < ActiveRecord::Base
# Cast the member_uid integer to a string to allow pg ILIKE search (from Ransack *_contains)
ransacker :member_uid do
Arel.sql("to_char(member_uid, '9999999')")
ransacker :member_uid_search do
Arel.sql("member_uid::text")
end

belongs_to :user
Expand Down
4 changes: 4 additions & 0 deletions app/policies/application_policy.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
class ApplicationPolicy
attr_reader :member, :user, :organization, :record

# TODO: Investigate how to just pass current_user here.
# Probably this will be solved by scoping the resources
# under `/organization`.
#
def initialize(member, record)
@member = member
@user = member.user if member
Expand Down
19 changes: 6 additions & 13 deletions app/views/inquiries/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
<p class="actions text-right">
<% if admin? || @inquiry.user == current_user %>
<%= link_to edit_inquiry_path(@inquiry), class: "btn btn-warning" do %>
<%= glyph :pencil %>
<%= t "global.edit" %>
<% if @inquiry.organization == current_organization %>
<p class="actions text-right">
<% if admin? or @inquiry.user == current_user %>
<%= render 'shared/post_actions', post: @inquiry %>
<% end %>
<%= link_to @inquiry,
data: { method: :delete, confirm: "sure?" },
class: "btn btn-danger" do %>
<%= glyph :trash %>
<%= t "global.delete" %>
<% end %>
<% end %>
</p>
</p>
<% end %>
<%= render "shared/post", post: @inquiry %>
31 changes: 12 additions & 19 deletions app/views/offers/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
<p class="actions text-right">
<% if admin? or @offer.user == current_user %>
<%= link_to edit_offer_path(@offer), class: "btn btn-warning" do %>
<%= glyph :pencil %>
<%= t "global.edit" %>
<% if @offer.organization == current_organization %>
<p class="actions text-right">
<% if admin? or @offer.user == current_user %>
<%= render 'shared/post_actions', post: @offer %>
<% end %>
<%= link_to @offer,
data: { method: :DELETE, confirm: "sure?" },
class: "btn btn-danger" do %>
<%= glyph :trash %>
<%= t "global.delete" %>
<% if current_user and @offer.user != current_user %>
<%= link_to new_transfer_path(id: @offer.user.id, offer: @offer.id, destination_account_id: @destination_account.id),
class: "btn btn-success" do %>
<%= glyph :time %>
<%= t ".give_time_for" %>
<% end %>
<% end %>
<% end %>
<% if current_user and @offer.user != current_user %>
<%= link_to new_transfer_path(id: @offer.user.id, offer: @offer.id, destination_account_id: @destination_account.id),
class: "btn btn-success" do %>
<%= glyph :time %>
<%= t ".give_time_for" %>
<% end %>
<% end %>
</p>
</p>
<% end %>
<%= render "shared/post", post: @offer %>
16 changes: 10 additions & 6 deletions app/views/shared/_post.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<% end %>
</div>
</div>
<% if current_user && current_organization %>
<% if current_user && current_organization == post.organization %>
<div class="panel panel-info">
<div class="panel-heading">
<h3 class="panel-title">
Expand Down Expand Up @@ -60,13 +60,17 @@
</div>
</div>
</div>
<% if !current_user || post.organization != current_organization %>
<div class="alert alert-info">
<%= t 'posts.show.info',
type: post.class.model_name.human,
organization: post.organization.name %>
</div>
<% end %>
<% unless current_user %>
<div class="alert alert-info">
<%= t "posts.show.info",
type: post.class.model_name.human,
organization: post.organization.name %>
<%= link_to t("layouts.application.login"),
new_user_session_path,
class: "btn btn-primary" %>
new_user_session_path,
class: "btn btn-primary" %>
</div>
<% end %>
9 changes: 9 additions & 0 deletions app/views/shared/_post_actions.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<%= link_to post, class: "btn btn-warning" do %>
<%= glyph :pencil %>
<%= t "global.edit" %>
<% end %>

<%= link_to post, data: { method: :delete, confirm: "sure?" }, class: "btn btn-danger" do %>
<%= glyph :trash %>
<%= t "global.delete" %>
<% end %>
6 changes: 2 additions & 4 deletions app/views/statistics/statistics_global_activity.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,12 @@
<form class="form-inline text-right">
<div class="form-group">
<input class="form-control"
id="datepicker_from"
type="date"
name="ini"
placeholder="<%= t '.ini_date' %>"
value="<%= params[:ini] %>">
<input class="form-control"
id="datepicker_to"
type="date"
name="fin"
placeholder="<%= t '.end_date' %>"
value="<%= params[:fin] %>">
<button class="btn btn-default" type="submit">
<%= t '.show' %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/users/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<div class="col-md-12">
<%= search_form_for(@search, class: "navbar-form navbar-left", url: users_path) do |f| %>
<div class="form-group">
<%= f.search_field :user_username_or_user_email_or_member_uid_contains, class: "form-control" %>
<%= f.search_field :user_username_or_user_email_or_member_uid_search_contains, class: "form-control" %>
</div>
<button class="btn btn-default" type="submit">
<%= t 'global.search' %>
Expand Down
2 changes: 1 addition & 1 deletion config/locales/ca.yml
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ ca:
title2: als Bancs de Temps
posts:
show:
info: "%{type} de %{organization} per veure les dades de la persona has de"
info: Aquesta %{type} pertany a %{organization}.
reports:
cat_with_users:
title: Serveis ofertats
Expand Down
2 changes: 1 addition & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ en:
impulsem-link: "Impulsem el que fas"
posts:
show:
info: "%{type} of %{organization} to see person's details you have to"
info: "This %{type} belongs to %{organization}."
reports:
cat_with_users:
title: Offered Services
Expand Down
2 changes: 1 addition & 1 deletion config/locales/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ es:
title2: los Bancos de Tiempo
posts:
show:
info: "%{type} de %{organization} para ver los datos de la persona tienes que"
info: Esta %{type} pertenece a %{organization}.
reports:
cat_with_users:
title: Servicios ofrecidos
Expand Down
2 changes: 1 addition & 1 deletion config/locales/eu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ eu:
title2: Denbora bankuentzat
posts:
show:
info: "%{type} %{organization}koaren datuak ikusteko, hau egin behar duzu"
info:
reports:
cat_with_users:
title: Eskaintzen diren zerbitzuak
Expand Down
2 changes: 1 addition & 1 deletion config/locales/pt-BR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ pt-BR:
title2: os Bancos de Tempo
posts:
show:
info: "%{type} de %{organization} para ver os dados da pessoa é necessário que"
info:
reports:
cat_with_users:
title: Serviços oferecidos
Expand Down
Loading

0 comments on commit 0277034

Please sign in to comment.