Skip to content

Commit

Permalink
Merge pull request #463 from coopdevs/develop
Browse files Browse the repository at this point in the history
Release v1.11.0
  • Loading branch information
enricostano authored Feb 18, 2019
2 parents a645342 + 5b91deb commit 937b3a2
Show file tree
Hide file tree
Showing 22 changed files with 178 additions and 88 deletions.
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
¿Has encontrado algún bug? ¿Quieres colaborar?

Proceso:
* Abrir un hilo en [discourse](http://community.coopdevs.org/) para aclarar si es un bug o una feature :wink:
* Una vez aclarado el bug y detectado los pasos para reproducirlos se crearia una issue en GH con enlaze al hilo original en discourse.
* Abrir un hilo en [discourse](https://community.coopdevs.org/c/timeoverflow) para aclarar si es un bug o una feature :wink:
* Una vez aclarado, si se trata de un bug, abre una issue en Github indicando los pasos para reproducirlo y cómo debería funncionar correctamente, enlaza al hilo original en discourse.
* Pull request que resuelve la issue.
* Reportar en el hilo de discourse que el bug ha sido resuelto con enlace a PR.

Expand Down
72 changes: 36 additions & 36 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
GEM
remote: https://rubygems.org/
specs:
actionmailer (4.2.10)
actionpack (= 4.2.10)
actionview (= 4.2.10)
activejob (= 4.2.10)
actionmailer (4.2.11)
actionpack (= 4.2.11)
actionview (= 4.2.11)
activejob (= 4.2.11)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 1.0, >= 1.0.5)
actionpack (4.2.10)
actionview (= 4.2.10)
activesupport (= 4.2.10)
actionpack (4.2.11)
actionview (= 4.2.11)
activesupport (= 4.2.11)
rack (~> 1.6)
rack-test (~> 0.6.2)
rails-dom-testing (~> 1.0, >= 1.0.5)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (4.2.10)
activesupport (= 4.2.10)
actionview (4.2.11)
activesupport (= 4.2.11)
builder (~> 3.1)
erubis (~> 2.7.0)
rails-dom-testing (~> 1.0, >= 1.0.5)
Expand All @@ -32,17 +32,17 @@ GEM
ransack (~> 1.3)
sass (~> 3.1)
sprockets (< 4.1)
activejob (4.2.10)
activesupport (= 4.2.10)
activejob (4.2.11)
activesupport (= 4.2.11)
globalid (>= 0.3.0)
activemodel (4.2.10)
activesupport (= 4.2.10)
activemodel (4.2.11)
activesupport (= 4.2.11)
builder (~> 3.1)
activerecord (4.2.10)
activemodel (= 4.2.10)
activesupport (= 4.2.10)
activerecord (4.2.11)
activemodel (= 4.2.11)
activesupport (= 4.2.11)
arel (~> 6.0)
activesupport (4.2.10)
activesupport (4.2.11)
i18n (~> 0.7)
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
Expand Down Expand Up @@ -111,7 +111,7 @@ GEM
execjs
coffee-script-source (1.8.0)
columnize (0.9.0)
concurrent-ruby (1.0.5)
concurrent-ruby (1.1.3)
connection_pool (2.2.1)
crass (1.0.4)
dalli (2.7.2)
Expand Down Expand Up @@ -204,15 +204,15 @@ GEM
i18n (~> 0.4)
json
rest-client
loofah (2.2.2)
loofah (2.2.3)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.7.0)
mail (2.7.1)
mini_mime (>= 0.1.1)
mime-types (3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521)
mini_mime (1.0.0)
mini_mime (1.0.1)
mini_portile2 (2.3.0)
minitest (5.11.3)
multi_json (1.11.2)
Expand All @@ -221,7 +221,7 @@ GEM
net-ssh (>= 2.6.5)
net-ssh (2.9.2)
netrc (0.11.0)
nokogiri (1.8.4)
nokogiri (1.8.5)
mini_portile2 (~> 2.3.0)
orm_adapter (0.5.0)
parallel (1.12.1)
Expand All @@ -240,21 +240,21 @@ GEM
public_suffix (2.0.5)
pundit (2.0.0)
activesupport (>= 3.0.0)
rack (1.6.10)
rack (1.6.11)
rack-protection (2.0.1)
rack
rack-test (0.6.3)
rack (>= 1.0)
rails (4.2.10)
actionmailer (= 4.2.10)
actionpack (= 4.2.10)
actionview (= 4.2.10)
activejob (= 4.2.10)
activemodel (= 4.2.10)
activerecord (= 4.2.10)
activesupport (= 4.2.10)
rails (4.2.11)
actionmailer (= 4.2.11)
actionpack (= 4.2.11)
actionview (= 4.2.11)
activejob (= 4.2.11)
activemodel (= 4.2.11)
activerecord (= 4.2.11)
activesupport (= 4.2.11)
bundler (>= 1.3.0, < 2.0)
railties (= 4.2.10)
railties (= 4.2.11)
sprockets-rails
rails-deprecated_sanitizer (1.0.3)
activesupport (>= 4.2.0.alpha)
Expand All @@ -272,9 +272,9 @@ GEM
rails_stdout_logging
rails_serve_static_assets (0.0.3)
rails_stdout_logging (0.0.3)
railties (4.2.10)
actionpack (= 4.2.10)
activesupport (= 4.2.10)
railties (4.2.11)
actionpack (= 4.2.11)
activesupport (= 4.2.11)
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rainbow (3.0.0)
Expand Down Expand Up @@ -364,7 +364,7 @@ GEM
sshkit (1.8.1)
net-scp (>= 1.1.2)
net-ssh (>= 2.8.0)
thor (0.20.0)
thor (0.20.3)
thread_safe (0.3.6)
tilt (2.0.8)
ttfunk (1.5.1)
Expand Down
9 changes: 7 additions & 2 deletions app/assets/javascripts/give_time.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@ jQuery.validator.addMethod "either-hours-minutes-informed", ((value, element) ->
giveTimeReadyFn = () ->
config =
submitHandler: (form) ->
$(" #transfer_amount ").val($(" #transfer_hours ").val() * 3600 + $(" #transfer_minutes ").val() * 60)
form.submit()
amount = $("#transfer_hours").val() * 3600 + $("#transfer_minutes").val() * 60
$("#transfer_amount").val(amount)

if amount > 0
form.submit()
else
$(form).find('.form-actions .error').removeClass('invisible').show()

$( "#new_transfer" ).validate(config)

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/transfers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def create
if persister.save
redirect_to redirect_target
else
flash[:error] = transfer.errors.full_messages.to_sentence
redirect_to :back, alert: transfer.errors.full_messages.to_sentence
end
end

Expand Down
4 changes: 4 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ module ApplicationHelper
TEXT_SUCCESS = 'text-success'.freeze
TEXT_DANGER = 'text-danger'.freeze

def page_title
current_organization || 'TimeOverflow'
end

# from gravatar
def avatar_url(user, size = 32)
gravatar_id = Digest::MD5::hexdigest(user.email).downcase
Expand Down
2 changes: 2 additions & 0 deletions app/models/movement.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ class Movement < ActiveRecord::Base
where(created_at: month.beginning_of_month..month.end_of_month)
}

validates :amount, numericality: { other_than: 0 }

after_create do
account.update_balance
end
Expand Down
9 changes: 1 addition & 8 deletions app/models/transfer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class Transfer < ActiveRecord::Base
has_many :movements, dependent: :destroy
has_many :events, dependent: :destroy

validates :amount, numericality: { greater_than: 0 }
validate :different_source_and_destination

after_create :make_movements
Expand All @@ -26,14 +27,6 @@ def make_movements
movements.create(account: Account.find(destination_id), amount: amount.to_i)
end

def movement_from
movements.detect {|m| m.amount < 0 }
end

def movement_to
movements.detect {|m| m.amount > 0 }
end

def source_id
source.respond_to?(:id) ? source.id : source
end
Expand Down
8 changes: 7 additions & 1 deletion app/services/push_notifications/creator/post.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@ def title
end

def body
event.post.description&.truncate(20) || 'No description'
description = event.post.description

if description.blank?
'No description'
else
description.truncate(20)
end
end

def data
Expand Down
31 changes: 4 additions & 27 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,17 @@
<meta charset="utf-8">
<meta content="IE=Edge,chrome=1" http-equiv="X-UA-Compatible">
<meta content="width=device-width, initial-scale=1.0" name="viewport">
<title>
<% if content_for? :window_title %>
<%= content_for :window_title %>
<% else %>
<% if current_organization %>
<%= current_organization %>
<% end %>
<%= yield :title %>
<% end %>
</title>
<title><%= page_title %></title>
<%= csrf_meta_tags %>
<link href="/favicon.ico" rel="shortcut icon">
<%= stylesheet_link_tag 'libs', media: 'all' %>
<%= stylesheet_link_tag 'application', media: 'all' %>
<%= stylesheet_link_tag 'application', 'https://fonts.googleapis.com/css?family=Work+Sans:400,500,600,700' %>
<%= stylesheet_link_tag 'application', 'https://fonts.googleapis.com/icon?family=Material+Icons' %>
<%= stylesheet_link_tag 'https://fonts.googleapis.com/css?family=Work+Sans:400,500,600,700' %>
<%= stylesheet_link_tag 'https://fonts.googleapis.com/icon?family=Material+Icons' %>
<%= javascript_include_tag 'libs' %>
<%= javascript_include_tag 'application' %>
</head>
<body class="<%= get_body_css_class(controller.controller_name) %>" data-action="<%= params[:controller] %>-<%= params[:action] %>">
<body class="<%= get_body_css_class(controller_name) %>">
<%= render 'navbar' %>
<div class="container content">
<%= render 'layouts/messages' unless devise_controller? %>
Expand All @@ -38,19 +29,5 @@
<%= render 'application/footer' %>

<div class="back-overlay"></div>
<!-- Piwik -->
<script type="text/javascript">
var _paq = _paq || [];
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
_paq.push(['setTrackerUrl', 'https://api-3d186b7b77a47155c00f114ddc52a2e7.fki.sandcats.io']);
_paq.push(['setSiteId', 1]);
_paq.push(['setApiToken', 'YIg1zq997dOFyvS5VTi4RZ0hnC0Ji3MkeYgHNvdky0c']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.type='text/javascript'; g.async=true; g.defer=true; g.src='https://00cwpvzw77kc4cysvzdy.fki.sandcats.io/embed.js'; s.parentNode.insertBefore(g,s);
})();
</script>
<!-- End Piwik Code -->
</body>
</html>
8 changes: 6 additions & 2 deletions app/views/shared/_post.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,16 @@
</h3>
<% if post.user.has_valid_email? %>
<dt><%= User.human_attribute_name :email %></dt>
<dd><%= post.user.email %></dd>
<dd><%= mail_to post.user.email %></dd>
<% end %>
<% phones = [post.user.phone, post.user.alt_phone].select(&:present?) %>
<% if phones.present? %>
<dt><%= User.human_attribute_name(:phone) %></dt>
<dd><%= phones.map(&:to_s).join(" — ") %></dd>
<dd>
<% phones.each do |phone| %>
<span><%= phone_to phone%></span>
<% end %>
</dd>
<% end %>
</div>
</div>
Expand Down
3 changes: 2 additions & 1 deletion app/views/transfers/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
</div>

<div class="form-actions">
<%= f.button :submit, class: "btn btn-default", style: "margin-bottom: 20px;" %>
<%= f.button :submit, class: "btn btn-default" %>
<label class="error invisible"><%= t ".error_amount" %></label>
</div>
<% end %>

Expand Down
4 changes: 2 additions & 2 deletions app/views/users/_member_card.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
<%= member.description&.truncate(124) %>
</div>
<div class="to-member-card__body__items">
<% if member.phone.present? && !member.phone.blank? %>
<% if member.phone.present? %>
<div class="to-member-card__body__item">
<span class="glyphicon glyphicon-earphone"></span>
<%= phone_to member.phone %>
</div>
<% end %>
<% if member.mail_to.present? && !member.mail_to.blank? %>
<% if member.mail_to.present? %>
<div class="to-member-card__body__item">
<span class="glyphicon glyphicon-envelope"></span>
<%= member.mail_to %>
Expand Down
2 changes: 2 additions & 0 deletions config/locales/ca.yml
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,8 @@ ca:
minute:
one: "%{count} minut"
other: "%{count} minuts"
new:
error_amount: El temps ha de ser més gran que 0
users:
edit:
edit_user: Canviar usuari
Expand Down
2 changes: 2 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,8 @@ en:
minute:
one: "%{count} minute"
other: "%{count} minutes"
new:
error_amount: Time must be greater than 0
users:
edit:
edit_user: Update user
Expand Down
2 changes: 2 additions & 0 deletions config/locales/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,8 @@ es:
minute:
one: "%{count} minuto"
other: "%{count} minutos"
new:
error_amount: 'El tiempo debe ser mayor que 0 '
users:
edit:
edit_user: Cambiar usuario
Expand Down
2 changes: 2 additions & 0 deletions config/locales/eu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,8 @@ eu:
minute:
one: "%{count}minutu"
other: "%{count} minutu"
new:
error_amount:
users:
edit:
edit_user: Erabiltzailea aldatu
Expand Down
2 changes: 2 additions & 0 deletions config/locales/pt-BR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,8 @@ pt-BR:
minute:
one: "%{count} minuto"
other: "%{count} minutos"
new:
error_amount:
users:
edit:
edit_user: Trocar usuário
Expand Down
10 changes: 10 additions & 0 deletions db/migrate/20181004200104_add_amount_constraint_to_movements.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class AddAmountConstraintToMovements < ActiveRecord::Migration
def change
# Destroy movements (and parent transfer) with amount equal to 0
Movement.includes(:transfer).where(amount: 0).find_each do |movement|
movement.transfer&.destroy
end

execute 'ALTER TABLE movements ADD CONSTRAINT non_zero_amount CHECK(amount != 0)'
end
end
Loading

0 comments on commit 937b3a2

Please sign in to comment.