Neuigkeiten updateund lva
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
class NeuigkeitenController < ApplicationController
|
||||
|
||||
before_filter {@toolbar_elements=[]}
|
||||
def index
|
||||
@neuigkeiten = Neuigkeit.all
|
||||
end
|
||||
@@ -7,7 +7,9 @@ class NeuigkeitenController < ApplicationController
|
||||
|
||||
def show
|
||||
@neuigkeit = Neuigkeit.find(params[:id])
|
||||
|
||||
if can? :edit, @neuigkeit
|
||||
@toolbar_elements << {:text=>I18n.t('common.edit'),:path=>edit_neuigkeit_path(@neuigkeit),:icon=>:pencil}
|
||||
end
|
||||
end
|
||||
|
||||
def new
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class RubrikenController < ApplicationController
|
||||
|
||||
before_filter {@toolbar_elements=[]}
|
||||
def index
|
||||
@rubriken = Rubrik.all
|
||||
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
class StudienController < ApplicationController
|
||||
before_filter {@toolbar_elements =[]}
|
||||
|
||||
|
||||
def index
|
||||
@studien = Studium.all
|
||||
|
||||
@toolbar_elements<<{:icon =>:plus, :text=> I18n.t('studien.new') ,:path=>new_studium_path }
|
||||
end
|
||||
|
||||
def show
|
||||
@@ -22,29 +24,25 @@ class StudienController < ApplicationController
|
||||
modulgruppen<<s
|
||||
end
|
||||
@studienphasen << {:modulgruppen=>modulgruppen, :phase => ph}.merge(opts)
|
||||
end
|
||||
@toolbar_elements=[{:icon =>:plus ,:text=> I18n.t('studien.new') , :path => new_studium_modulgruppe_path(@studium) }]
|
||||
@toolbar_elements<<{:icon=>:pencil,:text =>I18n.t('common.edit'),:path => edit_studium_path(@studium)}
|
||||
@toolbar_elements<<{:text=> I18n.t('common.delete'),:path => studium_path(@studium), :method=> :delete,:confirm=>"Sure?" }
|
||||
end
|
||||
|
||||
@toolbar_elements=[{:text => '<i class="icon-plus"></i> '.html_safe + I18n.t('studien.new') , :path => new_studium_modulgruppe_path(@studium) }]
|
||||
@toolbar_elements<<{:text => '<i class="icon-pencil"></i> '.html_safe + I18n.t('common.edit'),:path=>edit_studium_path(@studium)}
|
||||
@toolbar_elements<<{:link=> link_to('Destroy', @studium, method: :delete, data: { confirm: 'Are you sure?' })}
|
||||
end
|
||||
end
|
||||
|
||||
def new
|
||||
@studium = Studium.new
|
||||
end
|
||||
|
||||
# GET /studia/1/edit
|
||||
def edit
|
||||
@studium = Studium.find(params[:id])
|
||||
@toolbar_elements=[{:text => I18n.t('studien.anzeigen') , :path => url_for(@studium) }]
|
||||
@toolbar_elements<<{:text =>I18n.t('studien.allestudien'),:path=>studien_path(@studium)}
|
||||
end
|
||||
|
||||
# POST /studia
|
||||
# POST /studia.json
|
||||
def create
|
||||
@studium = Studium.new(params[:studium])
|
||||
|
||||
respond_to do |format|
|
||||
if @studium.save
|
||||
format.html { redirect_to url_for(@studium), notice: 'Studium was successfully created.' }
|
||||
@@ -58,19 +56,15 @@ class StudienController < ApplicationController
|
||||
def update
|
||||
@studium = Studium.find(params[:id])
|
||||
|
||||
respond_to do |format|
|
||||
if @studium.update_attributes(params[:studium])
|
||||
format.html { redirect_to url_for(@studium), notice: 'Studium was successfully updated.' }
|
||||
|
||||
redirect_to url_for(@studium), notice: 'Studium was successfully updated.'
|
||||
else
|
||||
format.html { render action: "edit" }
|
||||
render action: "edit"
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# DELETE /studia/1
|
||||
# DELETE /studia/1.json
|
||||
def destroy
|
||||
@studium = Studium.find(params[:id])
|
||||
@studium.destroy
|
||||
|
||||
@@ -8,10 +8,41 @@ module ApplicationHelper
|
||||
end
|
||||
def toolbar_html(elemente)
|
||||
html = ""
|
||||
limiter = " | "
|
||||
elemente.each do |e|
|
||||
html = html + link_to(e[:text],e[:path]) + " | "
|
||||
if !e[:icon].nil?
|
||||
case e[:icon]
|
||||
when :pencil
|
||||
text = '<i class="icon-pencil"></i>'.html_safe + e[:text]
|
||||
when :plus
|
||||
text ='<i class="icon-plus"></i>'.html_safe+e[:text]
|
||||
else
|
||||
text = e[:text]
|
||||
end
|
||||
else
|
||||
text =e[:text]
|
||||
end
|
||||
if e[:link].nil?
|
||||
if !e[:method].nil?
|
||||
if !e[:confirm].nil?
|
||||
html = html + link_to(text,e[:path],:confirm=>e[:confirm],:method=>e[:method])
|
||||
else
|
||||
html = html + link_to(text,e[:path],:method => e[:method])
|
||||
end
|
||||
else
|
||||
if !e[:confirm].nil?
|
||||
html=html + link_to(text,e[:path],:confirm=>e[:confirm])
|
||||
else
|
||||
html= html + link_to(text,e[:path])
|
||||
end
|
||||
|
||||
end
|
||||
else
|
||||
html = html + e[:link]
|
||||
end
|
||||
|
||||
html=html+limiter
|
||||
end
|
||||
#html= html + "</ul>"
|
||||
raw(html)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -5,4 +5,37 @@ class Lva < ActiveRecord::Base
|
||||
has_and_belongs_to_many :semester
|
||||
translates :desc, :fallbacks_for_empty_translations => true
|
||||
has_many :beispiele , :class_name => "Beispiel"
|
||||
after_initialize :load_tissdata
|
||||
def hash
|
||||
url= "https://tiss.tuwien.ac.at/api/course/"+ self.lvanr.to_s+"-2012W"
|
||||
@hash=Hash.from_xml(open(url).read)
|
||||
|
||||
end
|
||||
|
||||
def objective
|
||||
@hash["course"]["objective"][I18n.locale.to_s]
|
||||
end
|
||||
def techingContent
|
||||
@hash["course"]["teachingContent"][I18n.locale.to_s]
|
||||
end
|
||||
def person
|
||||
@person
|
||||
end
|
||||
private
|
||||
|
||||
def load_tissdata
|
||||
url= "https://tiss.tuwien.ac.at/api/course/"+ self.lvanr.to_s+"-2012W"
|
||||
begin
|
||||
@hash=Hash.from_xml(open(url).read)["tuvienna"]
|
||||
@person=[]
|
||||
# @person = @hash["course"]["lecturers"]["oid"]
|
||||
@hash["course"]["lecturers"]["oid"].each do |pid|
|
||||
@person << Hash.from_xml(open("https://tiss.tuwien.ac.at/adressbuch/adressbuch/person_via_oid/" + pid.to_s + ".xml").read)["tuvienna"]["person"]
|
||||
end
|
||||
rescue OpenURI::HTTPError => e
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
<div style="border: solid 1px; padding:2px"><p>
|
||||
<b><%= link_to "Modul "+ modul.name , modul_path(modul) %> </b>
|
||||
<b><%=
|
||||
if modul.name.nil?
|
||||
name=""
|
||||
else
|
||||
name=modul.name
|
||||
end
|
||||
link_to "Modul "+name , modul_path(modul) %> </b>
|
||||
</p>
|
||||
<p>
|
||||
<%= raw(modul.desc) %>
|
||||
@@ -11,5 +17,5 @@ LVAs:
|
||||
<% end %>
|
||||
</ul>
|
||||
|
||||
<% link_to '<i class="icon-pencil"></i>'.html_safe+I18n.t("common.edit"), edit_modul_path(modul) %>
|
||||
<% # @toolbar_elements << {:icon=>:pencil,:text=>I18n.t("common.edit"),:path=> edit_modul_path(modul)} %>
|
||||
</div>
|
||||
|
||||
@@ -1,2 +1,5 @@
|
||||
<h2><%=neuigkeit.title %></h2>
|
||||
<h2><%= link_to neuigkeit.title,neuigkeit_path(neuigkeit) %></h2>
|
||||
<%= if !neuigkeit.author.nil?
|
||||
neuigkeit.author.name
|
||||
end %>
|
||||
<p><%= raw(neuigkeit.text) %></p>
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
<ul class="breadcrumb">
|
||||
<li><%= link_to "Neuigkeiten", rubriken_path %></li>
|
||||
<li><span class="divider">/</span></li>
|
||||
<li><%= link_to @neuigkeit.rubrik.name , rubrik_path(@neuigkeit.rubrik) %> </li>
|
||||
</ul>
|
||||
<p id="notice"><%= notice %></p>
|
||||
|
||||
<%= render @neuigkeit %>
|
||||
<p>
|
||||
<b>Datum:</b>
|
||||
<%= @neuigkeit.datum %>
|
||||
</p>
|
||||
|
||||
|
||||
<% elements=[link_to('Edit', edit_neuigkeit_path(@neuigkeit))]
|
||||
elements << link_to('Back', rubrik_path(@neuigkeit.rubrik)) %>
|
||||
<%= toolbar_html (elements) %>
|
||||
<%= toolbar_html (@toolbar_elements) %>
|
||||
|
||||
@@ -40,3 +40,5 @@
|
||||
<%= link_to 'Back', rubriken_path %> |
|
||||
<%= link_to 'Destroy', @rubrik, method: :delete, data: { confirm: 'Are you sure?' } %>
|
||||
</span></div>
|
||||
<%= toolbar_html(@toolbar_elements)%>
|
||||
|
||||
|
||||
@@ -12,3 +12,4 @@
|
||||
<br />
|
||||
|
||||
<%= link_to I18n.t("studien.new"), new_studium_path %>
|
||||
<%= toolbar_html(@toolbar_elements) %>
|
||||
|
||||
Reference in New Issue
Block a user