upload beispiele attachments...
This commit is contained in:
@@ -48,16 +48,17 @@ class AttachmentsController < ApplicationController
|
||||
@attachment = Attachment.new(params[:attachment])
|
||||
@thema = Thema.find(params[:thema_id])
|
||||
@attachment.thema_id = @thema.id
|
||||
|
||||
@action="create"
|
||||
logger.info "#{@attachment.inspect}"
|
||||
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 { @attachment = Attachment.new }
|
||||
format.js { }
|
||||
else
|
||||
format.html { render action: "new" }
|
||||
format.json { render json: @attachment.errors, status: :unprocessable_entity }
|
||||
format.js { render action: "new"}
|
||||
format.js { render action: "new.js.erb"}
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -76,7 +77,7 @@ class AttachmentsController < ApplicationController
|
||||
else
|
||||
format.html { render action: "edit" }
|
||||
format.json { render json: @attachment.errors, status: :unprocessable_entity }
|
||||
format.js { render action: "new"}
|
||||
format.js { render action: "new"}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -43,15 +43,29 @@ class BeispieleController < ApplicationController
|
||||
# POST /beispiele
|
||||
# POST /beispiele.json
|
||||
def create
|
||||
logger.info "Creating Beispiel..."
|
||||
@lva = Lva.find_by_id(params[:lva_id])
|
||||
params.delete(:lva_id)
|
||||
@beispiel = Beispiel.new(params[:beispiel])
|
||||
@backlink = @beispiel.lva.nil? ? root_url : lva_path(@beispiel.lva)
|
||||
@beispiel.lva=@lva
|
||||
logger.info "New Beispiel: #{params.inspect}"
|
||||
|
||||
# @backlink = @beispiel.lva.nil? ? root_url : lva_path(@beispiel.lva)
|
||||
@beispiel.name=@beispiel.beispieldatei.filename
|
||||
logger.info "New Beispiel: #{@beispiel.attributes.inspect}"
|
||||
|
||||
@beispiel.datum=Time.now
|
||||
respond_to do |format|
|
||||
@beispiel.name=@beispiel.beispieldatei.to_s.split('/').last
|
||||
|
||||
if @beispiel.save
|
||||
format.html { redirect_to @backlink, notice: 'Beispiel was successfully created.' }
|
||||
format.json { render json: @beispiel, status: :created, location: @beispiel }
|
||||
format.html {
|
||||
render :json => [@beispiel.to_jq_upload].to_json,
|
||||
:content_type => 'text/html',
|
||||
:layout => false
|
||||
}
|
||||
format.json { render json: {files: [@beispiel.to_jq_upload]}, status: :created, location: [@lva, @beispiel] }
|
||||
# format.html { redirect_to @backlink, notice: 'Beispiel was successfully created.' }
|
||||
# format.json { render json: @beispiel, status: :created, location: @beispiel }
|
||||
else
|
||||
format.html { render action: "new" }
|
||||
format.json { render json: @beispiel.errors, status: :unprocessable_entity }
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
class HomeController < ApplicationController
|
||||
def index
|
||||
@beispiele = Beispiel.last([Beispiel.count, 3].min)
|
||||
@neuigkeiten = Neuigkeit.recent
|
||||
|
||||
end
|
||||
def dev
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ class ThemenController < ApplicationController
|
||||
respond_to do |format|
|
||||
format.html # new.html.erb
|
||||
format.json { render json: @thema }
|
||||
format.js { render action: "edit" }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -15,11 +15,22 @@ class Beispiel < ActiveRecord::Base
|
||||
has_paper_trail
|
||||
attr_accessible :desc, :name, :lva_id, :beispieldatei, :beispieldatei_cache, :datum
|
||||
belongs_to :lva
|
||||
mount_uploader :beispieldatei, BeispieldateiUploader
|
||||
mount_uploader :beispieldatei, AttachmentUploader
|
||||
validates :beispieldatei, :presence => true
|
||||
validates :name, :presence => true
|
||||
validates :lva_id, :presence => true
|
||||
validates :lva, :presence => true
|
||||
validates :datum, :presence => true
|
||||
|
||||
def to_jq_upload
|
||||
{
|
||||
"id" => read_attribute(:id),
|
||||
"title" => read_attribute(:title),
|
||||
"description" => read_attribute(:desc),
|
||||
"name" => read_attribute(:title),
|
||||
"size" => beispieldatei.size,
|
||||
"url" => beispieldatei.url,
|
||||
"thumbnail_url" => beispieldatei.thumb.url,
|
||||
"delete_type" => "DELETE"
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<%= semantic_form_for [@thema,@attachment],:remote=>true do |f| %>
|
||||
<%= semantic_form_for [@thema,@attachment], :remote=>true do |f| %>
|
||||
<%= f.inputs do %>
|
||||
<%= f.input :name %>
|
||||
|
||||
<%= token_tag form_authenticity_token %>
|
||||
<%= f.input :datei, :as => :file %>
|
||||
<% end %>
|
||||
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
|
||||
$("#attachmentform").html("<%=escape_javascript( render :partial=>'attachments/rform' )%>")
|
||||
alert('create_attachment');
|
||||
$("#attachmentform").html("<%=escape_javascript( render :partial=>'attachments/rform' )%>");
|
||||
|
||||
@@ -1 +1,4 @@
|
||||
$("#attachmentform").html("<%=escape_javascript( render :partial=>'attachments/rform' )%>")
|
||||
alert('new.js.erb')
|
||||
$("#attachmentform").html("<%=escape_javascript( render :partial=>'attachments/rform' )+ @action.to_s%>");
|
||||
$('document').trigger('ready');
|
||||
alert('ready')
|
||||
@@ -1,5 +1,6 @@
|
||||
|
||||
<div class="container">
|
||||
<%= semantic_form_for [@lva, @beispiel], :remote=>true, :html => { :multipart => true, :id => "fileupload" } do |f| %>
|
||||
<%= semantic_form_for [@lva,@beispiel], :remote=>true, :html => { :multipart => true, :id => "fileupload" } do |f| %>
|
||||
<!-- The fileupload-buttonbar contains buttons to add/delete files and start/cancel the upload -->
|
||||
<div class="row ">
|
||||
|
||||
@@ -10,7 +11,7 @@
|
||||
<i class="icon-plus icon-white"></i>
|
||||
<span>Add files...</span>
|
||||
<%= f.file_field :beispieldatei, :multiple=>true %>
|
||||
<%= f.input :lva %>
|
||||
<% f.input :lva %>
|
||||
</span>
|
||||
<button type="submit" class="btn btn-primary start">
|
||||
<i class="icon-upload icon-white"></i>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<div class="row-fluid">
|
||||
|
||||
<div class="span8">
|
||||
<h4>Neueste Beispiele</h4>
|
||||
<h4>Neueste Beispiele in unserer Sammlung</h4>
|
||||
</div>
|
||||
<div class="span4">
|
||||
<%= link_to I18n.t("beispiel.add"), new_beispiel_path, :class=>"btn"%>
|
||||
|
||||
@@ -1,5 +1,14 @@
|
||||
<div class="content-wrap content-column">
|
||||
<h1><%= I18n.t('home.willkommen') %></h1>
|
||||
<p><%= I18n.t('home.hallobeiderfet') %></p>
|
||||
<ul class="unstyled linkbox-list" style="max-width:70em">
|
||||
<% @neuigkeiten.each do |n| %>
|
||||
<li><%= render n if can?(:show, n) %> </li>
|
||||
<% end %>
|
||||
</ul>
|
||||
<p>
|
||||
<%= link_to "FET Login", user_omniauth_authorize_path(:ldap) %>
|
||||
</p>
|
||||
<div class="alert">
|
||||
<h2>Beta Test</h2>
|
||||
<p>Die Webseite befindet sich derzeit in einem Entsicklungsstadium,
|
||||
@@ -19,7 +28,6 @@
|
||||
</p>
|
||||
|
||||
</div>
|
||||
<p><%= I18n.t('home.hallobeiderfet') %></p>
|
||||
<%= link_to "Entwicklungsstatus" , home_dev_path %>
|
||||
<%= render 'beispiele' %>
|
||||
|
||||
|
||||
@@ -13,16 +13,16 @@
|
||||
<%= neuigkeit.title%>
|
||||
</h1>
|
||||
<%= raw(neuigkeit.text_first_words) unless neuigkeit.text.nil?%>
|
||||
</div>
|
||||
<% if neuigkeit.has_calentries? %>
|
||||
<div class="pull-right" href="#">
|
||||
<%= image_tag("/iconnavy/time.png") %>
|
||||
<% unless neuigkeit.calentries.upcoming.empty? %>
|
||||
<%= neuigkeit.calentries.upcoming.first.text %>
|
||||
<% else unless neuigkeit.calentries.recent.empty? %>
|
||||
<%= neuigkeit.calentries.recent.first.text %>
|
||||
<% end %><% end %>
|
||||
</div>
|
||||
<% if neuigkeit.has_calentries? %>
|
||||
<div class="pull-right" href="#">
|
||||
<%= image_tag("/iconnavy/time.png") %>
|
||||
<% unless neuigkeit.calentries.upcoming.empty? %>
|
||||
<%= neuigkeit.calentries.upcoming.first.text %>
|
||||
<% else unless neuigkeit.calentries.recent.empty? %>
|
||||
<%= neuigkeit.calentries.recent.first.text %>
|
||||
<% end %><% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
</div>
|
||||
|
||||
@@ -1 +1 @@
|
||||
$("#themaview").html("<%= escape_javascript(raw("<h2>Bearbeiten</h2>")+render(:partial=>"themen/form") )%>");
|
||||
$("#themaview").html("<%= escape_javascript(raw("<h2>"+I18n.t('thema.edit')+"</h2>")+render(:partial=>"themen/form") )%>");
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
<li id="themen_<%= thema.id %>" class="sort" ><div class="contentbox handle" ><h2><%= thema.title %></h2> </div> <%= link_to edit_thema_path(thema),:remote=>true do %> Edit <% end %> <%= link_to thema_fragen_path(thema),:remote=>true do %> Fragen <% end %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
<%= link_to new_themengruppe_thema_path(@themengruppe),:remote=>true do %> New Thema <% end %>
|
||||
</div>
|
||||
<div class="span8">
|
||||
<div id="themaview"></div>
|
||||
|
||||
@@ -21,6 +21,7 @@ de:
|
||||
info: "Information"
|
||||
mitarbeiter: "Mitarbeiter"
|
||||
fotos: "Fotos"
|
||||
search: "Suche"
|
||||
formtastic:
|
||||
titles:
|
||||
modul:
|
||||
|
||||
@@ -62,9 +62,9 @@ end
|
||||
get 'load_tiss'
|
||||
post 'show_tiss'
|
||||
end
|
||||
|
||||
resources :beispiele#, :only=>[:show,:index,:create]
|
||||
resources :lvas do
|
||||
resources :beispiele, :only=>[:show,:index]
|
||||
resources :beispiele#, :only=>[:show,:index,:create]
|
||||
end
|
||||
|
||||
resources :fragen
|
||||
@@ -102,7 +102,7 @@ end
|
||||
get 'home/linksnotimplemented', :controller=>:home, :action=>:linksnotimplemented, :as=>'home_linksnotimplemented'
|
||||
|
||||
|
||||
resources :beispiele
|
||||
|
||||
resources :themen do
|
||||
get :fragen
|
||||
resources :attachments
|
||||
|
||||
Reference in New Issue
Block a user