Skip to content

Commit d9fc47d

Browse files
committed
Merge branch 'main' into release
2 parents 064c20a + 05865db commit d9fc47d

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

server/app/admin/users_admin.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@
77
item :users, icon: "fa fa-user"
88
end
99

10+
scopes do
11+
User.roles.keys.each do |role|
12+
scope role.capitalize.pluralize, -> { User.where(role: role) }
13+
end
14+
scope "Admins and Editors", -> { User.where(role: ['admin', 'editor']) }
15+
end
16+
1017
search do |q|
1118
q ? collection.where("username ILIKE ? OR name ILIKE ?", "%#{q}%", "%#{q}%") : collection
1219
end

server/app/graphql/types/browse_tables/browse_user_type.rb

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ module Types::BrowseTables
22
class BrowseUserType < Types::Entities::UserType
33
connection_type_class(Types::Connections::BrowseTableConnection)
44

5-
@@role_mapping = User.roles.invert
65
@@area_mapping = User.area_of_expertises.invert
76

87
field :revision_count, Int, null: false
@@ -12,10 +11,6 @@ def area_of_expertise
1211
@@area_mapping[object.area_of_expertise]
1312
end
1413

15-
def role
16-
@@role_mapping[object.role]
17-
end
18-
1914
def organizations
2015
Loaders::AssociationLoader.for(MaterializedViews::UserBrowseTableRow, :affiliations).load(object).then do |affil|
2116
affil.map do |a|
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
class MaterializedViews::UserBrowseTableRow < MaterializedViews::MaterializedView
22
has_many :affiliations, primary_key: :id, foreign_key: :user_id
33
has_many :organizations, through: :affiliations
4+
5+
enum role: ['curator', 'editor', 'admin']
46
end

0 commit comments

Comments
 (0)