Skip to content

Commit

Permalink
Merge pull request #14933 from eduardoj/feature/add_moderator_role
Browse files Browse the repository at this point in the history
Add role "Moderator" to roles table
  • Loading branch information
danidoni committed Sep 21, 2023
2 parents 7b8768a + 0028669 commit 202c98b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/api/app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class User < ApplicationRecord
scope :staff, -> { joins(:roles).where('roles.title' => 'Staff') }
scope :not_staff, -> { where.not(id: User.unscoped.staff.pluck(:id)) }
scope :admins, -> { joins(:roles).where('roles.title' => 'Admin') }
scope :moderators, -> { joins(:roles).where('roles.title' => 'Moderator') }

scope :in_beta, -> { where(in_beta: true) }
scope :in_rollout, -> { where(in_rollout: true) }
Expand Down
11 changes: 11 additions & 0 deletions src/api/db/data/20230920125132_add_moderator_to_roles.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# frozen_string_literal: true

class AddModeratorToRoles < ActiveRecord::Migration[7.0]
def up
Role.where(title: 'Moderator', global: true).first_or_create
end

def down
Role.find_by(title: 'Moderator', global: true).destroy
end
end
2 changes: 1 addition & 1 deletion src/api/db/data_schema.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
DataMigrate::Data.define(version: 20230623122537)
DataMigrate::Data.define(version: 20230920125132)
1 change: 1 addition & 0 deletions src/api/db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
downloader_role = Role.where(title: 'downloader').first_or_create
reader_role = Role.where(title: 'reader').first_or_create
Role.where(title: 'Staff').first_or_create(global: true)
Role.where(title: 'Moderator').first_or_create(global: true)

puts 'Seeding users table...'
admin = User.where(login: 'Admin').first_or_create(login: 'Admin', email: 'root@localhost',
Expand Down

0 comments on commit 202c98b

Please sign in to comment.