This commit is contained in:
Christoph Haas 2015-04-18 21:39:12 +02:00
parent 42447edeaa
commit ec726ed62a
3 changed files with 12 additions and 7 deletions

View file

@ -61,13 +61,13 @@ class PackagesController < ApplicationController
#new_screenshot.image = params[:image] #new_screenshot.image = params[:image]
#render text: "File has been uploaded successfully" #render text: "File has been uploaded successfully"
redirect_to upload_package_by_name_path redirect_to package_path
end end
def delete_screenshot def delete_screenshot
@screenshot = Screenshot.find_by(id: params[:id]) @screenshot = Screenshot.find_by(id: params[:id])
@screenshot.destroy @screenshot.destroy
redirect_to upload_package_by_name_path redirect_to package_path
end end
end end

View file

@ -18,12 +18,17 @@
a.black.fancybox href=screenshot.image.url(:large, timestamp: false) rel='fancybox-thumb' title=screenshot.caption a.black.fancybox href=screenshot.image.url(:large, timestamp: false) rel='fancybox-thumb' title=screenshot.caption
= image_tag(screenshot.image.url(:large, timestamp: false), alt: screenshot.caption) = image_tag(screenshot.image.url(:large, timestamp: false), alt: screenshot.caption)
.imgcaption =screenshot.caption .imgcaption =screenshot.caption
// TODO: Enable button only if admin or uploader
a.button.tiny.alert[
href=delete_screenshot_path(@package.name, screenshot.id)
onclick="return confirm('Really delete the screenshot?');"
] Delete screenshot
// Upload image // Upload image
li li
//a.button.radius.expand href=upload_package_by_name_path(name: @package.name) Upload a new screenshot = form_tag(upload_image_path, multipart: true)
//= form_for @package, :url => upload_image_path, :html => { :multipart => true } do |form| = file_field_tag('image')
//= form.file_field :image = submit_tag
= form_for :screenshot, url: upload_image_path, html: { multipart: true } do |f| = form_for :screenshot, url: upload_image_path, html: { multipart: true } do |f|
= f.label :image, 'Upload new screenshot' = f.label :image, 'Upload new screenshot'

View file

@ -17,8 +17,8 @@
= file_field_tag('image') = file_field_tag('image')
= submit_tag = submit_tag
a.button.radius.expand href=upload_package_by_name_path(name: @package.name) //a.button.radius.expand href=upload_package_by_name_path(name: @package.name)
' Click or drag a PNG screenshot file here //' Click or drag a PNG screenshot file here
.small-6.columns .small-6.columns
' Form ' Form
- @package.screenshots.each do |screenshot| - @package.screenshots.each do |screenshot|