Merge branch 'master' of https://github.com/fetsite/fetsite
This commit is contained in:
@@ -19,7 +19,7 @@ class MembershipsController < ApplicationController
|
||||
# POST /memberships.json
|
||||
def create
|
||||
@membership = Membership.new(params[:membership])
|
||||
|
||||
@membership.fetprofile= Fetprofle.find(params[:fetprofile_id])
|
||||
respond_to do |format|
|
||||
if @membership.save
|
||||
format.html { redirect_to @membership.fetprofile, notice: 'Membership was successfully created.' }
|
||||
|
||||
@@ -10,6 +10,9 @@ class NeuigkeitenController < ApplicationController
|
||||
@neuigkeit = Neuigkeit.find(params[:id])
|
||||
if can? :edit, @neuigkeit
|
||||
@toolbar_elements << {:text=>I18n.t('common.edit'),:path=>edit_neuigkeit_path(@neuigkeit),:icon=>:pencil}
|
||||
@toolbar_elements << {:hicon=>'icon-remove-circle', :text=> I18n.t('common.delete'),:path => neuigkeit_path(@neuigkeit), :method=> :delete,:confirm=>"Sure?" }
|
||||
@toolbar_elements << {:hicon=>'icon-plus', :text=> "publish",:path => neuigkeit_publish_path(@neuigkeit),:confirm=>"Sure?" }
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -19,14 +22,19 @@ class NeuigkeitenController < ApplicationController
|
||||
@neuigkeit.rubrik=@rubrik unless @rubrik.nil?
|
||||
end
|
||||
|
||||
|
||||
def publish
|
||||
@neuigkeit = Neuigkeit.find(params[:id])
|
||||
@neuigkeit.publish
|
||||
@neuigkeit.save
|
||||
redirect_to @neuigkeit
|
||||
end
|
||||
def edit
|
||||
@neuigkeit = Neuigkeit.find(params[:id])
|
||||
end
|
||||
|
||||
def create
|
||||
@neuigkeit = Neuigkeit.new(params[:neuigkeit])
|
||||
@rubrik = @neuigkeit.rubrik
|
||||
|
||||
|
||||
respond_to do |format|
|
||||
if @neuigkeit.save
|
||||
|
||||
@@ -3,7 +3,7 @@ class RubrikenController < ApplicationController
|
||||
load_and_authorize_resource
|
||||
def index
|
||||
@rubriken = Rubrik.all
|
||||
|
||||
@neuigkeiten = Neuigkeit.recent
|
||||
end
|
||||
|
||||
|
||||
|
||||
@@ -15,4 +15,5 @@ class Calendar < ActiveRecord::Base
|
||||
has_and_belongs_to_many :calentries
|
||||
mount_uploader :picture, PictureUploader
|
||||
resourcify
|
||||
scope :public, -> { where(:public => :true) }
|
||||
end
|
||||
|
||||
@@ -16,14 +16,21 @@ class Calentry < ActiveRecord::Base
|
||||
has_and_belongs_to_many :calendars
|
||||
validates :start, :presence => true
|
||||
validates :typ, :presence => true
|
||||
before_save :get_public
|
||||
belongs_to :object, polymorphic: true
|
||||
|
||||
validate do |entry|
|
||||
if entry.ende.nil?
|
||||
errors.add(:ende, "Es muss ein Endzeitpunkt vorhanden sein")
|
||||
end
|
||||
end
|
||||
belongs_to :object, polymorphic: true
|
||||
|
||||
|
||||
resourcify
|
||||
def get_public
|
||||
self.public = (self.try(:object).nil?)? (self.calendars.public.count>0) : object.try(:public)
|
||||
true
|
||||
end
|
||||
def start_time
|
||||
start
|
||||
end
|
||||
@@ -33,5 +40,6 @@ class Calentry < ActiveRecord::Base
|
||||
def name
|
||||
summary
|
||||
end
|
||||
scope :public, -> { where(:public => :true) }
|
||||
scope :upcoming, -> { where("start >= ?" , Time.now).where("start <= ?", 8.days.from_now) }
|
||||
end
|
||||
|
||||
@@ -14,14 +14,30 @@
|
||||
|
||||
class Neuigkeit < ActiveRecord::Base
|
||||
|
||||
attr_accessible :datum, :text, :title, :rubrik_id, :author_id
|
||||
attr_accessible :datum, :text, :title, :rubrik_id, :author_id,:picture
|
||||
belongs_to :author, :class_name =>'User'
|
||||
belongs_to :rubrik, :class_name =>'Rubrik', :foreign_key => "rubrik_id"
|
||||
validates :rubrik, :presence=>true
|
||||
validates :author, :presence=>true
|
||||
translates :title,:text, :versioning=>true, :fallbacks_for_empty_translations => true
|
||||
|
||||
scope :published, -> {where("datum >= ?", Time.now.to_date)}
|
||||
scope :recent, -> { where("updated_at >= ? ",Time.now - 7.days)}
|
||||
|
||||
has_one :calentry, :as => :object
|
||||
mount_uploader :picture, PictureUploader
|
||||
scope :published, -> {where("datum >= ? AND datum IS NOT NULL", Time.now.to_date)}
|
||||
scope :recent, -> { published.where("updated_at >= ? ",Time.now - 7.days)}
|
||||
def datum_nilsave
|
||||
self.datum.nil? ? Time.now + 42.years : self.datum
|
||||
end
|
||||
def public
|
||||
self.rubrik.public && self.datum >=Time.now.to_date
|
||||
end
|
||||
def publish
|
||||
self.datum = Time.now
|
||||
end
|
||||
def reverse_publish
|
||||
self.datum = nil
|
||||
end
|
||||
def text_first_words
|
||||
md = /<p>(?<text>[\w\s,\.!\?]*)/.match self.text
|
||||
md[:text].split(" ")[1..100].join(" ")+ " ..."
|
||||
end
|
||||
end
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
class Rubrik < ActiveRecord::Base
|
||||
attr_accessible :desc, :name, :prio
|
||||
has_many :neuigkeiten, :class_name => "Neuigkeit"
|
||||
has_many :calentries, :through => :neuigkeiten, :as=>:object
|
||||
resourcify
|
||||
def moderator
|
||||
u=User.with_role(:newsmoderator).first
|
||||
|
||||
@@ -35,7 +35,10 @@ class PictureUploader < CarrierWave::Uploader::Base
|
||||
version :thumb do
|
||||
process :resize_to_fill => [64, 64]
|
||||
end
|
||||
version :big_thumb do
|
||||
process :resize_to_fill => [200,200]
|
||||
|
||||
end
|
||||
version :portrait do
|
||||
process :resize_to_fill => [128,192]
|
||||
end
|
||||
|
||||
@@ -2,8 +2,9 @@
|
||||
<h2><%= link_to modulgruppe.name, modulgruppe_path(modulgruppe) %>
|
||||
</h2>
|
||||
|
||||
<%= modulgruppe.desc%>
|
||||
<%= modulgruppe.desc%><ul>
|
||||
<%= render :partial=>'moduls/kurz', :collection=>modulgruppe.moduls, :as=>:modul%>
|
||||
</ul>
|
||||
<br>
|
||||
|
||||
<% link_to '<i class="icon-pencil"></i>'.html_safe+I18n.t("common.edit"), edit_modulgruppe_path(modulgruppe) %>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<div style="border: solid 1px; padding:2px;margin-top:5px;"><p>
|
||||
<li><p>
|
||||
<b><% if !modul.name.nil? %><%= link_to "Modul "+ modul.name , modul_path(modul) %> <%end%></b>
|
||||
</p>
|
||||
<% link_to '<i class="icon-pencil"></i>'.html_safe+I18n.t("common.edit"), edit_modul_path(modul) %>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
|
||||
@@ -12,17 +12,24 @@
|
||||
|
||||
</div>
|
||||
<div class="span4">
|
||||
<div class="lva-sidebar">
|
||||
<h2>Modulgruppen</h2>
|
||||
<ul>
|
||||
<% @modul.modulgruppen.each do |mg| %>
|
||||
<%= render 'modulgruppen/kurz', :modulgruppe=>mg %><br>
|
||||
<li>
|
||||
<%= render 'modulgruppen/kurz', :modulgruppe=>mg %>
|
||||
</li>
|
||||
<% end %>
|
||||
|
||||
</ul>
|
||||
<h2>Lvas</h2>
|
||||
<% @modul.lvas.each_slice(3) do |row| %>
|
||||
<ul>
|
||||
<% row.each do |lv| %>
|
||||
<li>
|
||||
<%= render 'lvas/lva_semester', :lva=>lv%>
|
||||
</li>
|
||||
<% end %>
|
||||
|
||||
</ul>
|
||||
<% end %>
|
||||
|
||||
</div>
|
||||
</div></div>
|
||||
|
||||
@@ -3,9 +3,10 @@
|
||||
<%= f.inputs do %>
|
||||
<%= f.input :title, :placeholder=>"Titel" %>
|
||||
<%= f.input :text, :as=>:tinymce_text %>
|
||||
<%= f.input :datum %>
|
||||
<% f.input :datum %>
|
||||
<%= f.input :rubrik, :as=>:radio, :collection=>Rubrik.all %>
|
||||
<%= f.input :author, :as=>:radio %>
|
||||
<%= f.input :picture, :as=>:file %>
|
||||
<% end %>
|
||||
|
||||
<%= f.actions do %>
|
||||
|
||||
@@ -1,6 +1,15 @@
|
||||
|
||||
<h2><%= link_to neuigkeit.title,neuigkeit_path(neuigkeit) %></h2>
|
||||
<%= if !neuigkeit.author.nil?
|
||||
neuigkeit.author.email
|
||||
end %>
|
||||
<p><%= raw(neuigkeit.text) %></p>
|
||||
|
||||
<div class="media">
|
||||
<div class="pull-left" href="#">
|
||||
<p><br><%= image_tag neuigkeit.picture.thumb.url unless neuigkeit.picture.url.nil? %></p>
|
||||
</div>
|
||||
<div class="media-body"><div><small><%= neuigkeit.rubrik.name %></small>
|
||||
<small class="pull-right"><%= "am "+ I18n.l(neuigkeit.try(:datum).try(:to_date)) unless neuigkeit.try(:datum).try(:to_date).nil? %></small> </div>
|
||||
<h1><%= link_to neuigkeit.title,neuigkeit_path(neuigkeit) %></h1>
|
||||
<%= raw(neuigkeit.text_first_words) unless neuigkeit.text.nil?%>
|
||||
<%= link_to "more" , neuigkeit_path(neuigkeit) %>
|
||||
<p></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -9,20 +9,22 @@
|
||||
<div class="span9">
|
||||
<%= @neuigkeit.rubrik.name %>
|
||||
</div>
|
||||
<div class="span3"><p>
|
||||
<%= @neuigkeit.try(:author).email.to_s %> am
|
||||
<%= I18n.l @neuigkeit.datum.to_date %></p>
|
||||
<div class="span3">
|
||||
|
||||
<%= @neuigkeit.author.email.to_s unless @neuigkeit.try(:author).try(:email).to_s %>
|
||||
<%= "am " + I18n.l(@neuigkeit.try(:datum).try(:to_date)) unless @neuigkeit.try(:datum).try(:to_date).nil? %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row-fluid">
|
||||
<div class="span12">
|
||||
<div class="media">
|
||||
<div class="pull-right" href="#">
|
||||
<p><br><%= "FOTO" %></p>
|
||||
<div class="pull-left" href="#">
|
||||
<p><br><%= link_to image_tag(@neuigkeit.picture.big_thumb.url),@neuigkeit.picture.url %></p>
|
||||
</div>
|
||||
<div class="media-body">
|
||||
<h1><%= link_to @neuigkeit.title,neuigkeit_path(@neuigkeit) %></h1>
|
||||
<%= raw(@neuigkeit.text) %>
|
||||
<p></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
<%= render 'tabs' %>
|
||||
<h1><%= I18n.t("rubrik.title")%></h1>
|
||||
<% @rubriken.each do |rubrik| %>
|
||||
|
||||
<% rubrik.neuigkeiten.recent.each do |n| %>
|
||||
<li><%= link_to n.title+"("+rubrik.name+")" , n %> </li>
|
||||
<% end %>
|
||||
<%= link_to 'Weitere Artikel zu '+rubrik.name.to_s , rubrik %>
|
||||
<ul class="unstyled"
|
||||
<% @neuigkeiten.each do |n| %>
|
||||
|
||||
<li><%= render n %> </li>
|
||||
<% end %>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
<% row.each do |neuigkeit| %>
|
||||
<div class="span6 min-width:13em;">
|
||||
<%= render neuigkeit %>
|
||||
<%= link_to "more" , neuigkeit_path(neuigkeit) %>
|
||||
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<div class="studium">
|
||||
<h2><%= link_to studium.name + " " + studium.zahl.to_s, studium_path(studium, :ansicht=>'semesteransicht')%></h2> <p><b><%= studium.typ%> </b></p>
|
||||
<p><b>Beschreibung:</b><br>
|
||||
<p><b><%=I18n.t("studien.desc")%>:</b><br>
|
||||
<%= !(studium.desc.to_s == "") ? studium.desc.html_safe : I18n.t("keine.beschreibung")%></p>
|
||||
|
||||
</div>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<% else %>
|
||||
<li>
|
||||
<% end %>
|
||||
<%= link_to "Alle Studien", studien_path %> </li>
|
||||
<%= link_to I18n.t("studien.allestudien"), studien_path %> </li>
|
||||
<% for s in Studium.all %>
|
||||
<% if !@studium.nil? && s == @studium %>
|
||||
|
||||
@@ -20,6 +20,6 @@
|
||||
<% else %>
|
||||
<li class="pull-right">
|
||||
<% end %>
|
||||
<%= link_to "Verwaltung", studien_verwalten_path %>
|
||||
<%= link_to I18n.t("studien.verwaltung.title"), studien_verwalten_path %>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<div class="span8">
|
||||
<h2><%= sem.name %></h2>
|
||||
</div>
|
||||
<div class="span4"><div class="pull-right"><%= link_to 'Lvas hinzufügen/entfernen', edit_semester_path(sem), :class=>"btn-small"%></div>
|
||||
<div class="span4"><div class="pull-right"><%= link_to I18n.t("lva.addrem"), edit_semester_path(sem), :class=>"btn-small"%></div>
|
||||
</div></div>
|
||||
<% sem.lvas.each do |lva| %>
|
||||
<div class="row-fluid">
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
de:
|
||||
studien:
|
||||
desc: "Beschreibung"
|
||||
studien: "Studien"
|
||||
list: "Studien der Fakultät Elektrotechnik"
|
||||
anzeigen: "Studium anzeigen"
|
||||
@@ -21,6 +22,7 @@ de:
|
||||
beschreibung: "Keine Beschreibung vorhanden"
|
||||
lva:
|
||||
add: "Lva hinzufügen"
|
||||
addrem: "Lva hinzufügen/entfernen"
|
||||
list: "Alle Lvas"
|
||||
semester:
|
||||
ohne: "Ohne Semesterzuordnung"
|
||||
|
||||
@@ -52,6 +52,7 @@
|
||||
resources :fragen
|
||||
get 'rubriken/verwalten', :controller=>:rubriken, :action=>:alle_verwalten, :as=>'alle_verwalten_rubrik'
|
||||
|
||||
get 'neuigkeiten/:id/publish', :controller=>:neuigkeiten, :action=>:publish, :as=>'neuigkeit_publish'
|
||||
resources :rubriken do
|
||||
resources :neuigkeiten, :only=>[:new, :show]
|
||||
end
|
||||
|
||||
@@ -3,13 +3,13 @@ class TranslateLvas < ActiveRecord::Migration
|
||||
Lva.create_translation_table!({
|
||||
:desc => :text
|
||||
}, {
|
||||
#:migrate_data => true
|
||||
:migrate_data => true
|
||||
})
|
||||
|
||||
|
||||
end
|
||||
|
||||
def self.down
|
||||
Lva.drop_translation_table! #:migrate_data => true
|
||||
Lva.drop_translation_table! :migrate_data => true
|
||||
end
|
||||
end
|
||||
14
db/migrate/20130823084252_add_object_to_calentries.rb
Normal file
14
db/migrate/20130823084252_add_object_to_calentries.rb
Normal file
@@ -0,0 +1,14 @@
|
||||
class AddObjectToCalentries < ActiveRecord::Migration
|
||||
def up
|
||||
add_column :calentries,:object_id, :integer
|
||||
add_column :calentries,:object_type, :string
|
||||
add_column :calentries, :public, :boolean
|
||||
Calentry.update_all(:public => :true)
|
||||
end
|
||||
|
||||
def down
|
||||
remove_column :calentries, :object_id
|
||||
remove_column :calentries,:object_type
|
||||
remove_column :calentries,:public
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,9 @@
|
||||
class AddPublicToRubrikneuigkeiten < ActiveRecord::Migration
|
||||
def up
|
||||
add_column :rubriken, :public,:boolean
|
||||
Rubrik.update_all(:public => :true)
|
||||
end
|
||||
def down
|
||||
remove_column :rubriken, :public
|
||||
end
|
||||
end
|
||||
5
db/migrate/20130823114945_add_picture_to_neuigkeiten.rb
Normal file
5
db/migrate/20130823114945_add_picture_to_neuigkeiten.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class AddPictureToNeuigkeiten < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :neuigkeiten,:picture,:string
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user