forked from bofh/fetsite
themen ueberarbeitet attachments verwalten
This commit is contained in:
@@ -46,19 +46,29 @@ class AttachmentsController < ApplicationController
|
||||
# POST /attachments.json
|
||||
def create
|
||||
@attachment = Attachment.new(params[:attachment])
|
||||
@thema = Thema.find(params[:thema_id])
|
||||
@attachment.thema_id = @thema.id
|
||||
@action="create"
|
||||
logger.info "#{@attachment.inspect}"
|
||||
@thema = Thema.find_by_id(params[:thema_id])
|
||||
# logger.info "gg"
|
||||
@attachment.thema = @thema
|
||||
@attachment.name=@attachment.datei.filename
|
||||
@action="create"
|
||||
|
||||
|
||||
# logger.info "sdf"
|
||||
respond_to do |format|
|
||||
if @attachment.save
|
||||
format.html { redirect_to @thema, notice: 'Attachment was successfully created.' }
|
||||
format.json { render json: @thema, status: :created, location: @thema }
|
||||
format.js { }
|
||||
if @attachment.save
|
||||
format.html {
|
||||
render :json => [@attachment.to_jq_upload].to_json,
|
||||
:content_type => 'text/html',
|
||||
:layout => false
|
||||
}
|
||||
|
||||
# format.html { redirect_to @thema, notice: 'Attachment was successfully created.' }
|
||||
format.json { render json: {files: [@attachment.to_jq_upload]}, status: :created, location: [@thema, @attachment]}
|
||||
|
||||
else
|
||||
format.html { render action: "new" }
|
||||
format.json { render json: @attachment.errors, status: :unprocessable_entity }
|
||||
format.js { render action: "new.js.erb"}
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -32,7 +32,8 @@ class ThemenController < ApplicationController
|
||||
end
|
||||
def verwalten
|
||||
@thema = Thema.find(params[:id])
|
||||
unless (@thema.wikiname.empty? || @thema.wikiname.nil?)
|
||||
@attachment=Attachment.new
|
||||
unless (@thema.is_wiki?)
|
||||
redirect_to verwalten_wiki_path(Wiki.find(@thema.id))
|
||||
end
|
||||
|
||||
@@ -58,7 +59,10 @@ class ThemenController < ApplicationController
|
||||
# GET /themen/1/edit
|
||||
def edit
|
||||
@thema = Thema.find(params[:id])
|
||||
|
||||
unless ( @thema.wikiname.nil? || @thema.wikiname.empty? )
|
||||
redirect_to edit_wiki_path(Wiki.find(@thema.id))
|
||||
return
|
||||
end
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.js
|
||||
@@ -93,6 +97,7 @@ class ThemenController < ApplicationController
|
||||
def attachments
|
||||
@thema = Thema.find(params[:id])
|
||||
@attachments=@thema.attachments
|
||||
@attachment=Attachment.new
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
|
||||
@@ -23,7 +23,11 @@ class WikisController < ApplicationController
|
||||
end
|
||||
def edit
|
||||
@wiki = Wiki.find(params[:id])
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.js
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def update
|
||||
|
||||
Reference in New Issue
Block a user