SU2-33 | Фикс критических и серьёзных ошибок, удаление/перезагрузка организации, пагинация, favicon
This commit is contained in:
@@ -28,18 +28,13 @@ module Authorization
|
||||
session['cas'] && session['cas']['user']
|
||||
end
|
||||
|
||||
def set_current_user(options = {})
|
||||
return nil if current_login.blank?
|
||||
load_current_user
|
||||
end
|
||||
|
||||
def load_current_user
|
||||
@current_user ||= User.where('lower(login) = lower(?)', current_login).first
|
||||
end
|
||||
|
||||
def check_authentication
|
||||
if session.blank? || session['cas'].blank? || session['cas']['user'].blank? ||
|
||||
(request.get? && !request.xhr? && request.xhr? != 0 && (session['cas']['last_validated_at'].blank? || session['cas']['last_validated_at'] < 15.minutes.ago))
|
||||
(request.get? && !request.xhr? && (session['cas']['last_validated_at'].blank? || session['cas']['last_validated_at'] < 15.minutes.ago))
|
||||
render plain: 'Требуется авторизация', status: 401
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class OrganisationsController < ApplicationController
|
||||
before_action :set_organisation, only: [:show]
|
||||
before_action :set_organisation, only: [:show, :destroy, :reload]
|
||||
|
||||
DOC_TYPES = {
|
||||
0 => { title: 'Бухгалтерский баланс', form_code: '1.1' },
|
||||
@@ -9,7 +9,7 @@ class OrganisationsController < ApplicationController
|
||||
}.freeze
|
||||
|
||||
def index
|
||||
organizations = Organization.all
|
||||
@pagy, organizations = pagy(Organization.order(:created_at))
|
||||
|
||||
@info_about_organisations = organizations.each_with_object({}) do |org, hash|
|
||||
hash[org.id] = {
|
||||
@@ -42,6 +42,17 @@ class OrganisationsController < ApplicationController
|
||||
end
|
||||
|
||||
|
||||
def destroy
|
||||
@org.destroy!
|
||||
redirect_to '/organisations/index', notice: "Организация #{@org.inn} удалена"
|
||||
end
|
||||
|
||||
def reload
|
||||
report = Report.create!(inn: @org.inn, status: 'processing')
|
||||
FileProcessorJob.perform_async(@org.inn, report.id)
|
||||
redirect_to "/organisations/#{@org.id}", notice: 'Данные обновляются в фоне'
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_organisation
|
||||
|
||||
@@ -4,9 +4,13 @@ class ReportsController < ApplicationController
|
||||
end
|
||||
|
||||
def create
|
||||
inn = params[:inn]
|
||||
report = Report.create!(inn: inn, status: 'processing')
|
||||
inn = params[:inn].to_s.strip
|
||||
unless inn.match?(/\A\d{10}(\d{2})?\z/)
|
||||
redirect_to reports_path, alert: 'Некорректный ИНН (должен содержать 10 или 12 цифр)'
|
||||
return
|
||||
end
|
||||
|
||||
report = Report.create!(inn: inn, status: 'processing')
|
||||
FileProcessorJob.perform_async(inn, report.id)
|
||||
|
||||
redirect_to reports_path, notice: 'Отчёт загружается в фоне'
|
||||
|
||||
Reference in New Issue
Block a user