studium_edit_lvas added
This commit is contained in:
@@ -34,6 +34,7 @@ class StudienController < ApplicationController
|
||||
|
||||
@toolbar_elements=[{:icon=>:plus, :hicon =>'icon-plus-sign' ,:text=> I18n.t('studien.new') , :path => new_studium_path(@studium) },
|
||||
{:icon=>:pencil, :hicon=>'icon-pencil',:text =>I18n.t('common.edit'),:path => edit_studium_path(@studium)},
|
||||
{:icon=>:pencil, :hicon=>'icon-pencil',:text =>I18n.t('common.edit'),:path => edit_lvas_studium_path(@studium)},
|
||||
{:hicon=>'icon-remove-circle', :text=> I18n.t('common.delete'),:path => studium_path(@studium), :method=> :delete,:confirm=>'Sure?' }]
|
||||
|
||||
@toolbar_modulgruppen =[ {:hicon=>'icon-plus-sign', :text=> I18n.t('modulgruppe.new'), :path=>new_studium_modulgruppe_path(@studium)},
|
||||
@@ -57,6 +58,15 @@ class StudienController < ApplicationController
|
||||
@toolbar_elements<<{:text =>I18n.t('studien.allestudien'),:path=>studien_path(@studium)}
|
||||
end
|
||||
|
||||
def edit_lvas
|
||||
@studium = Studium.find(params[:id])
|
||||
@lvas=@studium.lvas
|
||||
@semester=@studium.semester
|
||||
@toolbar_elements=[{:text => I18n.t('studien.anzeigen') , :path => url_for(@studium) }]
|
||||
@toolbar_elements<<{:text =>I18n.t('studien.allestudien'),:path=>studien_path(@studium)}
|
||||
|
||||
end
|
||||
|
||||
def create
|
||||
@studium = Studium.new(params[:studium])
|
||||
|
||||
@@ -73,9 +83,13 @@ class StudienController < ApplicationController
|
||||
|
||||
def update
|
||||
@studium = Studium.find(params[:id])
|
||||
|
||||
if @studium.update_attributes(params[:studium])
|
||||
redirect_to url_for(@studium), notice: 'Studium was successfully updated.'
|
||||
logger.info "params: #{params[:studium].inspect}"
|
||||
if @studium.update_attributes(params[:studium])
|
||||
if @studium.lvas.map(&:valid?).all?
|
||||
redirect_to url_for(@studium), notice: 'Studium was successfully updated.'
|
||||
else
|
||||
render action: "edit"
|
||||
end
|
||||
else
|
||||
render action: "edit"
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ class Neuigkeit < ActiveRecord::Base
|
||||
|
||||
has_many :calentries, as: :object
|
||||
mount_uploader :picture, PictureUploader
|
||||
|
||||
scope :published, -> {where("datum <= ? AND datum IS NOT NULL", Time.now.to_date).order(:datum).reverse_order}
|
||||
scope :recent, -> { published.limit(15)}
|
||||
scope :unpublished, -> {where("datum >= ? OR datum IS NULL", Date.today)}
|
||||
@@ -32,7 +33,7 @@ class Neuigkeit < ActiveRecord::Base
|
||||
accepts_nested_attributes_for :calentries, :allow_destroy=>true , :reject_if=> lambda{|a| a[:start].blank?}
|
||||
before_validation :sanitize
|
||||
has_many :nlinks
|
||||
|
||||
|
||||
def datum_nilsave
|
||||
self.datum.nil? ? Time.now + 42.years : self.datum
|
||||
end
|
||||
|
||||
@@ -27,18 +27,24 @@
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
class Studium < ActiveRecord::Base
|
||||
attr_accessible :desc, :name,:abkuerzung, :typ, :zahl, :semester, :picture, :picture_cache, :qualifikation,:struktur, :jobmoeglichkeiten
|
||||
attr_accessible :desc, :name,:abkuerzung, :typ, :zahl, :semester, :picture, :picture_cache, :qualifikation,:struktur, :jobmoeglichkeiten, :lvas_attributes
|
||||
has_many :modulgruppen, inverse_of: :studium, :class_name => "Modulgruppe", :dependent => :destroy
|
||||
scope :search, ->(query) {where("name like ? or studien.desc like ?", "%#{query}%", "%#{query}%")}
|
||||
has_many :moduls, :through=>:modulgruppen
|
||||
has_many :lvas, :through=>:moduls
|
||||
has_many :semester, :dependent => :destroy
|
||||
validates :abkuerzung, :length=>{:maximum=>5}, :format=>{:with=>/^[a-zA-z]{0,5}$/}
|
||||
|
||||
validates :abkuerzung, :length=>{:maximum=>5}, :format=>{:with=>/^[a-zA-z]{0,5}$/}
|
||||
validates :typ, :inclusion => {:in => ["Bachelor","Master"] }
|
||||
validates :name, :uniqueness => true, :presence=>true
|
||||
validates :zahl, :presence=>true, :format=>{:with=>/^[0-9A-Z]{4,10}$/}, :uniqueness => true
|
||||
|
||||
mount_uploader :picture, PictureUploader
|
||||
|
||||
accepts_nested_attributes_for :lvas #, :allow_destroy=>true # , :reject_if=> lambda{|a| a[:name].blank?}
|
||||
|
||||
translates :desc,:shortdesc, :qualifikation,:struktur, :jobmoeglichkeiten, :versioning =>true,:fallbacks_for_empty_translations => true
|
||||
|
||||
def title_context
|
||||
return self.abkuerzung.to_s.strip.empty? ? self.name : self.abkuerzung
|
||||
end
|
||||
|
||||
@@ -13,8 +13,13 @@
|
||||
end %>
|
||||
</div>
|
||||
<div class="media-body">
|
||||
<small class="pull-left"><%= gallery.fotos.size.to_s + " " + I18n.t('fotos.bilder')%> </small>
|
||||
<small class="pull-right"><%=I18n.l(gallery.try(:datum).try(:to_date)) unless gallery.try(:datum).try(:to_date).nil? %></small></br>
|
||||
<small class="pull-left">
|
||||
<%= gallery.fotos.size.to_s + " " + I18n.t('fotos.bilder')%>
|
||||
</small>
|
||||
<small class="pull-right">
|
||||
<%=I18n.l(gallery.try(:datum).try(:to_date)) unless gallery.try(:datum).try(:to_date).nil? %>
|
||||
</small>
|
||||
</br>
|
||||
<h1><%= gallery.name %></h1>
|
||||
<p>
|
||||
<%= if gallery.desc.split.size > Gallery::WORD_COUNT
|
||||
|
||||
21
app/views/lvas/_nested_fields.html.erb
Normal file
21
app/views/lvas/_nested_fields.html.erb
Normal file
@@ -0,0 +1,21 @@
|
||||
<tr>
|
||||
<td>
|
||||
<h4><%= %></h4>
|
||||
<%= f.semantic_errors :state %>
|
||||
<%= f.input :id, :as=>:hidden %>
|
||||
</td>
|
||||
|
||||
<td><%= f.input :lvanr , :input_html => { "style"=>"width:7em" }%></td>
|
||||
<td><%= f.input :name %></td>
|
||||
<td>
|
||||
<%= f.input :ects, :input_html => { "style"=>"width:4em" },:size=>5 %>
|
||||
<%= f.input :stunden, :input_html => { "style"=>"width:4em" }%></td>
|
||||
<td><%= f.input :typ, :input_html => { "style"=>"width:4em" }%></td>
|
||||
<td>
|
||||
<% f.input :semester , :input_html=>{:style=>"height:8em"},:collection=>@semester%>
|
||||
</td>
|
||||
|
||||
<td><%= f.input :pruefungsinformation,:input_html=>{:rows=>5} %></td>
|
||||
|
||||
<td><%= f.input :desc, :input_html=>{:rows=>4}%></td>
|
||||
</tr>
|
||||
@@ -3,33 +3,10 @@
|
||||
<% i = 0 %>
|
||||
<% @lvas.each do |lva|%>
|
||||
<% i = i +1 %>
|
||||
<tr>
|
||||
<%= semantic_fields_for "lvas[#{i}]", lva do |f|%>
|
||||
<td>
|
||||
<h4><%= lva.name %></h4>
|
||||
<%= f.semantic_errors :state %>
|
||||
<%= f.input :id, :as=>:hidden %></td>
|
||||
<td><%= f.input :lvanr , :input_html => { "style"=>"width:7em" }%></td>
|
||||
|
||||
|
||||
<td><%= f.input :name %></td>
|
||||
<td><%= f.input :ects, :input_html => { "style"=>"width:4em" },:size=>5 %>
|
||||
<%= f.input :stunden, :input_html => { "style"=>"width:4em" }%></td>
|
||||
<td><%= f.input :typ, :input_html => { "style"=>"width:4em" }%></td>
|
||||
<td>
|
||||
<%= f.input :semester , :input_html=>{:style=>"height:8em"},:collection=>@semester%></td>
|
||||
|
||||
<td><%= f.input :pruefungsinformation,:input_html=>{:rows=>4} %></td>
|
||||
|
||||
<td><%= f.input :desc, :input_html=>{:rows=>4}%></td>
|
||||
<td>
|
||||
<%= lva.valid? %>
|
||||
|
||||
</td>
|
||||
<%= render 'lvas/nested_fields', :f => f,:lva=>lva %>
|
||||
|
||||
<% end%>
|
||||
|
||||
</tr>
|
||||
<% end %>
|
||||
|
||||
<%= ff.actions do %>
|
||||
|
||||
@@ -9,23 +9,22 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="row-fluid">
|
||||
<div class="span6">
|
||||
<% f.input :datum, :as=> :datepicker %>
|
||||
<div class="span6">
|
||||
<% f.input :datum, :as=> :datepicker %>
|
||||
<%= f.input :rubrik, :as=> :radio, :collection=>Rubrik.all %>
|
||||
</div>
|
||||
<div class="span6">
|
||||
<%= f.input :author, :as=> :select %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="span6">
|
||||
<%= f.input :author, :as=> :select %>
|
||||
</div> </div>
|
||||
<div class="row-fluid">
|
||||
<div class="span12">
|
||||
<%= f.input :picture, :as=> :file %>
|
||||
</div> </div>
|
||||
<div class="span12">
|
||||
<%= f.input :picture, :as=> :file %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<%= f.semantic_fields_for :calentries , @calentries do |calentry| %>
|
||||
<%= render 'calentries/nested_fields', :f => calentry %>
|
||||
<%= f.semantic_fields_for :calentries , @calentries do |calentry| %>
|
||||
<%= render 'calentries/nested_fields', :f => calentry %>
|
||||
<% end %>
|
||||
|
||||
<% end %>
|
||||
|
||||
15
app/views/studien/edit_lvas.html.erb
Normal file
15
app/views/studien/edit_lvas.html.erb
Normal file
@@ -0,0 +1,15 @@
|
||||
<%= semantic_form_for @studium do |ff|%>
|
||||
|
||||
<table>
|
||||
|
||||
<%= ff.semantic_fields_for :lvas, @lvas do |f|%>
|
||||
<%= render 'lvas/nested_fields', :f => f %>
|
||||
<% end %>
|
||||
|
||||
<%= ff.actions do %>
|
||||
<%= ff.action :submit, :as => :button %>
|
||||
<%= ff.action :cancel, :as => :link %>
|
||||
<% end %>
|
||||
|
||||
</table>
|
||||
<% end %>
|
||||
@@ -25,9 +25,12 @@
|
||||
# Studien
|
||||
|
||||
scope '(:ansicht)' do
|
||||
resources :studien, :only=>[:new,:edit,:update,:destroy]
|
||||
resources :studien, :only=>[:show]
|
||||
end
|
||||
resources :studien, :only=>[:new,:edit,:update,:destroy,:show] do
|
||||
member do
|
||||
get :edit_lvas
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
resources :modulgruppen,:only =>[:create,:index] do
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user