meetingtyp management

This commit is contained in:
Andreas Stephanides
2015-02-09 15:38:21 +01:00
parent 6c39c40403
commit f1a149908d
15 changed files with 148 additions and 17 deletions

View File

@@ -126,6 +126,6 @@ $box-background: white;
@import 'extra'; @import 'extra';
body { body {
background: url('http://www.fet.at/stvn.jpg') fixed no-repeat; background: $color_schema_1_dark;
background-size:100%; background-size:100%;
} }

View File

@@ -1,2 +1,76 @@
class MeetingtypsController < ApplicationController class MeetingtypsController < ApplicationController
load_and_authorize_resource
def index
@meetingtyps=Meetingtyp.all
end
def show
redirect_to action: :index
end
def edit
@meetingtyp = Meetingtyp.find(params[:id])
end
def new
@meetingtyp=Meetingtyp.new
end
def create_protocol_and_agenda
@meetingtyp = Meetingtyp.find(params[:id])
if @meetingtyp.agenda.nil?
d=Document.new
d.typ=11
d.name="Agendavorlage"
d.save
@meetingtyp.agenda=d
end
if @meetingtyp.protocol.nil?
d=Document.new
d.typ=10
d.name="Protokollvorlage"
d.save
@meetingtyp.protocol=d
end
redirect_to action: :index
end
def create
@meetingtyp = Meetingtyp.new(params[:meetingtyp])
@meetingtyp.assign_attributes(params[:meetingtyp])
respond_to do |format|
if @meetingtyp.save
format.html { redirect_to @meetingtyp, notice: 'Meeting was successfully created.' }
#format.json { render json: @meeting, status: :created, location: @meeting }
format.js
else
format.html { render action: "new" }
# format.json { render json: @meeting.errors, status: :unprocessable_entity }
format.js { render action: "new" }
end
end
end
def update
@meetingtyp = Meetingtyp.find(params[:id])
respond_to do |format|
if @meetingtyp.update_attributes(params[:meetingtyp])
format.html { redirect_to @meetingtyp, notice: 'Meeting was successfully updated.' }
# format.json { head :no_content }
format.js
else
format.html { render action: "edit" }
# format.json { render json: @meeting.errors, status: :unprocessable_entity }
format.js { render action: "edit" }
end
end
end
def destroy
@meetingtyp = Meeting.find(params[:id])
@meetingtyp.destroy
respond_to do |format|
format.html { redirect_to action: :index}
end
end
end end

View File

@@ -53,6 +53,9 @@ class Meeting < ActiveRecord::Base
d=Document.new d=Document.new
d.typ=10 d.typ=10
d.name="Protokoll" d.name="Protokoll"
unless self.meetingtyp.protocol.nil?
d.text=self.meetingtyp.protocol.text
end
d.save d.save
self.protocol=d self.protocol=d
end end
@@ -60,16 +63,19 @@ class Meeting < ActiveRecord::Base
end end
def create_calentry def create_calentry
if self.calentry.nil? if self.calentry.nil?
ce =Calentry.new ce =Calentry.new
ce.typ=2 ce.typ=2
self.calentry=ce self.calentry=ce
end end
end end
def create_agenda def create_agenda
if self.agenda.nil? if self.agenda.nil?
d=Document.new d=Document.new
d.typ=11 d.typ=11
d.name="Agenda" d.name="Agenda"
unless self.meetingtyp.agenda.nil?
d.text=self.meetingtyp.agenda.text
end
d.save d.save
self.agenda=d self.agenda=d
end end

View File

@@ -1,7 +1,12 @@
class Meetingtyp < ActiveRecord::Base class Meetingtyp < ActiveRecord::Base
attr_accessible :agendaintern, :desc, :name, :protocolintern attr_accessible :agendaintern, :desc, :name, :protocolintern, :rubrik_id
belongs_to :rubrik belongs_to :rubrik
validate :rubrik, :presence=>true validate :rubrik, :presence=>true
has_many :meetings has_many :meetings
has_one :calendar, through: :rubrik has_one :calendar, through: :rubrik
has_one :protocol, :class_name=>'Document', :conditions=>{:typ=>10}, :as=>:parent
has_one :agenda , :as=>:parent, :conditions=>{:typ=>11}, :class_name=>'Document'
def text
self.name
end
end end

View File

@@ -33,7 +33,7 @@ class Neuigkeit < ActiveRecord::Base
scope :intern, ->{includes(:rubrik).where("rubriken.public"=>false)} scope :intern, ->{includes(:rubrik).where("rubriken.public"=>false)}
# scope :search, ->(query) {where("text like ? or title like ?", "%#{query}%", "%#{query}%")} # scope :search, ->(query) {where("text like ? or title like ?", "%#{query}%", "%#{query}%")}
LINKTYPES=["Thema", "Gallery", "Lva","Studium","Fetprofile", "Gremium"] LINKTYPES=["Thema", "Themengruppe", "Gallery", "Lva","Studium","Fetprofile", "Gremium"]
accepts_nested_attributes_for :calentries, :allow_destroy=>true , :reject_if=> lambda{|a| a[:start].blank?} accepts_nested_attributes_for :calentries, :allow_destroy=>true , :reject_if=> lambda{|a| a[:start].blank?}
before_validation :sanitize before_validation :sanitize

View File

@@ -9,7 +9,7 @@
<%= f.semantic_fields_for :calentry, @meeting.calentry do |ff| %> <%= f.semantic_fields_for :calentry, @meeting.calentry do |ff| %>
<%= ff.input :start, :as => :datetimepicker %> <%= ff.input :start, :as => :datetimepicker %>
<%= ff.input :ende, :as => :datetimepicker %> <%= ff.input :ende, :as => :datetimepicker %>
<%= ff.input :typ %> <%= ff.input :typ, :as=>:hidden %>
<% ff.input :object_id, :as=>:hidden %> <% ff.input :object_id, :as=>:hidden %>
<% ff.input :object_type %> <% ff.input :object_type %>
@@ -20,4 +20,4 @@
<%= f.action :submit, :as => :input_ %> <%= f.action :submit, :as => :input_ %>
<% end %> <% end %>
<%= @meeting.calentry.to_yaml %>

View File

@@ -1,4 +1,6 @@
$("#<%= @meeting.divid %>").html("<%=escape_javascript( render :partial=>"nested_form" ,:object=>@meeting)%>"); $("#<%= @meeting.divid %>").html("<%=escape_javascript( render :partial=>"nested_form" ,:object=>@meeting)%>");
$('.datetimepicker').datetimepicker({format: 'd.m.Y H:i', startDate: (!($(this).attr("value")==undefined))? $(this).attr("value"): ""})

View File

@@ -1,3 +1,5 @@
$("#<%= Meeting.new_divid_for(@parent) %>").replaceWith("<div id=\"<%= Meeting.new_divid_for(@parent) %>\"><%=escape_javascript( render :partial=>"nested_form" ,:object=>@meeting) %></div>"); $("#<%= Meeting.new_divid_for(@parent) %>").replaceWith("<div id=\"<%= Meeting.new_divid_for(@parent) %>\"><%=escape_javascript( render :partial=>"nested_form" ,:object=>@meeting) %></div>");
$('.datetimepicker').datetimepicker({format: 'd.m.Y H:i', startDate: (!($(this).attr("value")==undefined))? $(this).attr("value"): ""})

View File

@@ -0,0 +1,12 @@
<%= semantic_form_for [@meetingtyp] do |f| %>
<%= f.inputs do %>
<%= f.input :name, :placeholder=> "Name" %>
<%= f.input :rubrik %>
<%= f.input :agendaintern %>
<%= f.input :protocolintern %>
<% end %>
<%= f.actions do %>
<%= f.action :submit, :as => :input %>
<% end %>
<% end %>

View File

@@ -0,0 +1,5 @@
<%= meetingtyp.name %> <%= link_to "edit", edit_meetingtyp_path(meetingtyp) %>
<%= link_to "create" , create_protocol_and_agenda_meetingtyp_path(meetingtyp) %>
<%= render meetingtyp.protocol unless meetingtyp.protocol.nil? %>
<%= render meetingtyp.agenda unless meetingtyp.agenda.nil? %>

View File

@@ -0,0 +1 @@
<%= render "form" %>

View File

@@ -0,0 +1,6 @@
<ul>
<% @meetingtyps.each do |mt| %>
<li><%= render mt %> </li>
<% end %>
</ul>
<%= link_to "New" , new_meetingtyp_path %>

View File

@@ -0,0 +1 @@
<%= render "form" %>

View File

@@ -1 +1,14 @@
<h2><%= nlink.title %> </h2> <% themengruppe=nlink %>
<h3>
<% unless themengruppe.icon.nil? or themengruppe.icon.empty? %> <i class="<%= themengruppe.icon %>" style="font-size:1.5em;margin:0"></i>
<% end %>
<%= themengruppe.title%> </h3>
<p>
<%= if themengruppe.text.split.size > Themengruppe::WORD_COUNT
themengruppe.text.split[0..Themengruppe::WORD_COUNT].join(" ") + " ..."
else
themengruppe.text
end%>
</p>

View File

@@ -181,7 +181,11 @@
end end
resources :meetingtyps resources :meetingtyps do
member do
get :create_protocol_and_agenda
end
end
end end
end end
root :to => 'home#index' root :to => 'home#index'