mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-25 09:13:05 +08:00
Fix seeds to work with new UserRoles, fix Templates creation job [SCI-6270]
This commit is contained in:
parent
22623c821d
commit
2e92500a73
4 changed files with 8 additions and 2 deletions
|
@ -29,7 +29,7 @@ module Api
|
|||
project = @team.projects.build(project_params.merge!(created_by: current_user))
|
||||
|
||||
if project.visible? # set default viewer role for public projects
|
||||
project.default_public_user_role = UserRole.find_by(name: I18n.t('user_roles.predefined.viewer'))
|
||||
project.default_public_user_role = UserRole.predefined.find_by(name: I18n.t('user_roles.predefined.viewer'))
|
||||
end
|
||||
|
||||
project.save!
|
||||
|
|
|
@ -15,6 +15,8 @@ class UserRole < ApplicationRecord
|
|||
belongs_to :last_modified_by, class_name: 'User', optional: true
|
||||
has_many :user_assignments, dependent: :destroy
|
||||
|
||||
scope :predefined, -> { where(predefined: true) }
|
||||
|
||||
def self.owner_role
|
||||
new(
|
||||
name: I18n.t('user_roles.predefined.owner'),
|
||||
|
|
|
@ -21,9 +21,9 @@ class TemplatesService
|
|||
name: Constants::TEMPLATES_PROJECT_NAME,
|
||||
visibility: :visible,
|
||||
template: true,
|
||||
default_public_user_role: UserRole.predefined.find_by(name: I18n.t('user_roles.predefined.viewer')),
|
||||
created_by: team.created_by
|
||||
)
|
||||
tmpl_project.user_projects.create!(user: team.created_by, role: 'owner')
|
||||
end
|
||||
end
|
||||
owner = tmpl_project.user_projects
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
include UsersGenerator
|
||||
|
||||
if ActiveRecord::Base.connection.migration_context.needs_migration?
|
||||
raise "There are pending migrations. Run 'rails db:migrate' first."
|
||||
end
|
||||
|
||||
MyModuleStatusFlow.ensure_default
|
||||
|
||||
if User.count.zero?
|
||||
|
|
Loading…
Reference in a new issue