From c43ae62cdf47dd777e97c4594223187f75f2f74e Mon Sep 17 00:00:00 2001 From: albert Date: Sun, 24 Feb 2013 11:45:23 -0500 Subject: [PATCH] fixes #611 --- app/models/upload.rb | 2 +- app/models/user.rb | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app/models/upload.rb b/app/models/upload.rb index cd2523601..2b886398b 100644 --- a/app/models/upload.rb +++ b/app/models/upload.rb @@ -16,7 +16,7 @@ class Upload < ActiveRecord::Base module ValidationMethods def uploader_is_not_limited if !uploader.can_upload? - raise Error.new("uploader has reached their daily limit") + raise Error.new(uploader.upload_limited_reason) end end diff --git a/app/models/user.rb b/app/models/user.rb index 96cc500a7..2574710d2 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -375,6 +375,16 @@ class User < ActiveRecord::Base 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? if is_privileged? true