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
259c23dd
Commit
259c23dd
authored
Nov 23, 2016
by
Gabriel Mazetto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor to remove duplicated code in Geo aware avatars
parent
b31462ae
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
18 additions
and
30 deletions
+18
-30
app/models/ee/geo_aware_avatar.rb
app/models/ee/geo_aware_avatar.rb
+15
-0
app/models/ee/group.rb
app/models/ee/group.rb
+0
-12
app/models/ee/project.rb
app/models/ee/project.rb
+0
-16
app/models/group.rb
app/models/group.rb
+1
-0
app/models/project.rb
app/models/project.rb
+1
-1
app/models/user.rb
app/models/user.rb
+1
-1
No files found.
app/models/ee/
use
r.rb
→
app/models/ee/
geo_aware_avata
r.rb
View file @
259c23dd
module
EE
#
User EE
mixin
#
Avatars in Geo
mixin
#
# This module is intended to encapsulate
EE-specific model
logic
# and be **prepended** in the `
User` model
module
Use
r
def
avatar_url
(
size
=
nil
,
scale
=
2
)
# This module is intended to encapsulate
Geo-specific
logic
# and be **prepended** in the `
Group`, `User`, `Project` models
module
GeoAwareAvata
r
def
avatar_url
(
size
=
nil
)
if
self
[
:avatar
].
present?
&&
::
Gitlab
::
Geo
.
secondary?
File
.
join
(
::
Gitlab
::
Geo
.
primary_node
.
url
,
avatar
.
url
)
else
super
super
()
end
end
end
...
...
app/models/ee/group.rb
View file @
259c23dd
...
...
@@ -7,8 +7,6 @@ module EE
extend
ActiveSupport
::
Concern
included
do
prepend
GeoFeatures
state_machine
:ldap_sync_status
,
namespace: :ldap_sync
,
initial: :ready
do
state
:ready
state
:started
...
...
@@ -57,15 +55,5 @@ module EE
fail_ldap_sync
update_column
(
:ldap_sync_error
,
::
Gitlab
::
UrlSanitizer
.
sanitize
(
error_message
))
end
module
GeoFeatures
def
avatar_url
(
size
=
nil
)
if
self
[
:avatar
].
present?
&&
::
Gitlab
::
Geo
.
secondary?
File
.
join
(
::
Gitlab
::
Geo
.
primary_node
.
url
,
avatar
.
url
)
else
super
end
end
end
end
end
app/models/ee/project.rb
deleted
100644 → 0
View file @
b31462ae
module
EE
# Project EE mixin
#
# This module is intended to encapsulate EE-specific model logic
# and be **prepended** in the `Project` model
module
Project
# Display correct avatar in a secondary Geo node
def
avatar_url
if
self
[
:avatar
].
present?
&&
::
Gitlab
::
Geo
.
secondary?
File
.
join
(
::
Gitlab
::
Geo
.
primary_node
.
url
,
avatar
.
url
)
else
super
end
end
end
end
app/models/group.rb
View file @
259c23dd
...
...
@@ -9,6 +9,7 @@ class Group < Namespace
include
AccessRequestable
include
Referable
include
SelectForProjectAuthorization
prepend
EE
::
GeoAwareAvatar
has_many
:group_members
,
->
{
where
(
requested_at:
nil
)
},
dependent: :destroy
,
as: :source
alias_method
:members
,
:group_members
...
...
app/models/project.rb
View file @
259c23dd
...
...
@@ -15,7 +15,7 @@ class Project < ActiveRecord::Base
include
Elastic
::
ProjectsSearch
include
ProjectFeaturesCompatibility
include
SelectForProjectAuthorization
prepend
EE
::
Project
prepend
EE
::
GeoAwareAvatar
extend
Gitlab
::
ConfigHelper
...
...
app/models/user.rb
View file @
259c23dd
...
...
@@ -9,7 +9,7 @@ class User < ActiveRecord::Base
include
Sortable
include
CaseSensitivity
include
TokenAuthenticatable
prepend
EE
::
Use
r
prepend
EE
::
GeoAwareAvata
r
DEFAULT_NOTIFICATION_LEVEL
=
:participating
...
...
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