diff --git a/app/channels/api_channel.rb b/app/channels/api_channel.rb index 2e3746e9..697eb78c 100644 --- a/app/channels/api_channel.rb +++ b/app/channels/api_channel.rb @@ -153,6 +153,8 @@ def finish data dispatch_all 'comments/load', Comment.includes(:user).where(task_id:) dispatch_all 'app/finish' + dispatch_self 'notifications/push', kind: 'info', message: 'Calculating results …' + users_without_result = [] begin result_multiplier = Rational task.result_multiplier @@ -171,6 +173,8 @@ def finish data task.update_column :scoring_open, true dispatch_self 'app/ready', ready_info raise e + else + dispatch_self 'notifications/push', kind: 'success', message: 'Results calculated' end end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index ea92b862..65bf441e 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -22,7 +22,8 @@ def collection end def resource_params - params.require(:user).permit(PERMITTED_PARAMS).merge(registration_ips: ip_addresses, device_id: @device_id) + params.require(:user).permit(PERMITTED_PARAMS) + .merge(registration_ips: ip_addresses, device_id: @device_id, registration_secret_required: true) end def initialize_resource diff --git a/app/models/user.rb b/app/models/user.rb index ad705182..a83e4e1c 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,10 +1,13 @@ class User < ApplicationRecord - attr_accessor :registration_secret + attr_accessor :registration_secret, :registration_secret_required validates :name, :email, :city, :institution, :contest_site, :grade, presence: true validates :name, :secret, :judge_secret, uniqueness: { scope: :contest } - validates :registration_secret, presence: true, on: :create - validate :registration_secret_must_be_valid, on: :create + + with_options if: :registration_secret_required, on: :create do + validates :registration_secret, presence: true + validate :registration_secret_must_be_valid + end belongs_to :contest, inverse_of: :users has_many :solutions, inverse_of: :user, dependent: :destroy diff --git a/config/initializers/rails_admin.rb b/config/initializers/rails_admin.rb index 8864509f..93efc583 100644 --- a/config/initializers/rails_admin.rb +++ b/config/initializers/rails_admin.rb @@ -78,10 +78,18 @@ config.model 'Task' do |_config| configure :file_names, :pg_string_array configure :judges, :pg_string_array + configure(:solutions) { hide } + configure(:results) { hide } + configure(:criterions) { hide } + configure(:comments) { hide } end config.model 'User' do |_config| configure :registration_ips, :pg_inet_array + configure(:solutions) { hide } + configure(:results) { hide } + configure(:comments) { hide } + configure(:criterion_user_results) { hide } end config.model 'Solution' do |_config| @@ -92,5 +100,12 @@ configure :cities, :pg_string_array configure :institutions, :pg_string_array configure :contest_sites, :pg_string_array + configure(:tasks) { hide } + configure(:users) { hide } + configure(:solutions) { hide } + end + + config.model 'Criterion' do |_config| + configure(:criterion_user_results) { hide } end end