fixes #611
This commit is contained in:
@@ -16,7 +16,7 @@ class Upload < ActiveRecord::Base
|
|||||||
module ValidationMethods
|
module ValidationMethods
|
||||||
def uploader_is_not_limited
|
def uploader_is_not_limited
|
||||||
if !uploader.can_upload?
|
if !uploader.can_upload?
|
||||||
raise Error.new("uploader has reached their daily limit")
|
raise Error.new(uploader.upload_limited_reason)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -375,6 +375,16 @@ class User < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def upload_limited_reason
|
||||||
|
if created_at > 1.week.ago
|
||||||
|
"You cannot upload during your first week of registration"
|
||||||
|
elsif upload_limit <= 0
|
||||||
|
"You can only upload #{upload_limit} posts a day"
|
||||||
|
else
|
||||||
|
nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def can_comment?
|
def can_comment?
|
||||||
if is_privileged?
|
if is_privileged?
|
||||||
true
|
true
|
||||||
|
|||||||
Reference in New Issue
Block a user