Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
fe514b17
Commit
fe514b17
authored
Jun 21, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding groups to notification settings
parent
f3cbbfe0
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
68 additions
and
47 deletions
+68
-47
app/controllers/notifications_controller.rb
app/controllers/notifications_controller.rb
+5
-0
app/models/users_group.rb
app/models/users_group.rb
+2
-0
app/models/users_project.rb
app/models/users_project.rb
+1
-5
app/services/notification_service.rb
app/services/notification_service.rb
+11
-6
app/views/notifications/_settings.html.haml
app/views/notifications/_settings.html.haml
+29
-0
app/views/notifications/show.html.haml
app/views/notifications/show.html.haml
+13
-30
db/schema.rb
db/schema.rb
+7
-6
No files found.
app/controllers/notifications_controller.rb
View file @
fe514b17
...
...
@@ -4,6 +4,7 @@ class NotificationsController < ApplicationController
def
show
@notification
=
current_user
.
notification
@users_projects
=
current_user
.
users_projects
@users_groups
=
current_user
.
users_groups
end
def
update
...
...
@@ -12,6 +13,10 @@ class NotificationsController < ApplicationController
@saved
=
if
type
==
'global'
current_user
.
notification_level
=
params
[
:notification_level
]
current_user
.
save
elsif
type
==
'group'
users_group
=
current_user
.
users_groups
.
find
(
params
[
:notification_id
])
users_group
.
notification_level
=
params
[
:notification_level
]
users_group
.
save
else
users_project
=
current_user
.
users_projects
.
find
(
params
[
:notification_id
])
users_project
.
notification_level
=
params
[
:notification_level
]
...
...
app/models/users_group.rb
View file @
fe514b17
...
...
@@ -11,6 +11,8 @@
#
class
UsersGroup
<
ActiveRecord
::
Base
include
Notifiable
GUEST
=
10
REPORTER
=
20
DEVELOPER
=
30
...
...
app/models/users_project.rb
View file @
fe514b17
...
...
@@ -13,6 +13,7 @@
class
UsersProject
<
ActiveRecord
::
Base
include
Gitlab
::
ShellAdapter
include
Notifiable
GUEST
=
10
REPORTER
=
20
...
...
@@ -30,7 +31,6 @@ class UsersProject < ActiveRecord::Base
validates
:user_id
,
uniqueness:
{
scope:
[
:project_id
],
message:
"already exists in project"
}
validates
:project_access
,
inclusion:
{
in:
[
GUEST
,
REPORTER
,
DEVELOPER
,
MASTER
]
},
presence:
true
validates
:project
,
presence:
true
validates
:notification_level
,
inclusion:
{
in:
Notification
.
project_notification_levels
},
presence:
true
delegate
:name
,
:username
,
:email
,
to: :user
,
prefix:
true
...
...
@@ -134,8 +134,4 @@ class UsersProject < ActiveRecord::Base
def
skip_git?
!!
@skip_git
end
def
notification
@notification
||=
Notification
.
new
(
self
)
end
end
app/services/notification_service.rb
View file @
fe514b17
...
...
@@ -148,13 +148,18 @@ class NotificationService
# Get project users with WATCH notification level
def
project_watchers
(
project
)
# Get project notification settings since it has higher priority
user_ids
=
project
.
users_projects
.
where
(
notification_level:
Notification
::
N_WATCH
).
pluck
(
:user_id
)
project_watchers
=
User
.
where
(
id:
user_ids
)
member_methods
=
[
:users_projects
]
member_methods
<<
:users_groups
if
project
.
group
# next collect users who use global settings with watch state
user_ids
=
project
.
users_projects
.
where
(
notification_level:
Notification
::
N_GLOBAL
).
pluck
(
:user_id
)
project_watchers
+=
User
.
where
(
id:
user_ids
,
notification_level:
Notification
::
N_WATCH
)
member_methods
.
each
do
|
member_method
|
# Get project notification settings since it has higher priority
user_ids
=
project
.
send
(
member_method
).
where
(
notification_level:
Notification
::
N_WATCH
).
pluck
(
:user_id
)
project_watchers
=
User
.
where
(
id:
user_ids
)
# next collect users who use global settings with watch state
user_ids
=
project
.
send
(
member_method
).
where
(
notification_level:
Notification
::
N_GLOBAL
).
pluck
(
:user_id
)
project_watchers
+=
User
.
where
(
id:
user_ids
,
notification_level:
Notification
::
N_WATCH
)
end
project_watchers
.
uniq
end
...
...
app/views/notifications/_settings.html.haml
0 → 100644
View file @
fe514b17
%li
.row
.span4
%span
-
if
membership
.
kind_of?
UsersGroup
=
link_to
membership
.
group
.
name
,
membership
.
group
-
else
=
link_to_project
(
membership
.
project
)
.span7
=
form_tag
profile_notifications_path
,
method: :put
,
remote:
true
,
class:
'update-notifications'
do
=
hidden_field_tag
:notification_type
,
type
,
id:
dom_id
(
membership
,
'notification_type'
)
=
hidden_field_tag
:notification_id
,
membership
.
id
,
id:
dom_id
(
membership
,
'notification_id'
)
=
label_tag
do
=
radio_button_tag
:notification_level
,
Notification
::
N_GLOBAL
,
notification
.
global?
,
id:
dom_id
(
membership
,
'notification_level'
),
class:
'trigger-submit'
%span
Use global setting
=
label_tag
do
=
radio_button_tag
:notification_level
,
Notification
::
N_DISABLED
,
notification
.
disabled?
,
id:
dom_id
(
membership
,
'notification_level'
),
class:
'trigger-submit'
%span
Disabled
=
label_tag
do
=
radio_button_tag
:notification_level
,
Notification
::
N_PARTICIPATING
,
notification
.
participating?
,
id:
dom_id
(
membership
,
'notification_level'
),
class:
'trigger-submit'
%span
Participating
=
label_tag
do
=
radio_button_tag
:notification_level
,
Notification
::
N_WATCH
,
notification
.
watch?
,
id:
dom_id
(
membership
,
'notification_level'
),
class:
'trigger-submit'
%span
Watch
app/views/notifications/show.html.haml
View file @
fe514b17
...
...
@@ -36,36 +36,19 @@
=
link_to
'#'
,
class:
'js-toggle-visibility-link'
do
%h6
.btn.btn-tiny
%i
.icon-chevron-down
%span
Per project notifications setting
%ul
.well-list.js-toggle-visibility-container.hide
-
@users_projects
.
each
do
|
users_project
|
-
notification
=
Notification
.
new
(
users_project
)
%li
.row
.span4
%span
=
link_to_project
(
users_project
.
project
)
.span7
=
form_tag
profile_notifications_path
,
method: :put
,
remote:
true
,
class:
'update-notifications'
do
=
hidden_field_tag
:notification_type
,
'project'
,
id:
dom_id
(
users_project
,
'notification_type'
)
=
hidden_field_tag
:notification_id
,
users_project
.
id
,
id:
dom_id
(
users_project
,
'notification_id'
)
=
label_tag
do
=
radio_button_tag
:notification_level
,
Notification
::
N_GLOBAL
,
notification
.
global?
,
id:
dom_id
(
users_project
,
'notification_level'
),
class:
'trigger-submit'
%span
Use global setting
=
label_tag
do
=
radio_button_tag
:notification_level
,
Notification
::
N_DISABLED
,
notification
.
disabled?
,
id:
dom_id
(
users_project
,
'notification_level'
),
class:
'trigger-submit'
%span
Disabled
=
label_tag
do
=
radio_button_tag
:notification_level
,
Notification
::
N_PARTICIPATING
,
notification
.
participating?
,
id:
dom_id
(
users_project
,
'notification_level'
),
class:
'trigger-submit'
%span
Participating
=
label_tag
do
=
radio_button_tag
:notification_level
,
Notification
::
N_WATCH
,
notification
.
watch?
,
id:
dom_id
(
users_project
,
'notification_level'
),
class:
'trigger-submit'
%span
Watch
%span
Advanced notifications settings
.js-toggle-visibility-container.hide
%h5
Groups:
%ul
.well-list
-
@users_groups
.
each
do
|
users_group
|
-
notification
=
Notification
.
new
(
users_group
)
=
render
'settings'
,
type:
'project'
,
membership:
users_group
,
notification:
notification
%h5
Projects:
%ul
.well-list
-
@users_projects
.
each
do
|
users_project
|
-
notification
=
Notification
.
new
(
users_project
)
=
render
'settings'
,
type:
'project'
,
membership:
users_project
,
notification:
notification
.save-status-fixed
...
...
db/schema.rb
View file @
fe514b17
...
...
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
:version
=>
201306
1709560
3
)
do
ActiveRecord
::
Schema
.
define
(
:version
=>
201306
2119522
3
)
do
create_table
"deploy_keys_projects"
,
:force
=>
true
do
|
t
|
t
.
integer
"deploy_key_id"
,
:null
=>
false
...
...
@@ -301,11 +301,12 @@ ActiveRecord::Schema.define(:version => 20130617095603) do
add_index
"users"
,
[
"username"
],
:name
=>
"index_users_on_username"
create_table
"users_groups"
,
:force
=>
true
do
|
t
|
t
.
integer
"group_access"
,
:null
=>
false
t
.
integer
"group_id"
,
:null
=>
false
t
.
integer
"user_id"
,
:null
=>
false
t
.
datetime
"created_at"
,
:null
=>
false
t
.
datetime
"updated_at"
,
:null
=>
false
t
.
integer
"group_access"
,
:null
=>
false
t
.
integer
"group_id"
,
:null
=>
false
t
.
integer
"user_id"
,
:null
=>
false
t
.
datetime
"created_at"
,
:null
=>
false
t
.
datetime
"updated_at"
,
:null
=>
false
t
.
integer
"notification_level"
,
:default
=>
3
,
:null
=>
false
end
create_table
"users_projects"
,
:force
=>
true
do
|
t
|
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment