meetings added, documents added

This commit is contained in:
Andreas Stephanides
2014-11-26 20:36:04 +01:00
parent c2ea1782ff
commit 87dd70ea44
32 changed files with 304 additions and 21 deletions

View File

@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/

View File

@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/

View File

@@ -0,0 +1,3 @@
// Place all the styles related to the meetings controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

View File

@@ -0,0 +1,3 @@
// Place all the styles related to the meetingtyps controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

View File

@@ -57,7 +57,7 @@ def update
logger.info("-------------delete------------------") logger.info("-------------delete------------------")
@document = Document.find(params[:id]) @document = Document.find(params[:id])
@document_id = params[:id] @document_id = params[:id]
@object=@document.object
@document.destroy @document.destroy
respond_to do |format| respond_to do |format|

View File

@@ -0,0 +1,92 @@
class MeetingsController < ApplicationController
load_and_authorize_resource
def index
respond_to do |format|
format.html {redirect_to rubriken_path}
end
end
def new
@meeting=Meeting.new
@meeting.parent=params[:parent_typ].constantize.find(params[:parent_id])
@meeting.typ = 1
respond_to do |format|
format.js
end
end
def create_protocol
@meeting = Meeting.find(params[:id])
@meeting.create_protocol
@meeting.save
respond_to do |format|
format.js {render action: :show}
end
end
def create_agenda
@meeting = Meeting.find(params[:id])
@meeting.create_agenda
respond_to do |format|
format.js {render action: :show}
end
end
def edit
@meeting = Meeting.find(params[:id])
respond_to do |format|
format.js
end
end
def create
@meeting = Meeting.new(params[:meeting])
respond_to do |format|
if @meeting.save
# format.html { redirect_to @meeting, 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
@meeting = Meeting.find(params[:id])
respond_to do |format|
if @meeting.update_attributes(params[:meeting])
format.html { redirect_to @meeting, 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
logger.info("-------------delete------------------")
@meeting = Meeting.find(params[:id])
@meeting_id = params[:id]
@object=@meeting.object
@meeting.destroy
respond_to do |format|
#format.html { redirect_to @object}
#format.json { head :no_content }
format.js
end
end
end

View File

@@ -0,0 +1,2 @@
class MeetingtypsController < ApplicationController
end

View File

@@ -0,0 +1,2 @@
module MeetingsHelper
end

View File

@@ -0,0 +1,2 @@
module MeetingtypsHelper
end

View File

@@ -116,7 +116,12 @@ class Ability
cannot :delete, Neuigkeit cannot :delete, Neuigkeit
end end
# Calendar
if( user.has_role?("fetuser") || user.has_role?("fetadmin"))
can :manage, Document
can :manage, Meeting
can :manage, Meetingtyp
end
# Rechteverwaltung Kalender # Rechteverwaltung Kalender

View File

@@ -1,3 +1,9 @@
class Document < ActiveRecord::Base class Document < ActiveRecord::Base
attr_accessible :etherpadkey, :name, :parent, :text, :typ attr_accessible :etherpadkey, :name, :parent, :text, :typ
belongs_to :parent, :polymorphic => true
validate :name, :length=>{minimum:3}
validate :text, :presence=>true
validate :typ, :presence=>true
validate :parent, :presence=>true
end end

32
app/models/meeting.rb Normal file
View File

@@ -0,0 +1,32 @@
class Meeting < ActiveRecord::Base
belongs_to :parent, :polymorphic=>true
belongs_to :meetingtyp
attr_accessible :desc, :intern, :name
has_one :protocol, :class_name=>'Document', :conditions=>{:typ=>10}, :as=>:parent
has_one :agenda , :as=>:parent,:conditions=>{:typ=>11}, :class_name=>'Document'
validate :agenda, :presence=>true
validate :protocol, :presence=>true
has_one :calentry, :as=>:object
def public?
! (self.intern)
end
def create_protocol
if self.protocol.nil?
d=Document.new
d.typ=10
d.name="Protokoll"
d.save
self.protocol=d
end
end
def create_agenda
if self.agenda.nil?
d=Document.new
d.typ=11
d.name="Agenda"
d.save
self.agenda=d
end
end
end

3
app/models/meetingtyp.rb Normal file
View File

@@ -0,0 +1,3 @@
class Meetingtyp < ActiveRecord::Base
attr_accessible :agendaintern, :desc, :name, :protocolintern
end

View File

@@ -21,6 +21,8 @@ include Rails.application.routes.url_helpers
validates :themengruppe, :presence => true validates :themengruppe, :presence => true
validates :title, :presence => true validates :title, :presence => true
validates :text, :presence => true validates :text, :presence => true
has_many :meetings, :as=>:parent
has_many :documents, :as=>:parent
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}%")}

View File

@@ -1,4 +1,4 @@
<% data_ext = attachment.datei.file.extension.downcase %> <% data_ext = attachment.datei.file.try(:extension).try(:downcase) %>
<% if (!["jpg","png","jpeg"].find_index(data_ext).nil?) %> <% if (!["jpg","png","jpeg"].find_index(data_ext).nil?) %>

View File

@@ -1,8 +1,8 @@
<div class="contentbox" id="document_<%= document.id%>"> <div class="contentbox" id="document_<%= document.id%>">
<% image_tag("/iconnavy/time.png") %> <% image_tag("/iconnavy/time.png") %>
<% fa_icon("calendar 2x") %> <%= fa_icon("file-text 2x") %>
<%= document.title %> <%= document.name %>
<%= link_to "edit", edit_document_path(document),:remote=>true if can? :edit, document %> <%= link_to "edit", edit_document_path(document),:remote=>true if can? :edit, document %>
<%= link_to 'Delete', document, method: :delete, data: { confirm: 'Are you sure?' } , remote: true if can? :delete, document %> <%= link_to 'Delete', document, method: :delete, data: { confirm: 'Are you sure?' } , remote: true if can? :delete, document %>
</div> </div>

View File

@@ -1,15 +1,9 @@
<%= fa_icon("calendar 2x") %> <%= fa_icon("calendar 2x") %>
<p id="notice"><%= notice %></p> <p id="notice"><%= notice %></p>
<%= semantic_form_for @calentry, :remote=>true, :html=>{:class=>"inline"} do |f| %> <%= semantic_form_for @document, :remote=>true, :html=>{:class=>""} do |f| %>
<%= f.input :start, :as => :datetimepicker %> <%= f.input :name %>
<%= f.input :dauer , :as => :string, :append=>"h" %> <%= f.action :submit, :as => :input_ %>
<%= f.input :object_id , :as => :hidden %>
<%= f.input :object_type , :as => :hidden %>
<%= f.input :typ , :as => :hidden %>
<%= f.action :submit, :as => :input_ %>
<% end %> <% end %>

View File

@@ -0,0 +1,8 @@
<div class="contentbox" id="meeting_<%= meeting.id%>">
<h3>Meeting: <%= meeting.name %></h3>
<%= render meeting.calentry %>
<%= link_to "Agenda" , create_agenda_meeting_path(meeting), :remote=>true %>
<%= link_to "Protokoll" , create_protocol_meeting_path(meeting),:remote=>true %>
<%= render meeting.agenda unless meeting.agenda.nil? %>
<%= render meeting.protocol unless meeting.protocol.nil? %>
</div>

View File

@@ -0,0 +1 @@
$("#meeting_<%= @meeting.id %>").replaceWith("<%=escape_javascript( render :partial=>"meeting", :object=>@meeting)%>");

View File

@@ -8,8 +8,8 @@
<% if small.isdraft %> <% if small.isdraft %>
<div class="sticker sticker-yellow"><%= I18n.t("thema.isdraft") %> </div> <div class="sticker sticker-yellow"><%= I18n.t("thema.isdraft") %> </div>
<% end %> <% end %><div>
<%= raw(small.text) %> <%= raw(small.text) %></div>
<br/> <br/>
<%= raw("<b>FAQs:</b>") unless small.fragen.empty? %> <%= raw("<b>FAQs:</b>") unless small.fragen.empty? %>
@@ -20,6 +20,23 @@
<%= raw(frage.text) %> <%= raw(frage.text) %>
</p> </p>
<% end %> <% end %>
<% unless small.meetings.empty? %>
<b>Treffen/Sitzungen</b>
<% small.meetings.each do |m| %>
<%= render m %>
<% end%>
<% end%>
<% unless small.documents.empty? %>
<b>Dokumente</b>
<% small.documents.each do |d| %>
<%= render d %>
<% end%>
<% end%>
<% unless small.hideattachment %> <% unless small.hideattachment %>
<%= render partial: "themen/attachment_list", object: small.attachments, locals:{editor: false} unless small.attachments.empty? %> <%= render partial: "themen/attachment_list", object: small.attachments, locals:{editor: false} unless small.attachments.empty? %>
<% end %> <% end %>

View File

@@ -163,6 +163,14 @@ Fetsite::Application.routes.draw do
resources :calendars resources :calendars
get 'verwalten/calendars', :controller=>:calendars, :action=>:verwalten, :as=>'calendars_verwalten' get 'verwalten/calendars', :controller=>:calendars, :action=>:verwalten, :as=>'calendars_verwalten'
resources :calentries resources :calentries
resources :documents
resources :meetings do
member do
get :create_protocol
get :create_agenda
end
end
resources :meetingtyps
end end
end end
root :to => 'home#index' root :to => 'home#index'

View File

@@ -1,13 +1,15 @@
class CreateDocuments < ActiveRecord::Migration class CreateDocuments < ActiveRecord::Migration
def change def change
create_table :documents do |t| create_table :documents do |t|
t.integer :typ t.integer :typ, :default=>0
t.string :name t.string :name
t.text :text t.text :text
t.string :etherpadkey t.string :etherpadkey, :default=>""
t.references{polymorphic} :parent t.references :parent,:polymorphic=>{:default=>'Thema'}
t.timestamps t.timestamps
end end
add_index :documents, :parent_id
add_index :documents, :parent_type
end end
end end

View File

@@ -0,0 +1,11 @@
class CreateMeetingtyps < ActiveRecord::Migration
def change
create_table :meetingtyps do |t|
t.string :name
t.text :desc
t.boolean :agendaintern, :default=>false
t.boolean :protocolintern, :default=>true
t.timestamps
end
end
end

View File

@@ -0,0 +1,15 @@
class CreateMeetings < ActiveRecord::Migration
def change
create_table :meetings do |t|
t.string :name
t.text :desc
t.boolean :intern, :default=>true
t.references :parent, :polymorphic=>{:default=>'Thema'}
t.references :meetingtyp
t.timestamps
end
add_index :meetings, :parent_id
add_index :meetings, :parent_type
add_index :meetings, :meetingtyp_id
end
end

View File

@@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe MeetingsController, :type => :controller do
end

View File

@@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe MeetingtypsController, :type => :controller do
end

View File

@@ -0,0 +1,10 @@
FactoryGirl.define do
factory :meeting do
name "MyString"
desc "MyText"
parent nil
intern false
meetingtyp nil
end
end

View File

@@ -0,0 +1,9 @@
FactoryGirl.define do
factory :meetingtyp do
name "MyString"
desc "MyText"
agendaintern false
protocolintern false
end
end

View File

@@ -0,0 +1,15 @@
require 'rails_helper'
# Specs in this file have access to a helper object that includes
# the MeetingsHelper. For example:
#
# describe MeetingsHelper do
# describe "string concat" do
# it "concats two strings with spaces" do
# expect(helper.concat_strings("this","that")).to eq("this that")
# end
# end
# end
RSpec.describe MeetingsHelper, :type => :helper do
pending "add some examples to (or delete) #{__FILE__}"
end

View File

@@ -0,0 +1,15 @@
require 'rails_helper'
# Specs in this file have access to a helper object that includes
# the MeetingtypsHelper. For example:
#
# describe MeetingtypsHelper do
# describe "string concat" do
# it "concats two strings with spaces" do
# expect(helper.concat_strings("this","that")).to eq("this that")
# end
# end
# end
RSpec.describe MeetingtypsHelper, :type => :helper do
pending "add some examples to (or delete) #{__FILE__}"
end

View File

@@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe Meeting, :type => :model do
pending "add some examples to (or delete) #{__FILE__}"
end

View File

@@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe Meetingtyp, :type => :model do
pending "add some examples to (or delete) #{__FILE__}"
end