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
0
Merge Requests
0
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
Kazuhiko Shiozaki
gitlab-ce
Commits
4ef6ffaa
Commit
4ef6ffaa
authored
Feb 20, 2015
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Split up AttachmentUploader.
parent
c801df81
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
44 additions
and
22 deletions
+44
-22
app/models/group.rb
app/models/group.rb
+1
-1
app/models/project.rb
app/models/project.rb
+1
-1
app/models/user.rb
app/models/user.rb
+1
-1
app/uploaders/attachment_uploader.rb
app/uploaders/attachment_uploader.rb
+0
-10
app/uploaders/avatar_uploader.rb
app/uploaders/avatar_uploader.rb
+32
-0
app/views/events/event/_note.html.haml
app/views/events/event/_note.html.haml
+3
-3
app/views/projects/notes/_note.html.haml
app/views/projects/notes/_note.html.haml
+3
-3
features/steps/groups.rb
features/steps/groups.rb
+1
-1
features/steps/profile/profile.rb
features/steps/profile/profile.rb
+1
-1
features/steps/project/project.rb
features/steps/project/project.rb
+1
-1
No files found.
app/models/group.rb
View file @
4ef6ffaa
...
...
@@ -23,7 +23,7 @@ class Group < Namespace
validate
:avatar_type
,
if:
->
(
user
)
{
user
.
avatar_changed?
}
validates
:avatar
,
file_size:
{
maximum:
200
.
kilobytes
.
to_i
}
mount_uploader
:avatar
,
A
ttachment
Uploader
mount_uploader
:avatar
,
A
vatar
Uploader
after_create
:post_create_hook
after_destroy
:post_destroy_hook
...
...
app/models/project.rb
View file @
4ef6ffaa
...
...
@@ -138,7 +138,7 @@ class Project < ActiveRecord::Base
if:
->
(
project
)
{
project
.
avatar
&&
project
.
avatar_changed?
}
validates
:avatar
,
file_size:
{
maximum:
200
.
kilobytes
.
to_i
}
mount_uploader
:avatar
,
A
ttachment
Uploader
mount_uploader
:avatar
,
A
vatar
Uploader
# Scopes
scope
:sorted_by_activity
,
->
{
reorder
(
last_activity_at: :desc
)
}
...
...
app/models/user.rb
View file @
4ef6ffaa
...
...
@@ -177,7 +177,7 @@ class User < ActiveRecord::Base
end
end
mount_uploader
:avatar
,
A
ttachmentUploa
der
mount_uploader
:avatar
,
A
vatarUplao
der
# Scopes
scope
:admins
,
->
{
where
(
admin:
true
)
}
...
...
app/uploaders/attachment_uploader.rb
View file @
4ef6ffaa
...
...
@@ -3,8 +3,6 @@
class
AttachmentUploader
<
CarrierWave
::
Uploader
::
Base
storage
:file
after
:store
,
:reset_events_cache
def
store_dir
"uploads/
#{
model
.
class
.
to_s
.
underscore
}
/
#{
mounted_as
}
/
#{
model
.
id
}
"
end
...
...
@@ -22,15 +20,7 @@ class AttachmentUploader < CarrierWave::Uploader::Base
false
end
def
secure_url
Gitlab
.
config
.
gitlab
.
relative_url_root
+
"/files/
#{
model
.
class
.
to_s
.
underscore
}
/
#{
model
.
id
}
/
#{
file
.
filename
}
"
end
def
file_storage?
self
.
class
.
storage
==
CarrierWave
::
Storage
::
File
end
def
reset_events_cache
(
file
)
model
.
reset_events_cache
if
model
.
is_a?
(
User
)
end
end
app/uploaders/avatar_uploader.rb
0 → 100644
View file @
4ef6ffaa
# encoding: utf-8
class
AvatarUploader
<
CarrierWave
::
Uploader
::
Base
storage
:file
after
:store
,
:reset_events_cache
def
store_dir
"uploads/
#{
model
.
class
.
to_s
.
underscore
}
/
#{
mounted_as
}
/
#{
model
.
id
}
"
end
def
image?
img_ext
=
%w(png jpg jpeg gif bmp tiff)
if
file
.
respond_to?
(
:extension
)
img_ext
.
include?
(
file
.
extension
.
downcase
)
else
# Not all CarrierWave storages respond to :extension
ext
=
file
.
path
.
split
(
'.'
).
last
.
downcase
img_ext
.
include?
(
ext
)
end
rescue
false
end
def
file_storage?
self
.
class
.
storage
==
CarrierWave
::
Storage
::
File
end
def
reset_events_cache
(
file
)
model
.
reset_events_cache
if
model
.
is_a?
(
User
)
end
end
app/views/events/event/_note.html.haml
View file @
4ef6ffaa
...
...
@@ -18,9 +18,9 @@
-
note
=
event
.
target
-
if
note
.
attachment
.
url
-
if
note
.
attachment
.
image?
=
link_to
note
.
attachment
.
secure_
url
,
target:
'_blank'
do
=
image_tag
note
.
attachment
.
secure_
url
,
class:
'note-image-attach'
=
link_to
note
.
attachment
.
url
,
target:
'_blank'
do
=
image_tag
note
.
attachment
.
url
,
class:
'note-image-attach'
-
else
=
link_to
note
.
attachment
.
secure_
url
,
target:
"_blank"
,
class:
'note-file-attach'
do
=
link_to
note
.
attachment
.
url
,
target:
"_blank"
,
class:
'note-file-attach'
do
%i
.fa.fa-paperclip
=
note
.
attachment_identifier
app/views/projects/notes/_note.html.haml
View file @
4ef6ffaa
...
...
@@ -57,10 +57,10 @@
-
if
note
.
attachment
.
url
.note-attachment
-
if
note
.
attachment
.
image?
=
link_to
note
.
attachment
.
secure_
url
,
target:
'_blank'
do
=
image_tag
note
.
attachment
.
secure_
url
,
class:
'note-image-attach'
=
link_to
note
.
attachment
.
url
,
target:
'_blank'
do
=
image_tag
note
.
attachment
.
url
,
class:
'note-image-attach'
.attachment
=
link_to
note
.
attachment
.
secure_
url
,
target:
"_blank"
do
=
link_to
note
.
attachment
.
url
,
target:
"_blank"
do
%i
.fa.fa-paperclip
=
note
.
attachment_identifier
=
link_to
delete_attachment_project_note_path
(
@project
,
note
),
...
...
features/steps/groups.rb
View file @
4ef6ffaa
...
...
@@ -110,7 +110,7 @@ class Spinach::Features::Groups < Spinach::FeatureSteps
end
step
'I should see new group "Owned" avatar'
do
Group
.
find_by
(
name:
"Owned"
).
avatar
.
should
be_instance_of
A
ttachment
Uploader
Group
.
find_by
(
name:
"Owned"
).
avatar
.
should
be_instance_of
A
vatar
Uploader
Group
.
find_by
(
name:
"Owned"
).
avatar
.
url
.
should
==
"/uploads/group/avatar/
#{
Group
.
find_by
(
name
:"Owned"
).
id
}
/gitlab_logo.png"
end
...
...
features/steps/profile/profile.rb
View file @
4ef6ffaa
...
...
@@ -29,7 +29,7 @@ class Spinach::Features::Profile < Spinach::FeatureSteps
end
step
'I should see new avatar'
do
@user
.
avatar
.
should
be_instance_of
A
ttachment
Uploader
@user
.
avatar
.
should
be_instance_of
A
vatar
Uploader
@user
.
avatar
.
url
.
should
==
"/uploads/user/avatar/
#{
@user
.
id
}
/gitlab_logo.png"
end
...
...
features/steps/project/project.rb
View file @
4ef6ffaa
...
...
@@ -35,7 +35,7 @@ class Spinach::Features::Project < Spinach::FeatureSteps
end
step
'I should see new project avatar'
do
@project
.
avatar
.
should
be_instance_of
A
ttachment
Uploader
@project
.
avatar
.
should
be_instance_of
A
vatar
Uploader
url
=
@project
.
avatar
.
url
url
.
should
==
"/uploads/project/avatar/
#{
@project
.
id
}
/gitlab_logo.png"
end
...
...
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