true
has_and_belongs_to_many :modulgruppen
- validates :modulgruppen, :presence=>true # Ein Modul muss zu einer Modulgruppe gehören
+ validates :modulgruppen, :presence=>true # Ein Modul muss zu einer Modulgruppe gehören
validates :name, :presence=>true # Ein Modul muss einen Namen haben
translates :desc,:depend,:name, :versioning =>true, :fallbacks_for_empty_translations => true
-
+ def self.update_multiple(hash)
+ m= []
+ if hash.is_a? Hash
+ hash.each do |i,h|
+ if i.to_i == 0
+ unless h["name"].empty?
+ md=Modul.new(:name=>h["name"],:desc=>h["desc"],:depend=>h["depend"])
+ md.modulgruppen=Modulgruppe.where(:id => h["modulgruppe_ids"].map(&:to_i))
+ md.save
+ m << md
+ end
+ else
+ md=Modul.find(h["id"].to_i)
+ md.name=h["name"]
+ md.desc=h["desc"]
+ md.depend=h["depend"]
+ md.modulgruppen=Modulgruppe.where(:id => h["modulgruppe_ids"].map(&:to_i))
+ m << md
+ end
+ end
+ else
+ hash.each do |h|
+ unless h["name"].empty?
+ md=Modul.new(:name=>h["name"],:desc=>h["desc"],:depend=>h["depend"])
+ md.modulgruppen=Modulgruppe.where(:id => h["modulgruppe_ids"].map(&:to_i))
+ md.save
+ m << md
+ end
+ end
+ end
+ m
+ end
end
diff --git a/app/models/modulgruppe.rb b/app/models/modulgruppe.rb
index 236811c..7e45fd7 100755
--- a/app/models/modulgruppe.rb
+++ b/app/models/modulgruppe.rb
@@ -16,13 +16,20 @@ class Modulgruppe < ActiveRecord::Base
attr_accessible :name, :phase, :typ,:desc, :studium_id, :modul_ids
belongs_to :studium, :foreign_key => "studium_id"
has_and_belongs_to_many :moduls
-
+ has_many :lvas, :through=>:moduls
resourcify
validates :studium_id, :presence => true # Bei der Abfrage ist student_id entscheidend
validates :studium, :presence => true # Wird gesetzt, um das richtige Feld zu melden bei Fehlern
+
validates :name, :uniqueness =>{:scope => :studium_id}, :presence=>true # Pro Studium darf ein Name nur einmal vorkommen
validates :phase, :inclusion => {:in => [1, 2, 3, 4]}
validates :typ, :inclusion => {:in => ["Pflicht","Vertiefungspflicht","Wahl"] }
translates :desc, :versioning =>true,:fallbacks_for_empty_translations => true
+ def long_name
+ name + "(" + self.studium_name + ")"
+ end
+ def studium_name
+ self.studium.nil? ? "Kein Studium vorhanden" : self.studium.name
+ end
end
diff --git a/app/models/neuigkeit.rb b/app/models/neuigkeit.rb
index 2a0f582..e5b710b 100755
--- a/app/models/neuigkeit.rb
+++ b/app/models/neuigkeit.rb
@@ -24,12 +24,15 @@ 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.order(:datum).reverse_order.limit(15)}
+ scope :recent, -> { published.limit(15)}
scope :unpublished, -> {where("datum >= ? OR datum IS NULL", Date.today)}
scope :public, ->{includes(:rubrik).where("rubriken.public"=>:true)}
scope :search, ->(query) {where("text like ? or title like ?", "%#{query}%", "%#{query}%")}
+ LINKTYPES=["Thema", "Gallery", "Lva","Studium","Fetprofile"]
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
@@ -50,7 +53,7 @@ class Neuigkeit < ActiveRecord::Base
self.title
end
def text_first_words
- md = /(?[\w\s,\.!\?]*)/.match self.text
+ md = /(?[^\<\>]*)/.match Sanitize.clean(self.text,:elements=>['p'])
words=md[:text].split(" ") unless md.nil?
if words.nil? || words.empty?
"...."
diff --git a/app/models/nlink.rb b/app/models/nlink.rb
new file mode 100644
index 0000000..368cc4e
--- /dev/null
+++ b/app/models/nlink.rb
@@ -0,0 +1,10 @@
+class Nlink < ActiveRecord::Base
+ attr_accessible :link_id, :link_type, :neuigkeit_id, :neuigkeit,:link, :sort, :title
+ belongs_to :neuigkeit
+ belongs_to :link, :polymorphic=>true
+ validates :neuigkeit, :presence=>true
+ validates :link, :presence=>true
+ validates :link_id, :uniqueness=>{:scope=>[:neuigkeit_id]}
+
+
+end
diff --git a/app/models/semester.rb b/app/models/semester.rb
index 2adb3aa..1f556b6 100755
--- a/app/models/semester.rb
+++ b/app/models/semester.rb
@@ -22,7 +22,7 @@ class Semester < ActiveRecord::Base
if self.nummer == 0
return I18n.t("ohnezuordnung") + " (" + self.studium.name + ")"
else
- return self.nummer.to_s + ". " + self.studium.name
+ return self.nummer.to_s + "."+I18n.t("semester.semester")+", " + self.studium.name
end
end
def name_kurz
diff --git a/app/models/studium.rb b/app/models/studium.rb
index 4cd722d..51afdf1 100755
--- a/app/models/studium.rb
+++ b/app/models/studium.rb
@@ -27,19 +27,26 @@
# 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
+ attr_accessible :desc, :name,:abkuerzung, :typ, :zahl, :semester, :picture, :picture_cache, :qualifikation,:struktur, :jobmoeglichkeiten
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 :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
- translates :desc,:shortdesc, :versioning =>true,:fallbacks_for_empty_translations => true
+ 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
+ has_many :nlinks, as: :link
+ def title
+ self.name
+ end
def batch_add_semester
# Semester automatisch zu Studien hinzufügen
if self.typ == "Bachelor"
@@ -65,7 +72,11 @@ class Studium < ActiveRecord::Base
def desc_first_words
md = /(?[\w\s,\.!\?]*)/.match self.desc
- md[:text].split(" ")[0..100].join(" ")+ " ..." unless md.nil?
+ unless md.nil?
+ md[:text].split(" ")[0..100].join(" ")+ " ..."
+ else
+ ""
+ end
end
end
diff --git a/app/models/thema.rb b/app/models/thema.rb
index 58097ac..c32149c 100644
--- a/app/models/thema.rb
+++ b/app/models/thema.rb
@@ -16,9 +16,22 @@ class Thema < ActiveRecord::Base
has_many :attachments
belongs_to :themengruppe, :foreign_key => "themengruppe_id"
has_one :gremium
+ has_many :nlinks, as: :link
validates :themengruppe, :presence => true
validates :title, :presence => true
+ validates :text, :presence => true
scope :search, ->(query) {where("text like ? or title like ?", "%#{query}%", "%#{query}%")}
-
translates :title,:text, :versioning =>true, :fallbacks_for_empty_translations => true
+
+ def text_first_words
+ md = /(?[^\<\>]*)/.match Sanitize.clean(self.text,:elements=>['p'])
+ words=md[:text].split(" ") unless md.nil?
+ if words.nil? || words.empty?
+ "...."
+ else
+ words[0..100].join(" ")+ " ..." unless words.nil?
+
+ end
+ end
+
end
diff --git a/app/models/themengruppe.rb b/app/models/themengruppe.rb
index 5a6b973..ca42007 100644
--- a/app/models/themengruppe.rb
+++ b/app/models/themengruppe.rb
@@ -10,12 +10,14 @@
class Themengruppe < ActiveRecord::Base
WORD_COUNT = 50
- attr_accessible :text, :title, :picture,:priority
+ attr_accessible :text, :title, :picture, :priority
has_many :themen, class_name: 'Thema'
has_many :fragen, through: :themen
+
mount_uploader :picture, PictureUploader
validates :title, :presence => true
+ validates :text, :presence => true
translates :title,:text, :versioning =>true, :fallbacks_for_empty_translations => true
end
diff --git a/app/views/beispiele/show.html.erb b/app/views/beispiele/show.html.erb
deleted file mode 100755
index 49501a7..0000000
--- a/app/views/beispiele/show.html.erb
+++ /dev/null
@@ -1,18 +0,0 @@
-<%= notice %>
-
-
- Name:
- <%= @beispiel.name %>
-
-
-
- Desc:
- <%= @beispiel.desc %>
- <%= @beispiel.beispieldatei.url %>
-
-
- <%= @beispiel.lva.name %>
-
-
-<%= link_to 'Edit', edit_beispiel_path(@beispiel) %> |
-<%= link_to 'Back', beispiele_path %>
diff --git a/app/views/calentries/_calentry.html.erb b/app/views/calentries/_calentry.html.erb
index 7d2ec02..a187212 100644
--- a/app/views/calentries/_calentry.html.erb
+++ b/app/views/calentries/_calentry.html.erb
@@ -1,5 +1,7 @@
-<%= image_tag("/iconnavy/time.png") %>
+<% image_tag("/iconnavy/time.png") %>
+<%= fa_icon("calendar 2x") %>
+
<% if calentry.start.to_date == calentry.ende.to_date
format=:timeonly
else
diff --git a/app/views/calentries/_nested_fields.html.erb b/app/views/calentries/_nested_fields.html.erb
index b29f4fe..e4fc987 100644
--- a/app/views/calentries/_nested_fields.html.erb
+++ b/app/views/calentries/_nested_fields.html.erb
@@ -1,6 +1,7 @@
-<%= image_tag("/icon_kalender_small.png") %>
+<%= fa_icon("calendar 2x") %>
+
<%= f.input :start, :as => :datepicker %>
diff --git a/app/views/fetprofiles/_nlink.html.erb b/app/views/fetprofiles/_nlink.html.erb
new file mode 100644
index 0000000..b3362c1
--- /dev/null
+++ b/app/views/fetprofiles/_nlink.html.erb
@@ -0,0 +1 @@
+
<%= nlink.title %>
diff --git a/app/views/fetprofiles/index.html.erb b/app/views/fetprofiles/index.html.erb
index a36b5b2..d80a255 100644
--- a/app/views/fetprofiles/index.html.erb
+++ b/app/views/fetprofiles/index.html.erb
@@ -41,7 +41,7 @@
- <%= link_to I18n.t('fetprofiles.new'), new_fetprofile_path %>
+ <%= link_to I18n.t('profile.new_profile'), new_fetprofile_path %>
diff --git a/app/views/galleries/_nlink.html.erb b/app/views/galleries/_nlink.html.erb
new file mode 100644
index 0000000..72f2216
--- /dev/null
+++ b/app/views/galleries/_nlink.html.erb
@@ -0,0 +1,21 @@
+
diff --git a/app/views/galleries/index.html.erb b/app/views/galleries/index.html.erb
index 68a8a8f..ed4bb87 100644
--- a/app/views/galleries/index.html.erb
+++ b/app/views/galleries/index.html.erb
@@ -25,6 +25,27 @@
+
<% end %>
<% end %>
diff --git a/app/views/gremien/index.html.erb b/app/views/gremien/index.html.erb
index 3bbbb1d..6ea21ef 100644
--- a/app/views/gremien/index.html.erb
+++ b/app/views/gremien/index.html.erb
@@ -12,7 +12,7 @@
<%= link_to g do %>
<%= g.name %>
- <%= g.desc %>
+ <%= g.desc.html_safe %>
<% end %>
<% end %>
diff --git a/app/views/gremien/show.html.erb b/app/views/gremien/show.html.erb
index fe7b2e2..5880e93 100644
--- a/app/views/gremien/show.html.erb
+++ b/app/views/gremien/show.html.erb
@@ -11,7 +11,11 @@
<%= @gremium.desc.html_safe %>
<% unless @gremium.thema.nil? %>
- <%= link_to "Mehr zum Gremium lesen ..." ,themengruppe_path(@gremium.thema.themengruppe , {:thema=>@gremium.thema.id})%>
+
+<%= link_to thema_path(@gremium.thema) do%>
+<%= fa_icon "book 2x border" %> Mehr über <%=@gremium.fall4 %> erfahren
+<% end %>
+
<% end %>
diff --git a/app/views/gremien/verwalten.html.erb b/app/views/gremien/verwalten.html.erb
index 3348678..38a339e 100644
--- a/app/views/gremien/verwalten.html.erb
+++ b/app/views/gremien/verwalten.html.erb
@@ -39,7 +39,7 @@
<%= render 'layouts/pretty_toolbar' %>
-<%= link_to 'New Gremium', new_gremium_path %>
+
diff --git a/app/views/home/_search_results.html.erb b/app/views/home/_search_results.html.erb
index 9989e84..b4153fb 100644
--- a/app/views/home/_search_results.html.erb
+++ b/app/views/home/_search_results.html.erb
@@ -28,10 +28,11 @@
<% end %>
<% @themen.each do |thema| %>
-
- - <%= link_to thema, {:class=>"linkbox"} do %>
+
+ - <%= link_to thema.title,thema %>
+
<%= render :partial=>"themen/small", :object=>thema %>
-<% end %>
+
<% end %>
diff --git a/app/views/home/index.html.erb b/app/views/home/index.html.erb
index 50c915a..87417d4 100755
--- a/app/views/home/index.html.erb
+++ b/app/views/home/index.html.erb
@@ -7,7 +7,7 @@
<% end %>
-<%= link_to "FET Login", user_omniauth_authorize_path(:ldap) %>
+<%= link_to I18n.t('home.login'), user_omniauth_authorize_path(:ldap) %>
Beta Test
@@ -23,12 +23,12 @@
<%= link_to "Steuerelemente und Komponenten", "http://getbootstrap.com/2.3.2/index.html" %>
Um bei der Entwicklung mitzuhelfen braucht nur Ruby on Rails installiert werden
-
<%= link_to "Getting Started" , home_startdev_path%>
+
<%= link_to "Getting Started" , startdev_home_index_path %>
Das Kalender Feature wird überarbeitet, in Zukunft soll folgender Link nicht mehr funktionieren <%= link_to "Kalender", calendars_path %>
- <%= link_to "Entwicklungsstatus" , home_dev_path %>
+ <%= link_to "Entwicklungsstatus" , dev_home_index_path %>
<%= render 'beispiele' %>
Verschiedene Styles
diff --git a/app/views/home/kontakt.html.erb b/app/views/home/kontakt.html.erb
new file mode 100644
index 0000000..48cb162
--- /dev/null
+++ b/app/views/home/kontakt.html.erb
@@ -0,0 +1 @@
+<%= I18n.t "home.kontakt" %>
diff --git a/app/views/home/search.html.erb b/app/views/home/search.html.erb
index a22bf16..e45c142 100644
--- a/app/views/home/search.html.erb
+++ b/app/views/home/search.html.erb
@@ -1,6 +1,6 @@
-<%= semantic_form_for :search,:remote=>true, :url=>search_home_index_path, :html=>{:id=>"search_form", :method=>'get'} do |f| %>
-<%= f.input :query, :input_html => { :name => 'query' } %>
+<%= semantic_form_for :search,:remote=>true, :url=>search_home_index_path, :html=>{:id=>"search_form",:class=>"navbar-search", :method=>'get'} do |f| %>
+<%= f.input :query, :input_html => { :name => 'query' } , :label=>false, :class=>"search-query" %>
<% end %>