weitere classen durchsuchen

This commit is contained in:
Andreas Stephanides
2014-11-12 21:24:18 +01:00
parent e9245919c3
commit dc124e3810
18 changed files with 99 additions and 19 deletions

View File

@@ -32,7 +32,7 @@ class HomeController < ApplicationController
def search def search
unless params['query'].nil? || params['query'].empty? unless params['query'].nil? || params['query'].empty?
@results = Sunspot.search Neuigkeit, Fetprofile do @results = Sunspot.search Neuigkeit,Rubrik, Fetprofile, Thema, Themengruppe, Lva, Studium, Modul, Modulgruppe do
fulltext params['query'] fulltext params['query']
end end
@neuigkeiten=[]; @neuigkeiten=[];
@@ -43,11 +43,12 @@ class HomeController < ApplicationController
end end
# @fetprofiles = Fetprofile.search(params['query']) # @fetprofiles = Fetprofile.search(params['query'])
@fetprofiles=[] @fetprofiles=[]
if can?(:showintern, Neuigkeit) # if can?(:showintern, Neuigkeit)
@themen=Thema.search(params['query']) # @themen=Thema.search(params['query'])
else # else
@themen=Thema.search(params['query']).public # @themen=Thema.search(params['query']).public
end # end
@themen=[]
else else
@neuigkeiten=[] @neuigkeiten=[]

View File

@@ -198,6 +198,15 @@ class Lva < ActiveRecord::Base
newlvas newlvas
end end
searchable do
text :desc
text :pruefungsinformation
text :lernaufwand
text :typ
text :name, :boost=>3.0
end
def self.update_multiple_with_modul(hash,modul) def self.update_multiple_with_modul(hash,modul)
newlvas=[] newlvas=[]
hash.each do |i,l| hash.each do |i,l|

View File

@@ -53,4 +53,9 @@ class Modul < ActiveRecord::Base
end end
m m
end end
searchable do
text :desc
text :name, :boost=>3.0
end
end end

View File

@@ -32,4 +32,10 @@ class Modulgruppe < ActiveRecord::Base
def studium_name def studium_name
self.studium.nil? ? "Kein Studium vorhanden" : self.studium.name self.studium.nil? ? "Kein Studium vorhanden" : self.studium.name
end end
searchable do
text :desc
text :typ
text :name, :boost=>3.0
end
end end

View File

@@ -84,7 +84,8 @@ class Neuigkeit < ActiveRecord::Base
end end
end end
searchable do searchable do
text :text, :datum text :text
text :datum
text :title, :boost=>3.0 text :title, :boost=>3.0
end end
end end

View File

@@ -35,4 +35,10 @@ end
self.calendar.public=self.public self.calendar.public=self.public
self.calendar.save self.calendar.save
end end
searchable do
text :desc
text :name, :boost=>4.0
end
end end

View File

@@ -84,5 +84,12 @@ validates :abkuerzung, :length=>{:maximum=>5}, :format=>{:with=>/^[a-zA-z]{0,5}$
"" ""
end end
end end
searchable do
text :desc
text :zahl
text :typ
text :abkuerzung
text :name, :boost=>3.0
end
end end

View File

@@ -23,7 +23,13 @@ include Rails.application.routes.url_helpers
validates :text, :presence => true validates :text, :presence => true
scope :public, where(:isdraft=>false).includes(:themengruppe).where("themengruppen.public"=>true) scope :public, where(:isdraft=>false).includes(:themengruppe).where("themengruppen.public"=>true)
default_scope order("themen.priority").reverse_order default_scope order("themen.priority").reverse_order
scope :search, ->(query) {where("themen.text like ? or themen.title like ?", "%#{query}%", "%#{query}%")} # scope :search, ->(query) {where("themen.text like ? or themen.title like ?", "%#{query}%", "%#{query}%")}
searchable do
text :text
text :title, :boost=>4.0
end
scope :outdated, -> {includes(:translations).where("thema_translations.updated_at<?",2.month.ago).where("thema_translations.locale"=>I18n.t.locale) scope :outdated, -> {includes(:translations).where("thema_translations.updated_at<?",2.month.ago).where("thema_translations.locale"=>I18n.t.locale)
} }
translates :title,:text, :versioning =>true, :fallbacks_for_empty_translations => true translates :title,:text, :versioning =>true, :fallbacks_for_empty_translations => true

View File

@@ -36,4 +36,9 @@ end
self.save; self.save;
end end
searchable do
text :text
text :title, :boost=>4.0
end
end end

View File

@@ -1,8 +1,17 @@
<% unless @results.nil? %> <% unless @results.nil? %>
<%= @results.results.each do |res| %> <ul class="unstyled linkbox-list">
<%= render res %> <% @results.results.each do |res| %>
<% if can?(:show, res) %>
<li>
<%= link_to res, :class=>:linkbox do %>
<%= render :partial=>res.class.to_s.pluralize.downcase+"/nlink", :object=>res %>
<% end %> <% end %>
</li>
<% end %>
<% end %>
</ul>
<% end %> <% end %>
<% unless @neuigkeiten.empty? %> <% unless @neuigkeiten.empty? %>

View File

@@ -0,0 +1 @@
<h2><%= nlink.name %></h2>

View File

@@ -1,9 +1,9 @@
<h1><%= @modul.name %></h1> <h1><%= modul.name %></h1>
<div class="row-fluid"> <div class="row-fluid">
<div class="span8"> <div class="span8">
<h2><%=I18n.t("modul.lvas")%></h2> <h2><%=I18n.t("modul.lvas")%></h2>
<% @modul.lvas.each_slice(3) do |row| %> <% modul.lvas.each_slice(3) do |row| %>
<ul> <ul>
<% row.each do |lv| %> <% row.each do |lv| %>
<li> <li>
@@ -14,14 +14,14 @@
<% end %> <% end %>
<h2><%=I18n.t("modul.desc")%></h2> <h2><%=I18n.t("modul.desc")%></h2>
<p> <p>
<%= raw(@modul.desc) %> <%= raw(modul.desc) %>
</p> </p>
</div> </div>
<div class="span4"> <div class="span4">
<div class="lva-sidebar"> <div class="lva-sidebar">
<h2><%=I18n.t("modul.mgs")%></h2> <h2><%=I18n.t("modul.mgs")%></h2>
<ul> <ul>
<% @modul.modulgruppen.each do |mg| %> <% modul.modulgruppen.each do |mg| %>
<li> <li>
<%= render 'modulgruppen/kurz', :modulgruppe=>mg %> <%= render 'modulgruppen/kurz', :modulgruppe=>mg %>
</li> </li>

View File

@@ -0,0 +1,2 @@
Modul:
<%= nlink.name %>

View File

@@ -0,0 +1,3 @@
<h2> <%= nlink.title %> </h2>

View File

@@ -0,0 +1,3 @@
<h2 ><%= nlink.name %></h2>

View File

View File

@@ -1,2 +1,17 @@
<h2><%= nlink.name %></h2> <% studium=nlink %>
<p><%= nlink.desc_first_words %></p> <div class="media">
<% unless studium.picture.thumb.url.nil? %>
<div class="pull-left">
<%= image_tag studium.picture.thumb.url %>
</div>
<% end %>
<div class="media-body">
<h2>
<%= studium.name + " " + studium.zahl.to_s %>
</h2>
<p>
<b><%= studium.typ%> </b>
</p>
</div>
</div>

View File

@@ -0,0 +1 @@
<h2><%= nlink.title %> </h2>