Dropdown on details page allows image management for users and admins
This commit is contained in:
parent
263f6cd33f
commit
16999260ca
8 changed files with 75 additions and 35 deletions
|
|
@ -20,10 +20,14 @@ class Screenshot < ActiveRecord::Base
|
|||
# Currently this check makes sure that the same screenshot is not uploaded
|
||||
# twice for the same package. However it allows the screenshot to be uploaded
|
||||
# for two different packages. Restricting that further may happen later.
|
||||
|
||||
# TODO: will fail if screenshot is updated because it finds its own image
|
||||
def validate_image_is_unique
|
||||
# Look for images with the same checksum / image_fingerprint
|
||||
if Screenshot.find_by(image_fingerprint: image_fingerprint, package_id: self.package.id)
|
||||
errors.add(:image, "has already been uploaded for this package")
|
||||
if screenshot=Screenshot.find_by(image_fingerprint: image_fingerprint, package_id: self.package.id)
|
||||
unless screenshot.id == self.id
|
||||
errors.add(:image, "has already been uploaded for this package")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue