From 4ac7b41a7fa291ffe966369203f653be54f2bfff Mon Sep 17 00:00:00 2001 From: Andreas Stephanides Date: Sun, 16 Mar 2014 11:19:10 +0100 Subject: [PATCH] lecturer load lva load first steps --- app/controllers/lvas_controller.rb | 11 +++++++++++ app/controllers/moduls_controller.rb | 1 + app/models/lecturer.rb | 12 ++++++++++++ app/models/lva.rb | 2 +- app/views/lecturers/_lec_lva.html.erb | 16 ++++++++-------- app/views/lecturers/show.html.erb | 3 +++ 6 files changed, 36 insertions(+), 9 deletions(-) diff --git a/app/controllers/lvas_controller.rb b/app/controllers/lvas_controller.rb index 8919adb..7f0bd65 100755 --- a/app/controllers/lvas_controller.rb +++ b/app/controllers/lvas_controller.rb @@ -36,6 +36,17 @@ class LvasController < ApplicationController end + + def compare_tiss + + end + + def load_tiss + + end + + + # POST /lvas # POST /lvas.json def create diff --git a/app/controllers/moduls_controller.rb b/app/controllers/moduls_controller.rb index 624d536..ace786b 100755 --- a/app/controllers/moduls_controller.rb +++ b/app/controllers/moduls_controller.rb @@ -8,6 +8,7 @@ class ModulsController < ApplicationController if !params[:studium_id].nil? @studium=Studium.find_by_id(params[:studium_id]) end + @toolbar_elements = [{:hicon=>'icon-plus-sign', :text=>I18n.t("modul.add"), :path=>new_modul_path}] @topbar_elements =[{:hicon=>'icon-list', :text=>I18n.t("studien.allestudien"),:path=>studien_path}] @topbar_elements<<{:hicon=>'icon-list', :text=>I18n.t("modul.list"),:path=>moduls_path} diff --git a/app/models/lecturer.rb b/app/models/lecturer.rb index f860542..8195633 100644 --- a/app/models/lecturer.rb +++ b/app/models/lecturer.rb @@ -16,4 +16,16 @@ class Lecturer < ActiveRecord::Base has_and_belongs_to_many :lvas mount_uploader :picture, PictureUploader resourcify + + def load_tissdata + url= "https://tiss.tuwien.ac.at/adressbuch/adressbuch/person_via_oid/"+self.oid.to_s+".xml" + hash=Hash.from_xml(open(url).read)["tuvienna"] + self.name=hash["person"]["firstname"]+" "+hash["person"]["lastname"] + if hash["person"]["employee"]["employment"].is_a? Array + self.email= hash["person"]["employee"]["employment"].first["emails"]["email"].first + else + self.email= hash["person"]["employee"]["employment"]["emails"]["email"].first + end + self.link= "https://tiss.tuwien.ac.at/adressbuch/adressbuch/person_via_oid/"+self.oid.to_s + end end diff --git a/app/models/lva.rb b/app/models/lva.rb index 241b4b6..4bf9bf8 100755 --- a/app/models/lva.rb +++ b/app/models/lva.rb @@ -87,7 +87,7 @@ class Lva < ActiveRecord::Base # rescue OpenURI::HTTPError => e # end self.name=hash["course"]["title"][I18n.locale.to_s] - self.pruefungsinformation= hash["course"]["examinationModalities"][I18n.locale.to_s] + self.pruefungsinformation = hash["course"]["examinationModalities"][I18n.locale.to_s] self.desc= hash["course"]["objective"][I18n.locale.to_s]+hash["course"]["teachingContent"][I18n.locale.to_s] self.typ=hash["course"]["courseType"] self.stunden=hash["course"]["weeklyHours"] diff --git a/app/views/lecturers/_lec_lva.html.erb b/app/views/lecturers/_lec_lva.html.erb index 21a9536..83cc332 100644 --- a/app/views/lecturers/_lec_lva.html.erb +++ b/app/views/lecturers/_lec_lva.html.erb @@ -1,11 +1,11 @@
- - - -
-

<%= link_to lec_lva.name, lec_lva %>

+ + + +
+

<%= link_to lec_lva.name, lec_lva %>

Email: <%= mail_to lec_lva.email %>
- TISS: <%= link_to lec_lva.name, lec_lva.link %> -
-
+ TISS: <%= link_to lec_lva.name, lec_lva.link %> +
+ diff --git a/app/views/lecturers/show.html.erb b/app/views/lecturers/show.html.erb index 21e93cb..7f6cf37 100644 --- a/app/views/lecturers/show.html.erb +++ b/app/views/lecturers/show.html.erb @@ -1,5 +1,8 @@

<%= notice %>

+ +<%= render partial: "lec_lva", object: @lecturer %> +

Name: <%= @lecturer.name %>