Fix reviewers errors

This commit is contained in:
Jure Grabnar 2018-10-15 14:25:12 +02:00
parent 6b47165ac1
commit ed16e8d479
4 changed files with 9 additions and 11 deletions

View file

@ -5,7 +5,7 @@ class TeamsController < ApplicationController
before_action :check_create_samples_permissions, only: %i(parse_sheet
import_samples)
before_action :check_view_samples_permission, only: [:export_samples]
before_action :check_export_projects_permissions, only: [:export_projects]
before_action :check_export_projects_permissions, only: :export_projects
def parse_sheet
session[:return_to] ||= request.referer
@ -228,8 +228,9 @@ class TeamsController < ApplicationController
def export_projects
if export_projects_params[:project_ids]
# Check if user has enough requests for the day
limit = ENV['EXPORT_ALL_LIMIT_24_HOURS'].to_i || 3
if current_user.export_vars['num_of_export_all_last_24_hours'] >= limit
limit = (ENV['EXPORT_ALL_LIMIT_24_HOURS'] || 3).to_i
if limit.zero? \
|| current_user.export_vars['num_of_export_all_last_24_hours'] >= limit
render json: {
html: render_to_string(
partial: 'projects/export/error.html.erb',
@ -254,11 +255,7 @@ class TeamsController < ApplicationController
title: t('projects.export_projects.modal_title_success')
}
end
return
else
flash[:alert] = t('zip_export.export_error')
end
redirect_back(fallback_location: root_path)
end
def routing_error(error = 'Routing error', status = :not_found, exception=nil)

View file

@ -2,5 +2,5 @@
It looks like you have exceeded your daily export limit. The number of exports is <strong>limited to <%= limit %> requests per day </strong>- you currently have 0 export requests left.
</p>
<p>Please repeat the desired action <strong>tomorrow</strong>, when your daily limit will rise back to <%= limit %> export requests.
<p>Please repeat the desired action <strong>tomorrow</strong>, when your daily limit will reset back to <%= limit %> export requests.
</p>

View file

@ -88,7 +88,7 @@
<div class="modal-body">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal"><%=t "general.cancel" %></button>
<button type="button" class="btn btn-default" data-dismiss="modal"><%=t "general.close" %></button>
</div>
</div>
</div>

View file

@ -9,7 +9,7 @@ namespace :exportable_items do
desc 'Resets export project counter to 0'
task reset_export_projects_counter: :environment do
User.all.each do |user|
User.find_each do |user|
User.transaction do
begin
user.export_vars['num_of_export_all_last_24_hours'] = 0
@ -17,7 +17,8 @@ namespace :exportable_items do
rescue ActiveRecord::ActiveRecordError,
ArgumentError,
ActiveRecord::RecordNotSaved => e
puts "Error creating user, transaction reverted: #{e}"
puts "Error resetting users num_of_export_all_last_24_hours " \
"variable to 0, transaction reverted: #{e}"
end
end
end