Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
cleaning-portalmec
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Richard Fernando Heise Ferreira
cleaning-portalmec
Commits
e19dd96e
Commit
e19dd96e
authored
7 years ago
by
Clarissa
Browse files
Options
Downloads
Patches
Plain Diff
#204: creating moderator role and adding to user
parent
25bcb9fb
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
app/models/role.rb
+4
-0
4 additions, 0 deletions
app/models/role.rb
app/models/user.rb
+11
-0
11 additions, 0 deletions
app/models/user.rb
db/seeds.rb
+1
-0
1 addition, 0 deletions
db/seeds.rb
lib/portalmec/sociable_tests.rb
+2
-0
2 additions, 0 deletions
lib/portalmec/sociable_tests.rb
with
18 additions
and
0 deletions
app/models/role.rb
+
4
−
0
View file @
e19dd96e
...
...
@@ -29,4 +29,8 @@ class Role < ApplicationRecord
def
self
.
curator
find_by
(
name:
'curator'
)
||
create!
(
name:
'curator'
)
end
def
self
.
moderator
find_by
(
name:
'moderator'
)
||
create!
(
name:
'moderator'
)
end
end
This diff is collapsed.
Click to expand it.
app/models/user.rb
+
11
−
0
View file @
e19dd96e
...
...
@@ -100,6 +100,17 @@ class User < ApplicationRecord
false
end
def
is_moderator?
roles
.
each
do
|
role
|
return
true
if
role
.
name
==
'moderator'
end
false
end
def
can_moderate?
self
.
is_admin?
||
self
.
is_moderator?
end
def
associated_collections
c
=
collections
.
blank?
?
[]
:
collections
.
to_a
institutions
.
each
{
|
i
|
c
.
push
(
*
i
.
collections
.
to_a
)
}
...
...
This diff is collapsed.
Click to expand it.
db/seeds.rb
+
1
−
0
View file @
e19dd96e
...
...
@@ -9,6 +9,7 @@ Role.create(name: 'teacher', description: 'This role represents a Teacher in Por
Role
.
create
(
name:
'student'
,
description:
'This role represents a Student in Portal MEC.'
)
Role
.
create
(
name:
'admin'
,
description:
'This role represents an MEC Admin, that can perform any action.'
)
Role
.
create
(
name:
'curator'
,
description:
'This role represents a content Curator in Portal MEC.'
)
Role
.
create
(
name:
'moderator'
,
description:
'This role represents a content Moderator in Portal MEC, with less privileges than admin.'
)
# create the default admin
User
.
create
(
...
...
This diff is collapsed.
Click to expand it.
lib/portalmec/sociable_tests.rb
+
2
−
0
View file @
e19dd96e
require
'active_support'
module
Portalmec::SociableTests
extend
ActiveSupport
::
Testing
::
Declarative
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment