nettere Kalendereinttragsbearbeitung
This commit is contained in:
@@ -2,14 +2,14 @@ class CalentriesController < ApplicationController
|
|||||||
# GET /calentries
|
# GET /calentries
|
||||||
# GET /calentries.json
|
# GET /calentries.json
|
||||||
load_and_authorize_resource
|
load_and_authorize_resource
|
||||||
def index
|
# def index
|
||||||
@calentries = Calentry.all
|
# @calentries = Calentry.all
|
||||||
|
|
||||||
respond_to do |format|
|
# respond_to do |format|
|
||||||
format.html # index.html.erb
|
# format.html # index.html.erb
|
||||||
format.json { render json: @calentries }
|
# format.json { render json: @calentries }
|
||||||
end
|
# end
|
||||||
end
|
# end
|
||||||
|
|
||||||
# GET /calentries/1
|
# GET /calentries/1
|
||||||
# GET /calentries/1.json
|
# GET /calentries/1.json
|
||||||
@@ -25,35 +25,36 @@ class CalentriesController < ApplicationController
|
|||||||
|
|
||||||
# GET /calentries/new
|
# GET /calentries/new
|
||||||
# GET /calentries/new.json
|
# GET /calentries/new.json
|
||||||
def new
|
# def new
|
||||||
@calentry = Calentry.new
|
# @calentry = Calentry.new
|
||||||
|
|
||||||
respond_to do |format|
|
# respond_to do |format|
|
||||||
format.html # new.html.erb
|
# format.html # new.html.erb
|
||||||
format.json { render json: @calentry }
|
# format.json { render json: @calentry }
|
||||||
end
|
# end
|
||||||
end
|
# end
|
||||||
|
|
||||||
# GET /calentries/1/edit
|
# GET /calentries/1/edit
|
||||||
def edit
|
#def edit
|
||||||
@calentry = Calentry.find(params[:id])
|
# @calentry = Calentry.find(params[:id])
|
||||||
end
|
|
||||||
|
# end
|
||||||
|
|
||||||
# POST /calentries
|
# POST /calentries
|
||||||
# POST /calentries.json
|
# POST /calentries.json
|
||||||
def create
|
# def create
|
||||||
@calentry = Calentry.new(params[:calentry])
|
# @calentry = Calentry.new(params[:calentry])
|
||||||
|
|
||||||
respond_to do |format|
|
# respond_to do |format|
|
||||||
if @calentry.save
|
# if @calentry.save
|
||||||
format.html { redirect_to @calentry, notice: 'Calentry was successfully created.' }
|
# format.html { redirect_to @calentry, notice: 'Calentry was successfully created.' }
|
||||||
format.json { render json: @calentry, status: :created, location: @calentry }
|
# format.json { render json: @calentry, status: :created, location: @calentry }
|
||||||
else
|
# else
|
||||||
format.html { render action: "new" }
|
# format.html { render action: "new" }
|
||||||
format.json { render json: @calentry.errors, status: :unprocessable_entity }
|
# format.json { render json: @calentry.errors, status: :unprocessable_entity }
|
||||||
end
|
# end
|
||||||
end
|
# end
|
||||||
end
|
# end
|
||||||
|
|
||||||
# PUT /calentries/1
|
# PUT /calentries/1
|
||||||
# PUT /calentries/1.json
|
# PUT /calentries/1.json
|
||||||
|
|||||||
@@ -15,8 +15,9 @@
|
|||||||
class Calentry < ActiveRecord::Base
|
class Calentry < ActiveRecord::Base
|
||||||
attr_accessible :ende, :start, :summary, :typ,:calendar_ids, :calendar, :dauer
|
attr_accessible :ende, :start, :summary, :typ,:calendar_ids, :calendar, :dauer
|
||||||
belongs_to :calendar
|
belongs_to :calendar
|
||||||
belongs_to :neuigkeit
|
#belongs_to :neuigkeit
|
||||||
validates :start, :presence => true
|
validates :start, :presence => true
|
||||||
|
validates :object, :presence => true
|
||||||
validates :typ, :presence => true
|
validates :typ, :presence => true
|
||||||
before_save :get_public
|
before_save :get_public
|
||||||
belongs_to :object, polymorphic: true # Objekt zu dem der Calentry gehört (derzeit ein Newsartikel)
|
belongs_to :object, polymorphic: true # Objekt zu dem der Calentry gehört (derzeit ein Newsartikel)
|
||||||
|
|||||||
@@ -20,13 +20,13 @@ class Neuigkeit < ActiveRecord::Base
|
|||||||
validates :rubrik, :presence=>true
|
validates :rubrik, :presence=>true
|
||||||
validates :author, :presence=>true
|
validates :author, :presence=>true
|
||||||
translates :title,:text, :versioning=>true, :fallbacks_for_empty_translations => true
|
translates :title,:text, :versioning=>true, :fallbacks_for_empty_translations => true
|
||||||
has_one :calentry
|
has_one :calentry, inverse_of: :object
|
||||||
mount_uploader :picture, PictureUploader
|
mount_uploader :picture, PictureUploader
|
||||||
scope :published, -> {where("datum <= ? AND datum IS NOT NULL", Time.now.to_date).order(:datum).reverse_order}
|
scope :published, -> {where("datum <= ? AND datum IS NOT NULL", Time.now.to_date).order(:datum).reverse_order}
|
||||||
scope :recent, -> { published.where("updated_at >= ? ",Time.now - 7.days)}
|
scope :recent, -> { published.where("updated_at >= ? ",Time.now - 7.days)}
|
||||||
scope :unpublished, -> {where("datum >= ? OR datum IS NULL", Date.today)}
|
scope :unpublished, -> {where("datum >= ? OR datum IS NULL", Date.today)}
|
||||||
scope :public, ->{includes(:rubrik).where("rubriken.public"=>:true)}
|
scope :public, ->{includes(:rubrik).where("rubriken.public"=>:true)}
|
||||||
accepts_nested_attributes_for :calentry
|
accepts_nested_attributes_for :calentry, :allow_destroy=>true
|
||||||
def datum_nilsave
|
def datum_nilsave
|
||||||
self.datum.nil? ? Time.now + 42.years : self.datum
|
self.datum.nil? ? Time.now + 42.years : self.datum
|
||||||
end
|
end
|
||||||
@@ -39,6 +39,9 @@ accepts_nested_attributes_for :calentry
|
|||||||
def reverse_publish
|
def reverse_publish
|
||||||
self.datum = nil
|
self.datum = nil
|
||||||
end
|
end
|
||||||
|
def name
|
||||||
|
self.title
|
||||||
|
end
|
||||||
def text_first_words
|
def text_first_words
|
||||||
md = /<p>(?<text>[\w\s,\.!\?]*)/.match self.text
|
md = /<p>(?<text>[\w\s,\.!\?]*)/.match self.text
|
||||||
md[:text].split(" ")[0..100].join(" ")+ " ..."
|
md[:text].split(" ")[0..100].join(" ")+ " ..."
|
||||||
|
|||||||
5
app/views/calentries/_calentry.html.erb
Normal file
5
app/views/calentries/_calentry.html.erb
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<div class="contentbox">
|
||||||
|
<%= image_tag("/icon_kalender_small.png") %>
|
||||||
|
|
||||||
|
<%= link_to I18n.l(calentry.start) +" bis "+ I18n.l(calentry.ende), calendar_path(calentry.calendar) %>
|
||||||
|
</div>
|
||||||
9
app/views/calentries/_nested_fields.html.erb
Normal file
9
app/views/calentries/_nested_fields.html.erb
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<div class="row-fluid">
|
||||||
|
<div class="span1"></div><div class="span1">
|
||||||
|
<%= image_tag("/icon_kalender_small.png") %>
|
||||||
|
</div>
|
||||||
|
<div class="span4">
|
||||||
|
<%= f.input :start, :as => :datepicker %></div><div class="span4">
|
||||||
|
<%= f.input :dauer , :as => :string, :append=>"h" %></div><div class="span1">
|
||||||
|
<%= f.input :typ %></div> <div class="span1"><%= f.check_box :_destroy %></div>
|
||||||
|
</div>
|
||||||
@@ -1,17 +1,31 @@
|
|||||||
<%= tinymce_assets %>
|
<%= tinymce_assets %>
|
||||||
|
<div class="container-fluid">
|
||||||
<%= semantic_form_for [@neuigkeit.rubrik,@neuigkeit] do |f| %>
|
<%= semantic_form_for [@neuigkeit.rubrik,@neuigkeit] do |f| %>
|
||||||
<%= f.inputs do %>
|
<%= f.inputs do %>
|
||||||
|
<div class="row-fluid">
|
||||||
|
<div class="span12">
|
||||||
<%= f.input :title, :placeholder=> "Titel" %>
|
<%= f.input :title, :placeholder=> "Titel" %>
|
||||||
<%= f.input :text, :as=> :tinymce_text %>
|
<%= f.input :text, :as=> :tinymce_text %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row-fluid">
|
||||||
|
<div class="span6">
|
||||||
<% f.input :datum, :as=> :datepicker %>
|
<% f.input :datum, :as=> :datepicker %>
|
||||||
<%= f.input :rubrik, :as=> :radio, :collection=>Rubrik.all %>
|
<%= f.input :rubrik, :as=> :radio, :collection=>Rubrik.all %>
|
||||||
<%= f.input :author, :as=> :radio %>
|
</div>
|
||||||
|
<div class="span6">
|
||||||
|
<%= f.input :author, :as=> :select %>
|
||||||
|
</div> </div>
|
||||||
|
<div class="row-fluid">
|
||||||
|
<div class="span12">
|
||||||
<%= f.input :picture, :as=> :file %>
|
<%= f.input :picture, :as=> :file %>
|
||||||
|
</div> </div>
|
||||||
|
|
||||||
<% unless @neuigkeit.calentry.nil? %>
|
<% unless @neuigkeit.calentry.nil? %>
|
||||||
|
|
||||||
|
|
||||||
<%= f.inputs :for => :calentry do |calentry| %>
|
<%= f.inputs :for => :calentry do |calentry| %>
|
||||||
<%= calentry.input :start, :as => :datepicker %>
|
<%= render 'calentries/nested_fields', :f => calentry %>
|
||||||
<%= calentry.input :dauer , :as => :string %>
|
|
||||||
<%= calentry.input :typ %>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
@@ -19,5 +33,6 @@
|
|||||||
<%= f.action :submit, :as => :input %>
|
<%= f.action :submit, :as => :input %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
</div>
|
||||||
<script>$('.datepicker').datepicker()</script>
|
<script>$('.datepicker').datepicker()</script>
|
||||||
<%= tinymce %>
|
<%= tinymce %>
|
||||||
|
|||||||
BIN
public/icon_kalender_small.png
Normal file
BIN
public/icon_kalender_small.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.0 KiB |
Reference in New Issue
Block a user