Put confirmation and maximum limit on transaction amount
This commit is contained in:
parent
4faf3e36ab
commit
53f1a0a44f
5 changed files with 17 additions and 3 deletions
|
@ -70,6 +70,17 @@ ready = function() {
|
|||
});
|
||||
filters_body.hide();
|
||||
|
||||
$(form).submit(function(e) {
|
||||
euros = parseInt($(form).find('input[name="transaction[euros]"]').val());
|
||||
console.log(euros);
|
||||
if (euros < 6) {
|
||||
return true;
|
||||
} else {
|
||||
e.preventDefault();
|
||||
return confirm("Are you sure? " + euros + " monies is a lot of money ...");
|
||||
}
|
||||
});
|
||||
|
||||
$(form).on("ajax:before", function(xhr, settings) {
|
||||
$(flash_success).addClass("hidden");
|
||||
$(submit_button).val("Processing");
|
||||
|
|
|
@ -7,7 +7,7 @@ class UsersController < ApplicationController
|
|||
load_and_authorize_resource except: :show
|
||||
|
||||
def show
|
||||
@user = User.find_or_create_by(name: params[:id])
|
||||
@user = User.find_by(name: params[:id])
|
||||
respond_to do |format|
|
||||
format.html { @transaction = Transaction.new }
|
||||
format.json { render json: @user }
|
||||
|
|
|
@ -6,6 +6,8 @@ class UserAbility
|
|||
|
||||
can :manage, :all if user.penning?
|
||||
can :read, user, id: user.id
|
||||
can :create, Transaction, debtor: user
|
||||
can :create, Transaction do |t|
|
||||
t.debtor == user && t.amount <= Rails.application.config.maximum_amount
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -14,5 +14,5 @@
|
|||
%span.glyphicon.glyphicon-euro
|
||||
= f.number_field :euros, value: amount(@transaction.amount),
|
||||
placeholder: "Bedrag", step: 0.01, min: (0.01 unless current_user.penning),
|
||||
class: "form-control", size: 20, max: 100, required: true
|
||||
class: "form-control", size: 20, max: Rails.application.config.maximum_amount/100, required: true
|
||||
= f.submit "Send it!", class: "pure-button pure-button-primary btn"
|
||||
|
|
|
@ -25,5 +25,6 @@ module Tab
|
|||
|
||||
# Which is the lowest balance you should be ashamed of.
|
||||
config.shameful_balance = 5000 # In eurocents!
|
||||
config.maximum_amount = 3000
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue