app/controllers/checkouts_controller.rb in enju_circulation-0.1.0.pre41 vs app/controllers/checkouts_controller.rb in enju_circulation-0.1.0.pre42
- old
+ new
@@ -33,11 +33,11 @@
if @user
user = @user
if current_user.try(:has_role?, 'Librarian')
search.build do
with(:username).equal_to user.username
- with(:checked_in_at).equal_to nil unless user.save_checkout_history
+ with(:checked_in_at).equal_to nil unless user.profile.save_checkout_history
end
else
if current_user == user
redirect_to checkouts_url(format: params[:format])
return
@@ -51,12 +51,14 @@
search.build do
with(:username).equal_to current_user.username
end
end
- search.build do
- with(:checked_in_at).equal_to nil
+ unless current_user.profile.save_checkout_history?
+ search.build do
+ with(:checked_in_at).equal_to nil
+ end
end
end
if current_user.try(:has_role?, 'Librarian')
if @item
@@ -131,11 +133,11 @@
end
# PUT /checkouts/1
# PUT /checkouts/1.json
def update
- @checkout.assign_attributes(params[:checkout])
+ @checkout.assign_attributes(checkout_params)
@checkout.due_date = @checkout.due_date.end_of_day
@checkout.checkout_renewal_count += 1
respond_to do |format|
if @checkout.save
@@ -174,7 +176,12 @@
respond_to do |format|
format.html { redirect_to checkouts_url, notice: t('controller.successfully_deleted', model: t('activerecord.models.checkout')) }
format.json { head :no_content }
end
+ end
+
+ private
+ def checkout_params
+ params.fetch(:checkout, {}).permit(:due_date)
end
end