Added age_days method to display the upload age of a screenshot
This commit is contained in:
parent
2b2f325356
commit
d7bfa0843f
2 changed files with 8 additions and 1 deletions
|
|
@ -27,6 +27,13 @@ class Screenshot < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Calculate how many days ago this screenshot has been uploaded
|
||||||
|
def age_days
|
||||||
|
seconds = Time.now-self.uploaddatetime
|
||||||
|
days = (seconds/86400).to_i
|
||||||
|
days ? "#{days} days ago" : 'today'
|
||||||
|
end
|
||||||
|
|
||||||
# Return caption for full-screen screenshots.
|
# Return caption for full-screen screenshots.
|
||||||
# Takes the description of a screenshot if available.
|
# Takes the description of a screenshot if available.
|
||||||
# Otherwise it falls back to the general description of its package.
|
# Otherwise it falls back to the general description of its package.
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
.imgcaption =screenshot.caption
|
.imgcaption =screenshot.caption
|
||||||
// TODO: Show information only if admin
|
// TODO: Show information only if admin
|
||||||
- if user_signed_in?
|
- if user_signed_in?
|
||||||
p Uploader IP=#{screenshot.uploaderip} / Token=#{screenshot.uploaderhash}
|
p Uploader IP=#{screenshot.uploaderip} / Token=#{screenshot.uploaderhash} / Uploaded #{screenshot.age_days}
|
||||||
// TODO: Enable button only if admin or uploader
|
// TODO: Enable button only if admin or uploader
|
||||||
a.button.tiny.alert[
|
a.button.tiny.alert[
|
||||||
href=delete_screenshot_path(@package.name, screenshot.id)
|
href=delete_screenshot_path(@package.name, screenshot.id)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue