Merge remote-tracking branch 'origin/master' into extrafeature
This commit is contained in:
4
Gemfile
4
Gemfile
@@ -43,7 +43,9 @@ gem 'jquery-rails'
|
|||||||
|
|
||||||
# Formbuilder for easier form generation
|
# Formbuilder for easier form generation
|
||||||
gem 'formtastic', '~>2.2.1'
|
gem 'formtastic', '~>2.2.1'
|
||||||
gem 'formtastic-bootstrap', '~>2.1.3' #, :git => "git://github.com/mjbellantoni/formtastic-bootstrap.git"
|
|
||||||
|
# gem 'formtastic-bootstrap', '~>2.1.3' #, :git => "git://github.com/mjbellantoni/formtastic-bootstrap.git"
|
||||||
|
gem 'formtastic-bootstrap', '~>3.0.0' #, :git => "git://github.com/mjbellantoni/formtastic-bootstrap.git"
|
||||||
# TinyMCE
|
# TinyMCE
|
||||||
gem "tinymce-rails" , '~>4.1.0'
|
gem "tinymce-rails" , '~>4.1.0'
|
||||||
|
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ GEM
|
|||||||
activesupport (3.2.13)
|
activesupport (3.2.13)
|
||||||
i18n (= 0.6.1)
|
i18n (= 0.6.1)
|
||||||
multi_json (~> 1.0)
|
multi_json (~> 1.0)
|
||||||
|
acts_as_votable (0.10.0)
|
||||||
annotate (2.6.1)
|
annotate (2.6.1)
|
||||||
activerecord (>= 2.3.0)
|
activerecord (>= 2.3.0)
|
||||||
rake (>= 0.8.7)
|
rake (>= 0.8.7)
|
||||||
@@ -225,6 +226,7 @@ GEM
|
|||||||
rspec-expectations (~> 2.14.0)
|
rspec-expectations (~> 2.14.0)
|
||||||
rspec-mocks (~> 2.14.0)
|
rspec-mocks (~> 2.14.0)
|
||||||
rubyntlm (0.1.1)
|
rubyntlm (0.1.1)
|
||||||
|
rubyzip (1.1.6)
|
||||||
sanitize (2.0.6)
|
sanitize (2.0.6)
|
||||||
nokogiri (>= 1.4.4)
|
nokogiri (>= 1.4.4)
|
||||||
sass (3.2.13)
|
sass (3.2.13)
|
||||||
@@ -271,6 +273,7 @@ PLATFORMS
|
|||||||
|
|
||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
RedCloth
|
RedCloth
|
||||||
|
acts_as_votable
|
||||||
annotate (>= 2.5.0)
|
annotate (>= 2.5.0)
|
||||||
awesome_nested_set
|
awesome_nested_set
|
||||||
bootstrap-addons-rails
|
bootstrap-addons-rails
|
||||||
@@ -304,6 +307,7 @@ DEPENDENCIES
|
|||||||
rmagick
|
rmagick
|
||||||
rolify
|
rolify
|
||||||
rspec-rails
|
rspec-rails
|
||||||
|
rubyzip
|
||||||
sanitize
|
sanitize
|
||||||
sass-rails (~> 3.2)
|
sass-rails (~> 3.2)
|
||||||
seed_dump (~> 0.5.3)
|
seed_dump (~> 0.5.3)
|
||||||
|
|||||||
3
app/assets/javascripts/comments.js.coffee
Normal file
3
app/assets/javascripts/comments.js.coffee
Normal 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/
|
||||||
@@ -115,3 +115,4 @@ $box-background: white;
|
|||||||
|
|
||||||
@import 'layout';
|
@import 'layout';
|
||||||
@import 'calendars';
|
@import 'calendars';
|
||||||
|
@import 'formtastic-bootstrap'
|
||||||
@@ -17,7 +17,10 @@ class BeispieleController < ApplicationController
|
|||||||
def show
|
def show
|
||||||
# @lva = params([:lva]) unless params([:lva]).nil?
|
# @lva = params([:lva]) unless params([:lva]).nil?
|
||||||
@beispiel = Beispiel.find(params[:id])
|
@beispiel = Beispiel.find(params[:id])
|
||||||
redirect_to @beispiel.lva
|
respond_to do |format|
|
||||||
|
format.html { redirect_to @beispiel.lva }
|
||||||
|
format.js
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# GET /beispiele/new
|
# GET /beispiele/new
|
||||||
|
|||||||
83
app/controllers/comments_controller.rb
Normal file
83
app/controllers/comments_controller.rb
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
class CommentsController < ApplicationController
|
||||||
|
def index
|
||||||
|
@comments=Comment.all
|
||||||
|
end
|
||||||
|
def show
|
||||||
|
@comment = Comment.find(params[:id])
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html # show.html.erb
|
||||||
|
format.json { render json: @comment }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
def new
|
||||||
|
@comment = Comment.new
|
||||||
|
@comment.commentable=params[:commentable_type].constantize.find(params[:commentable_id]) unless params[:commentable_type].nil? or params[:commentable_id].nil?
|
||||||
|
respond_to do |format|
|
||||||
|
format.html # new.html.erb
|
||||||
|
format.json { render json: @comment }
|
||||||
|
format.js
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# GET /comments/1/edit
|
||||||
|
def edit
|
||||||
|
@comment = Comment.find(params[:id])
|
||||||
|
end
|
||||||
|
|
||||||
|
# POST /comments
|
||||||
|
# POST /comments.json
|
||||||
|
def create
|
||||||
|
params_new= params[:comment].select {|i| !["commentable_id", "commentable_type"].include?(i)}
|
||||||
|
|
||||||
|
c = params[:comment][:commentable_type].constantize.find(params[:comment][:commentable_id]) unless params[:comment][:commentable_type].nil? or params[:comment][:commentable_id].nil?
|
||||||
|
|
||||||
|
@comment = Comment.build_for(c, current_user,"", params_new)
|
||||||
|
#raise @comment.to_yaml.to_s
|
||||||
|
# @comment.commentable= c
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
if @comment
|
||||||
|
format.html { redirect_to @comment.commentable, notice: 'Comment was successfully created.' }
|
||||||
|
format.json { render json: @comment, status: :created, location: @comment }
|
||||||
|
else
|
||||||
|
format.html { render action: "new" }
|
||||||
|
format.json { render json: @comment.errors, status: :unprocessable_entity }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# PUT /comments/1
|
||||||
|
# PUT /comments/1.json
|
||||||
|
def update
|
||||||
|
|
||||||
|
params[:comment].select! {|i| !["commentable_id", "commentable_type"].include?(i)}
|
||||||
|
@comment = Comment.find(params[:id])
|
||||||
|
@comment.commentable=params[:comment][:commentable_type].constantize.find(params[:comment][:commentable_id]) unless params[:comment][:commentable_type].nil? or params[:comment][:commentable_id].nil?
|
||||||
|
respond_to do |format|
|
||||||
|
|
||||||
|
if @comment.update_attributes(params[:comment])
|
||||||
|
format.html { redirect_to @comment.commentable, notice: 'Comment was successfully updated.' }
|
||||||
|
format.json { head :no_content }
|
||||||
|
else
|
||||||
|
format.html { render action: "edit" }
|
||||||
|
format.json { render json: @comment.errors, status: :unprocessable_entity }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# DELETE /comments/1
|
||||||
|
# DELETE /comments/1.json
|
||||||
|
def destroy
|
||||||
|
@comment = Comment.find(params[:id])
|
||||||
|
@comment.destroy
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html { redirect_to comments_url }
|
||||||
|
format.json { head :no_content }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -4,4 +4,6 @@ class ConfigController < ApplicationController
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def choose_contact_topics
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ class HomeController < ApplicationController
|
|||||||
|
|
||||||
end
|
end
|
||||||
def kontakt
|
def kontakt
|
||||||
|
t=YAML.load_file("#{::Rails.root.to_s}/config/contact_topic.yml")
|
||||||
|
@themen = Thema.where(:id=>t)
|
||||||
end
|
end
|
||||||
def intern
|
def intern
|
||||||
authorize! :seeintern, User
|
authorize! :seeintern, User
|
||||||
@@ -51,4 +53,9 @@ class HomeController < ApplicationController
|
|||||||
format.js
|
format.js
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
def choose_contact_topics
|
||||||
|
File.open("config/contact_topic.yml",'w'){|f| f.write(params[:themen].to_yaml)}
|
||||||
|
redirect_to admin_home_index_path
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
class LvasController < ApplicationController
|
class LvasController < ApplicationController
|
||||||
# GET /lvas
|
# GET /lvas
|
||||||
require 'zip'
|
require 'zip'
|
||||||
before_filter :load_toolbar, :only => [:show]
|
before_filter :load_toolbar, :only => [:verwalten]
|
||||||
load_and_authorize_resource
|
load_and_authorize_resource
|
||||||
def index
|
def index
|
||||||
@lvas = Lva.all
|
@lvas = Lva.all
|
||||||
@@ -43,6 +43,15 @@ class LvasController < ApplicationController
|
|||||||
def show
|
def show
|
||||||
@lva = Lva.find_by_id(params[:id])
|
@lva = Lva.find_by_id(params[:id])
|
||||||
@beispiel=Beispiel.new
|
@beispiel=Beispiel.new
|
||||||
|
@toolbar_elements =[]
|
||||||
|
@toolbar_elements<<{:hicon=>'icon-pencil', :icon=>:pencil,:text =>I18n.t('common.manage'),:path => verwalten_lva_path(@lva)} if can? :verwalten, @lva
|
||||||
|
|
||||||
|
end
|
||||||
|
def verwalten
|
||||||
|
@lva = Lva.find_by_id(params[:id])
|
||||||
|
@beispiel=Beispiel.new
|
||||||
|
|
||||||
|
render :show
|
||||||
end
|
end
|
||||||
|
|
||||||
# GET /lvas/new
|
# GET /lvas/new
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ class NeuigkeitenController < ApplicationController
|
|||||||
unless @neuigkeit.published?
|
unless @neuigkeit.published?
|
||||||
redirect_to [@neuigkeit.rubrik,@neuigkeit], notice: 'Neuigkeit muss veröffentlicht sein um sie auf Facebook zu posten.'
|
redirect_to [@neuigkeit.rubrik,@neuigkeit], notice: 'Neuigkeit muss veröffentlicht sein um sie auf Facebook zu posten.'
|
||||||
else
|
else
|
||||||
page=YAML.load_file("#{::Rails.root.to_s}/tmp/page.yml")
|
page=YAML.load_file("#{::Rails.root.to_s}/config/page.yml")
|
||||||
page.feed!(:access_token=>page.access_token, :message=>@neuigkeit.text_first_words, :name=>@neuigkeit.title, :link=>rubrik_neuigkeit_url(@neuigkeit.rubrik, @neuigkeit)+".html", :picture=>@neuigkeit.picture.url)
|
page.feed!(:access_token=>page.access_token, :message=>@neuigkeit.text_first_words, :name=>@neuigkeit.title, :link=>rubrik_neuigkeit_url(@neuigkeit.rubrik, @neuigkeit)+".html", :picture=>@neuigkeit.picture.url)
|
||||||
|
|
||||||
redirect_to [@neuigkeit.rubrik,@neuigkeit], notice: 'Neuigkeit auf Facebook gepostet'
|
redirect_to [@neuigkeit.rubrik,@neuigkeit], notice: 'Neuigkeit auf Facebook gepostet'
|
||||||
@@ -113,9 +113,14 @@ class NeuigkeitenController < ApplicationController
|
|||||||
render action:"show"
|
render action:"show"
|
||||||
end
|
end
|
||||||
def create_link
|
def create_link
|
||||||
Nlink.create(:link=>params[:link_type].constantize.find(params[:link_id]),:neuigkeit=>Neuigkeit.find(params[:id]))
|
@neuigkeit = Neuigkeit.find(params[:id])
|
||||||
|
|
||||||
redirect_to action:"show"
|
Nlink.create(:link=>params[:link_type].constantize.find(params[:link_id]),:neuigkeit=>Neuigkeit.find(params[:id]))
|
||||||
|
@nlinks=@neuigkeit.nlinks
|
||||||
|
respond_to do |format|
|
||||||
|
format.html { edirect_to action:"show" }
|
||||||
|
format.js
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@@ -159,21 +164,23 @@ private
|
|||||||
def load_toolbar_elements
|
def load_toolbar_elements
|
||||||
@neuigkeit=Neuigkeit.find(params[:id])
|
@neuigkeit=Neuigkeit.find(params[:id])
|
||||||
@toolbar_elements=[]
|
@toolbar_elements=[]
|
||||||
@toolbar_elements << {:hicon=>'icon-plus', :text=> I18n.t('neuigkeit.publish'),:path => publish_rubrik_neuigkeit_path(@neuigkeit.rubrik,@neuigkeit),:confirm=> I18n.t('neuigkeit.publish_sure') } if can?(:publish, @neuigkeit) && !@neuigkeit.published?
|
actions=[]
|
||||||
@toolbar_elements << {:hicon=>'icon-facebook', :text=> I18n.t('neuigkeit.publishfb'),:path => publish_to_facebook_rubrik_neuigkeit_path(@neuigkeit.rubrik,@neuigkeit),:confirm=>I18n.t('neuigkeit.publishfb_sure') } if can?(:publish, @neuigkeit) && @neuigkeit.published?
|
actions << {:hicon=>'icon-plus', :text=> I18n.t('neuigkeit.publish'),:path => publish_rubrik_neuigkeit_path(@neuigkeit.rubrik,@neuigkeit),:confirm=> I18n.t('neuigkeit.publish_sure') } if can?(:publish, @neuigkeit) && !@neuigkeit.published?
|
||||||
|
actions << {:hicon=>'ffi1-facebook1', :text=> I18n.t('neuigkeit.publishfb'),:path => publish_to_facebook_rubrik_neuigkeit_path(@neuigkeit.rubrik,@neuigkeit),:confirm=>I18n.t('neuigkeit.publishfb_sure') } if can?(:publish, @neuigkeit) && @neuigkeit.published?
|
||||||
|
|
||||||
@toolbar_elements << {:hicon=>'icon-facebook', :text=> I18n.t('neuigkeit.publishfetmail'),:path => mail_to_fet_rubrik_neuigkeit_path(@neuigkeit.rubrik,@neuigkeit),:confirm=>I18n.t('neuigkeit.publishfetmail_sure') } if can?(:publish, @neuigkeit) && @neuigkeit.published?
|
actions << {:hicon=>'icon-facebook', :text=> I18n.t('neuigkeit.publishfetmail'),:path => mail_to_fet_rubrik_neuigkeit_path(@neuigkeit.rubrik,@neuigkeit),:confirm=>I18n.t('neuigkeit.publishfetmail_sure') } if can?(:publish, @neuigkeit) && @neuigkeit.published?
|
||||||
|
|
||||||
@toolbar_elements << {:hicon=>'icon-minus', :text=> I18n.t('neuigkeit.unpublish'),:path => unpublish_rubrik_neuigkeit_path(@neuigkeit.rubrik,@neuigkeit),:confirm=> I18n.t('neuigkeit.unpublish_sure') } if can?(:unpublish, @neuigkeit) && @neuigkeit.published?
|
actions << {:hicon=>'icon-minus', :text=> I18n.t('neuigkeit.unpublish'),:path => unpublish_rubrik_neuigkeit_path(@neuigkeit.rubrik,@neuigkeit),:confirm=> I18n.t('neuigkeit.unpublish_sure') } if can?(:unpublish, @neuigkeit) && @neuigkeit.published?
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@toolbar_elements << {:text=>I18n.t('common.edit'),:path=>edit_rubrik_neuigkeit_path(@neuigkeit.rubrik,@neuigkeit),:icon=>:pencil} if can? :edit, @neuigkeit.rubrik
|
@toolbar_elements << {:text=>I18n.t('common.edit'),:path=>edit_rubrik_neuigkeit_path(@neuigkeit.rubrik,@neuigkeit),:icon=>:pencil} if can? :edit, @neuigkeit.rubrik
|
||||||
@versions= @neuigkeit.translation.versions.select([:created_at]).reverse
|
@versions= @neuigkeit.translation.versions.select([:created_at]).reverse
|
||||||
|
|
||||||
@toolbar_elements <<{:path=>rubrik_neuigkeit_path(@neuigkeit.rubrik,@neuigkeit),:method=>:versions,:versions=>@versions}
|
@toolbar_elements <<{:path=>rubrik_neuigkeit_path(@neuigkeit.rubrik,@neuigkeit),:method=>:versions,:versions=>@versions}
|
||||||
|
|
||||||
@toolbar_elements << {:hicon=>'icon-remove-circle', :text=> I18n.t('common.delete'),:path => rubrik_neuigkeit_path(@neuigkeit.rubrik,@neuigkeit), :method=> :delete,:confirm=>'Sure?' } if can? :delete, @neuigkeit
|
actions << {:hicon=>'icon-remove-circle', :text=> I18n.t('common.delete'),:path => rubrik_neuigkeit_path(@neuigkeit.rubrik,@neuigkeit), :method=> :delete,:confirm=>'Sure?' } if can? :delete, @neuigkeit
|
||||||
|
@toolbar_elements << {:text => "action", :method => :dropdown, :elements=> actions}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ class UsersController < ApplicationController
|
|||||||
redirect_to intern_home_index_path
|
redirect_to intern_home_index_path
|
||||||
else
|
else
|
||||||
@fbu=FbGraph::User.new(current_user.uid.to_s).fetch(:access_token=>session["fbuser_access_token"])
|
@fbu=FbGraph::User.new(current_user.uid.to_s).fetch(:access_token=>session["fbuser_access_token"])
|
||||||
File.open("tmp/page.yml",'w'){|f| f.write(@fbu.accounts(:access_token=>session["fbuser_access_token"]).select { |p| p.name == params["page"] }.first.to_yaml)}
|
File.open("config/page.yml",'w'){|f| f.write(@fbu.accounts(:access_token=>session["fbuser_access_token"]).select { |p| p.name == params["page"] }.first.to_yaml)}
|
||||||
logger.debug @fbu.to_s
|
logger.debug @fbu.to_s
|
||||||
redirect_to admin_home_index_path
|
redirect_to admin_home_index_path
|
||||||
end
|
end
|
||||||
|
|||||||
2
app/helpers/comments_helper.rb
Normal file
2
app/helpers/comments_helper.rb
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
module CommentsHelper
|
||||||
|
end
|
||||||
@@ -4,12 +4,14 @@ class Ability
|
|||||||
def initialize(user)
|
def initialize(user)
|
||||||
loggedin=!(user.nil?)
|
loggedin=!(user.nil?)
|
||||||
user ||= User.new # guest user (not logged in)
|
user ||= User.new # guest user (not logged in)
|
||||||
|
|
||||||
|
can :manage, Comment
|
||||||
#-----------------------------------------------------
|
#-----------------------------------------------------
|
||||||
# Rechteverwaltung fuer Studien Modul
|
# Rechteverwaltung fuer Studien Modul
|
||||||
can [:show, :index], Studium
|
can [:show, :index], Studium
|
||||||
can [:show, :index], Modulgruppe
|
can [:show, :index], Modulgruppe
|
||||||
can [:show, :index], Modul
|
can [:show, :index], Modul
|
||||||
can [:show, :index], Lva
|
can [:show, :index, :beispiel_sammlung], Lva
|
||||||
can [:create, :show], Beispiel
|
can [:create, :show], Beispiel
|
||||||
if loggedin
|
if loggedin
|
||||||
can :like, Beispiel
|
can :like, Beispiel
|
||||||
@@ -20,6 +22,7 @@ class Ability
|
|||||||
can :manage, Modul
|
can :manage, Modul
|
||||||
can :manage, Lva
|
can :manage, Lva
|
||||||
can :manage, Studium
|
can :manage, Studium
|
||||||
|
can :manage, Beispiel
|
||||||
end
|
end
|
||||||
unless user.has_role?("fetadmin")
|
unless user.has_role?("fetadmin")
|
||||||
cannot :delete, Studium
|
cannot :delete, Studium
|
||||||
@@ -40,6 +43,7 @@ class Ability
|
|||||||
can :showintern, Thema
|
can :showintern, Thema
|
||||||
can :manage, Thema
|
can :manage, Thema
|
||||||
can :manage, Themengruppe
|
can :manage, Themengruppe
|
||||||
|
can :manage, Attachment
|
||||||
end
|
end
|
||||||
unless user.has_role?("fetadmin")
|
unless user.has_role?("fetadmin")
|
||||||
cannot :delete, Themengruppe
|
cannot :delete, Themengruppe
|
||||||
@@ -95,6 +99,8 @@ class Ability
|
|||||||
if user.has_role?("fetadmin")
|
if user.has_role?("fetadmin")
|
||||||
can :addfetuser, User
|
can :addfetuser, User
|
||||||
can :addfetadmin, User
|
can :addfetadmin, User
|
||||||
|
can :edit, User
|
||||||
|
can :manage, User
|
||||||
end
|
end
|
||||||
|
|
||||||
if user.has_role?("newsadmin") || user.has_role?( "fetadmin") || user.has_role?( "fetuser")
|
if user.has_role?("newsadmin") || user.has_role?( "fetadmin") || user.has_role?( "fetuser")
|
||||||
|
|||||||
@@ -18,6 +18,13 @@ class Attachment < ActiveRecord::Base
|
|||||||
validates :thema, :presence => true
|
validates :thema, :presence => true
|
||||||
validates :name, :presence => true
|
validates :name, :presence => true
|
||||||
|
|
||||||
|
def image?
|
||||||
|
|
||||||
|
# data_ext = datei.file.extension.downcase
|
||||||
|
# %w(jpg png jpeg).include?(data_ext)
|
||||||
|
datei.image?(datei.file)
|
||||||
|
end
|
||||||
|
|
||||||
def to_jq_upload
|
def to_jq_upload
|
||||||
{
|
{
|
||||||
"id" => read_attribute(:id),
|
"id" => read_attribute(:id),
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ class Beispiel < ActiveRecord::Base
|
|||||||
attr_accessible :desc, :name, :lva_id, :beispieldatei, :beispieldatei_cache, :datum
|
attr_accessible :desc, :name, :lva_id, :beispieldatei, :beispieldatei_cache, :datum
|
||||||
acts_as_votable
|
acts_as_votable
|
||||||
belongs_to :lva
|
belongs_to :lva
|
||||||
|
include IsCommentable
|
||||||
mount_uploader :beispieldatei, AttachmentUploader
|
mount_uploader :beispieldatei, AttachmentUploader
|
||||||
validates :beispieldatei, :presence => true
|
validates :beispieldatei, :presence => true
|
||||||
validates :name, :presence => true
|
validates :name, :presence => true
|
||||||
@@ -35,4 +35,7 @@ class Beispiel < ActiveRecord::Base
|
|||||||
"delete_type" => "DELETE"
|
"delete_type" => "DELETE"
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
def divid
|
||||||
|
"beispiel_"+id.to_s
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
44
app/models/comment.rb
Normal file
44
app/models/comment.rb
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
class Comment < ActiveRecord::Base
|
||||||
|
attr_accessible :text,:anonym, :intern, :hidden
|
||||||
|
# commentable depth, official, intern, anonym
|
||||||
|
acts_as_votable
|
||||||
|
acts_as_nested_set :scope => [:commentable_id, :commentable_type]
|
||||||
|
belongs_to :commentable, :polymorphic=> true
|
||||||
|
belongs_to :user
|
||||||
|
validate :text, :presence=>true
|
||||||
|
validate :user, :presence=>true
|
||||||
|
validate :commentable, :presence=>true
|
||||||
|
include IsCommentable
|
||||||
|
|
||||||
|
def self.build_for(set_commentable, user, text,attr={})
|
||||||
|
c = new
|
||||||
|
raise "Tried to build comment for non commentable" unless set_commentable.try(:is_commentable?)
|
||||||
|
c.user=user
|
||||||
|
c.text=text
|
||||||
|
c.assign_attributes(attr)
|
||||||
|
|
||||||
|
unless set_commentable.class.to_s == "Comment"
|
||||||
|
c.commentable=set_commentable
|
||||||
|
c.save
|
||||||
|
else
|
||||||
|
|
||||||
|
c.commentable=set_commentable.commentable
|
||||||
|
c.save
|
||||||
|
c.move_to_child_of(set_commentable)
|
||||||
|
end
|
||||||
|
c
|
||||||
|
end
|
||||||
|
def thumb_url
|
||||||
|
t_url= user.fetprofile.picture.thumb.url unless user.nil? or user.fetprofile.nil?
|
||||||
|
t_url
|
||||||
|
end
|
||||||
|
def divid
|
||||||
|
"comment_" + id.to_s
|
||||||
|
end
|
||||||
|
def formid
|
||||||
|
"comment_form_" + commentable_type + "_" + commentable_id.to_s
|
||||||
|
end
|
||||||
|
def self.formid_for(c)
|
||||||
|
"comment_form_" + c.class.to_s + "_" + c.id.to_s
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
class Fetprofile < ActiveRecord::Base
|
class Fetprofile < ActiveRecord::Base
|
||||||
attr_accessible :active, :desc, :fetmailalias, :nachname, :picture, :short, :vorname, :memberships_attributes, :remove_picture, :picture_cache, :plz, :street, :city, :instant,:skype, :telnr, :hdynr, :birth_day, :birth_month, :birth_year,:geschlecht
|
attr_accessible :active, :desc, :fetmailalias, :nachname, :picture, :short, :vorname, :memberships_attributes, :remove_picture, :picture_cache, :plz, :street, :city, :instant,:skype, :telnr, :hdynr, :birth_day, :birth_month, :birth_year,:geschlecht
|
||||||
has_many :memberships, dependent: :delete_all
|
has_many :memberships, dependent: :destroy
|
||||||
has_many :gremien, :through=> :membership
|
has_many :gremien, :through=> :membership
|
||||||
mount_uploader :picture, PictureUploader
|
mount_uploader :picture, PictureUploader
|
||||||
has_paper_trail
|
has_paper_trail
|
||||||
|
|||||||
@@ -49,7 +49,9 @@ include Rails.application.routes.url_helpers
|
|||||||
|
|
||||||
def fix_links(host)
|
def fix_links(host)
|
||||||
full_url= URI.parse(root_url(:host=>host))
|
full_url= URI.parse(root_url(:host=>host))
|
||||||
self.text.gsub!(/src="[^"]*attachment\/datei\/(\d+)[^"]*"/){|s| full_url.path=Attachment.find($1.to_i).datei.url; 'src="'+full_url.to_s+'"'}
|
self.text.gsub!(/src="[\.\/]*uploads\/attachment\/datei\/(\d+)\/thumb_big[^"]*"/){|s| full_url.path=Attachment.find($1.to_i).datei.thumb_big.url; 'src="'+full_url.to_s+'"'}
|
||||||
|
self.text.gsub!(/src="[\.\/^"]*uploads\/attachment\/datei\/(\d+)\/[^"]*"/){|s| full_url.path=Attachment.find($1.to_i).datei.url; 'src="'+full_url.to_s+'"'}
|
||||||
|
|
||||||
self.text.gsub!(/href="[^"]*themen\/(\d+)[^"]*"/){|s| full_url.path=thema_path(Thema.find($1.to_i)); 'href="'+full_url.to_s+'"'}
|
self.text.gsub!(/href="[^"]*themen\/(\d+)[^"]*"/){|s| full_url.path=thema_path(Thema.find($1.to_i)); 'href="'+full_url.to_s+'"'}
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -89,8 +89,11 @@ end
|
|||||||
# def filename
|
# def filename
|
||||||
# "something.jpg" if original_filename
|
# "something.jpg" if original_filename
|
||||||
# end
|
# end
|
||||||
protected
|
def extention
|
||||||
def image?(file)
|
File.extname(full_filename(file.file)).downcase
|
||||||
%w(jpg png jpeg).include?(File.extname(full_filename(file)))
|
end
|
||||||
|
|
||||||
|
def image?(for_file)
|
||||||
|
%w(.jpg .png .jpeg).include?(File.extname(full_filename(for_file.file)).downcase)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
|
<div id="<%= beispiel.divid %>" class="contentbox">
|
||||||
<div class="row-fluid contentbox">
|
<div class="row-fluid">
|
||||||
<div class="span8">
|
<div class="span8">
|
||||||
|
|
||||||
<b><%=link_to ffi1_icon("note20")+" " + beispiel.name, beispiel.beispieldatei.url, title: beispiel.desc %></b>
|
<b><%=link_to ffi1_icon("note20")+" " + beispiel.name, beispiel.beispieldatei.url, title: beispiel.desc %></b>
|
||||||
|
|
||||||
<%= I18n.t("file.size") + ": " + (beispiel.beispieldatei.size/1024.0).round(2).to_s %>KiB <br>
|
<%= I18n.t("file.size") + ": " + (beispiel.beispieldatei.size/1024.0).round(2).to_s %>KiB <br>
|
||||||
<span class="linklist"><%=
|
<span class="linklist"><%=
|
||||||
if can?(:like, beispiel)
|
if can?(:like, beispiel)
|
||||||
link_to ffi1_icon("like3")+" like" + "("+beispiel.get_likes.size.to_s+")", like_beispiel_path(beispiel),title: "liked by " + ((current_user.liked?(beispiel)) ? ("you and " + ((beispiel.get_likes.size - 1).to_s + " others")) : beispiel.get_likes.size.to_s)
|
link_to ffi1_icon("like3")+" like" + "("+beispiel.get_likes.size.to_s+")", like_beispiel_path(beispiel),title: "liked by " + ((current_user.liked?(beispiel)) ? ("you and " + ((beispiel.get_likes.size - 1).to_s + " others")) : beispiel.get_likes.size.to_s), remote: true
|
||||||
else
|
else
|
||||||
"liked by " + beispiel.get_likes.size.to_s
|
"liked by " + beispiel.get_likes.size.to_s
|
||||||
end
|
end
|
||||||
@@ -15,7 +15,7 @@ end
|
|||||||
|
|
||||||
<%=
|
<%=
|
||||||
if can?(:dislike, beispiel)
|
if can?(:dislike, beispiel)
|
||||||
link_to ffi1_icon("dislike")+" dislike" + "("+beispiel.get_dislikes.size.to_s+")", dislike_beispiel_path(beispiel),title:"disliked by " + ((current_user.disliked?(beispiel)) ? ("you and " + ((beispiel.get_dislikes.size - 1).to_s + " others")) : beispiel.get_dislikes.size.to_s)
|
link_to ffi1_icon("dislike")+" dislike" + "("+beispiel.get_dislikes.size.to_s+")", dislike_beispiel_path(beispiel),title:"disliked by " + ((current_user.disliked?(beispiel)) ? ("you and " + ((beispiel.get_dislikes.size - 1).to_s + " others")) : beispiel.get_dislikes.size.to_s) , remote: true
|
||||||
else
|
else
|
||||||
"disliked by " + beispiel.get_dislikes.size.to_s
|
"disliked by " + beispiel.get_dislikes.size.to_s
|
||||||
end
|
end
|
||||||
@@ -23,10 +23,19 @@ end
|
|||||||
%>
|
%>
|
||||||
|
|
||||||
<%= link_to ff_icon("icon-pencil")+" edit", edit_beispiel_path(beispiel) if can? :edit, beispiel%>
|
<%= link_to ff_icon("icon-pencil")+" edit", edit_beispiel_path(beispiel) if can? :edit, beispiel%>
|
||||||
<%= link_to ff_icon("icon-remove")+" delete", beispiel_path(beispiel), :method=>:delete, :data=>{:confirm=>I18n.t('beispiel.sure')} if can? :delete, beispiel %></br>
|
<%= link_to ff_icon("icon-remove")+" delete", beispiel_path(beispiel), :method=>:delete, :data=>{:confirm=>I18n.t('beispiel.sure')} if can? :delete, beispiel %>
|
||||||
|
<%= link_to "Refresh", beispiel, remote: true %></br>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="span4">
|
<div class="span4">
|
||||||
<%= beispiel.desc %>
|
<%= beispiel.desc %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<%= link_to "comment" , new_comment_path( commentable_type: "Beispiel", commentable_id: beispiel.id), remote:true if can? :comment, beispiel %>
|
||||||
|
<div id="<%= Comment.formid_for(beispiel) %>">
|
||||||
|
</div>
|
||||||
|
<% unless beispiel.comments.roots.empty? %>
|
||||||
|
<div class="row-fluid"><div class="span12"><%= render partial:"comments/comments", object: beispiel.comments.order(:created_at).roots.reverse_order %></div></div>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|||||||
1
app/views/beispiele/refresh.js.erb
Normal file
1
app/views/beispiele/refresh.js.erb
Normal file
@@ -0,0 +1 @@
|
|||||||
|
$("#<%= @beispiel.divid %>").replaceWith("<%= escape_javascript ( render @beispiel ) %>")
|
||||||
1
app/views/beispiele/show.js.erb
Normal file
1
app/views/beispiele/show.js.erb
Normal file
@@ -0,0 +1 @@
|
|||||||
|
$("<%= '#' + @beispiel.divid %>").replaceWith("<%= escape_javascript render @beispiel %>")
|
||||||
17
app/views/comments/_comment.html.erb
Normal file
17
app/views/comments/_comment.html.erb
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<div id="<%= comment.divid %>">
|
||||||
|
<a class="pull-left media-object" href="#"><%= image_tag comment.thumb_url %></a>
|
||||||
|
<div class="media-body">
|
||||||
|
<b><%= comment.user.try(:email) %></b> (<%= I18n.l(comment.created_at) %>):
|
||||||
|
<p><%= comment.text %>
|
||||||
|
<% if can?(:comment, comment.commentable) %>
|
||||||
|
<br><%= link_to "comment" , new_comment_path( commentable_type: "Comment", commentable_id: comment.id), remote:true %>
|
||||||
|
<% end %>
|
||||||
|
</p>
|
||||||
|
<%= render partial:"comments/comments", object: comment.children.order(:created_at).reverse_order if comment.children.size >0 %>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="<%= Comment.formid_for(comment) %>">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
9
app/views/comments/_comments.html.erb
Normal file
9
app/views/comments/_comments.html.erb
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<% unless comments.empty? %>
|
||||||
|
<div class="contentbox" style="border-right:none;border-bottom:none; border-top:none">
|
||||||
|
<ul class="unstyled media-list">
|
||||||
|
<% comments.each do |c| %>
|
||||||
|
<li class="media"><%= render c %></li>
|
||||||
|
<% end %>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
14
app/views/comments/_form.html.erb
Normal file
14
app/views/comments/_form.html.erb
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
<div id="<%= form.formid %>">
|
||||||
|
<%= semantic_form_for form , remote:true, html: {class: "form-inline"} do |f| %>
|
||||||
|
<%= f.inputs do %>
|
||||||
|
<%= f.input :commentable_id, as: :hidden %>
|
||||||
|
<%= f.input :commentable_type, as: :hidden %>
|
||||||
|
<%= f.input :text, as: :string %>
|
||||||
|
<%= f.input :anonym %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<%= f.actions do %>
|
||||||
|
<%= f.action :submit, :as => :input %>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
6
app/views/comments/edit.html.erb
Normal file
6
app/views/comments/edit.html.erb
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<h1>Editing comment</h1>
|
||||||
|
|
||||||
|
<%= render 'form', object: @comment %>
|
||||||
|
|
||||||
|
<%= link_to 'Show', @comment %> |
|
||||||
|
<%= link_to 'Back', comments_path %>
|
||||||
21
app/views/comments/index.html.erb
Normal file
21
app/views/comments/index.html.erb
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<h1>Listing comments</h1>
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<th></th>
|
||||||
|
<th></th>
|
||||||
|
<th></th>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<% @comments.each do |comment| %>
|
||||||
|
<tr>
|
||||||
|
<td><%= link_to 'Show', comment %></td>
|
||||||
|
<td><%= link_to 'Edit', edit_comment_path(comment) %></td>
|
||||||
|
<td><%= link_to 'Destroy', comment, method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<br />
|
||||||
|
|
||||||
|
<%= link_to 'New Comment', new_comment_path %>
|
||||||
5
app/views/comments/new.html.erb
Normal file
5
app/views/comments/new.html.erb
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<h1>New comment</h1>
|
||||||
|
|
||||||
|
<%= render partial: 'form', object: @comment %>
|
||||||
|
|
||||||
|
<%= link_to 'Back', comments_path %>
|
||||||
1
app/views/comments/new.js.erb
Normal file
1
app/views/comments/new.js.erb
Normal file
@@ -0,0 +1 @@
|
|||||||
|
$("#<%= @comment.formid %>").replaceWith("<%= escape_javascript render partial: "form", object: @comment %>")
|
||||||
6
app/views/comments/show.html.erb
Normal file
6
app/views/comments/show.html.erb
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<p id="notice"><%= notice %></p>
|
||||||
|
|
||||||
|
<%= render @comment %>
|
||||||
|
|
||||||
|
<%= link_to 'Edit', edit_comment_path(@comment) %> |
|
||||||
|
<%= link_to 'Back', comments_path %>
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
<p>
|
<p>
|
||||||
<b>Geburtstag</b> <%= %>
|
<b>Geburtstag</b> <%= I18n.l(interninfo.birthday,format: :short) %>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<b>Adresse:</b>
|
<b>Adresse:</b>
|
||||||
|
|||||||
@@ -9,4 +9,12 @@
|
|||||||
<%= semantic_form_for :set_page, url: fb_set_default_publish_page_user_path(current_user), html:{method: :get} do |f| %>
|
<%= semantic_form_for :set_page, url: fb_set_default_publish_page_user_path(current_user), html:{method: :get} do |f| %>
|
||||||
<%= f.input :page , :input_html => { :name => 'page' }%>
|
<%= f.input :page , :input_html => { :name => 'page' }%>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
<%= semantic_form_for :set_thema, url: choose_contact_topics_home_index_path, html:{method: :get} do |f| %>
|
||||||
|
<%= f.input :themen, :input_html=> {:name=>'themen'}, :as=>:select ,:multiple=>true,:collection =>Thema.all%>
|
||||||
|
|
||||||
|
<%= f.actions do %>
|
||||||
|
<%= f.action :submit, :as => :button, :label=> I18n.t("common.save" ) %>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
</p>
|
</p>
|
||||||
|
|||||||
@@ -1,12 +1,10 @@
|
|||||||
<div class="content-column content-wrap">
|
<div class="content-column content-wrap">
|
||||||
<h1> <%= I18n.t "kontakt.H1" %></h1>
|
<h1> <%= I18n.t "kontakt.H1" %></h1>
|
||||||
<p>
|
<% @themen.each do |th| %>
|
||||||
<%= I18n.t "kontakt.text" %>
|
<%= render partial: "themen/small", object: th %>
|
||||||
</p>
|
<% end %>
|
||||||
<h2><%= I18n.t "kontakt.service" %></h2>
|
|
||||||
<%= raw(I18n.t( "kontakt.service_text")) %>
|
|
||||||
<h2><%= I18n.t "kontakt.adresse" %></h2>
|
|
||||||
<p><%= raw(I18n.t("kontakt.adresse_text")) %></p>
|
|
||||||
<p><%= raw(I18n.t ("kontakt.telefon_text")) %></p>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -6,12 +6,30 @@ Verwendung: Aufruf mit
|
|||||||
-->
|
-->
|
||||||
<% toolbar_elements = !pretty_toolbar.nil? ? pretty_toolbar : @toolbar_elements %>
|
<% toolbar_elements = !pretty_toolbar.nil? ? pretty_toolbar : @toolbar_elements %>
|
||||||
<% unless toolbar_elements.nil? || toolbar_elements.empty? %>
|
<% unless toolbar_elements.nil? || toolbar_elements.empty? %>
|
||||||
<span class="label"><%= I18n.t("common.actions")%></span>
|
<!--<span class="label"><% I18n.t("common.actions")%></span>
|
||||||
<div class="btn-group">
|
--><div class="btn-group">
|
||||||
<% toolbar_elements.each do |t| %>
|
<% toolbar_elements.each do |t| %>
|
||||||
<% unless t[:method]==:versions %>
|
<% unless t[:method]==:versions %>
|
||||||
<% text='<i class="'.html_safe+ t[:hicon].to_s.html_safe + '"></i>'.html_safe+t[:text] %>
|
<% unless t[:method]==:dropdown %>
|
||||||
|
|
||||||
|
<% text=ff_icon(t[:hicon])+t[:text] %>
|
||||||
<%= link_to text, t[:path], :method=>t[:method], :confirm=>t[:confirm].to_s, :data=>t[:data], :class=>((t[:method].to_s=='delete') ? "btn btn-danger" : "btn") ,:remote=>(t[:remote])?true : false %>
|
<%= link_to text, t[:path], :method=>t[:method], :confirm=>t[:confirm].to_s, :data=>t[:data], :class=>((t[:method].to_s=='delete') ? "btn btn-danger" : "btn") ,:remote=>(t[:remote])?true : false %>
|
||||||
|
<% else %>
|
||||||
|
<div class="btn-group">
|
||||||
|
<a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
|
||||||
|
<%= t[:text] %><span class="caret"></span>
|
||||||
|
</a>
|
||||||
|
<ul class="dropdown-menu">
|
||||||
|
<% t[:elements].each do |t2| %>
|
||||||
|
<li>
|
||||||
|
<% text=ff_icon(t2[:hicon])+" ".html_safe + t2[:text] %>
|
||||||
|
<%= link_to text, t2[:path], :method=>t2[:method], :confirm=>t2[:confirm].to_s, :data=>t2[:data], :class=>((t2[:method].to_s=='delete') ? "btn-danger" : "") ,:remote=>(t2[:remote])?true : false %>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
<% end %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<div class="btn-group">
|
<div class="btn-group">
|
||||||
<a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
|
<a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
|
||||||
@@ -28,9 +46,9 @@ Verwendung: Aufruf mit
|
|||||||
q= q.merge(URI.decode_www_form(uri.query)) unless uri.query.nil?
|
q= q.merge(URI.decode_www_form(uri.query)) unless uri.query.nil?
|
||||||
|
|
||||||
uri.query= URI.encode_www_form(q<<["version",i.to_s])
|
uri.query= URI.encode_www_form(q<<["version",i.to_s])
|
||||||
%>
|
%>
|
||||||
<%= link_to I18n.l(v[:created_at]).to_s,uri.to_s ,:version=>v[:id] %>
|
<%= link_to I18n.l(v[:created_at]).to_s,uri.to_s ,:version=>v[:id] %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</li>
|
</li>
|
||||||
<% end %>
|
<% end %>
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
|
|
||||||
<li>
|
<li>
|
||||||
<%= link_to nlink_list_search.title, nlink_list_search %>
|
<%= link_to nlink_list_search.title, nlink_list_search %>
|
||||||
<%= link_to "add:"+nlink_list_search.title, create_link_rubrik_neuigkeit_path(@neuigkeit.rubrik,@neuigkeit, :link_id=>nlink_list_search.id, :link_type=>nlink_list_search.class.to_s) %>
|
<%= link_to create_link_rubrik_neuigkeit_path(@neuigkeit.rubrik, @neuigkeit, :link_id=>nlink_list_search.id, :link_type=>nlink_list_search.class.to_s), remote: true do %>
|
||||||
<div class="contentbox" >
|
<div class="contentbox" >
|
||||||
<% p = nlink_list_search.class.to_s.downcase.pluralize+"/nlink" %>
|
<% p = nlink_list_search.class.to_s.downcase.pluralize+"/nlink" %>
|
||||||
<%= render :partial=>p, :object=>nlink_list_search %>
|
<%= render :partial=>p, :object=>nlink_list_search %>
|
||||||
</div>
|
</div>
|
||||||
|
<% end %>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
2
app/views/neuigkeiten/create_link.js.erb
Normal file
2
app/views/neuigkeiten/create_link.js.erb
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
$('#nlink_list_search').html("");
|
||||||
|
$('#nlink_list').html("<%= escape_javascript( render partial:"nlink_list", collection: @nlinks )%>");
|
||||||
@@ -8,9 +8,15 @@
|
|||||||
</td>
|
</td>
|
||||||
<% if editor %>
|
<% if editor %>
|
||||||
<td>
|
<td>
|
||||||
<%= link_to "Edit", edit_thema_attachment_path(a.thema,a) %>
|
<div class="dropdown">
|
||||||
<%= link_to "Delete", thema_attachment_path(a.thema,a), method: "DELETE", confirm: "Sure?" %>
|
<a class="dropdown-toggle" data-toggle="dropdown" href="#">Actions</a>
|
||||||
|
<ul class="dropdown-menu">
|
||||||
|
<li>
|
||||||
|
<%= link_to ff_icon("icon-pencil")+"Edit", edit_thema_attachment_path(a.thema,a) %>
|
||||||
|
</li><li>
|
||||||
|
<%= link_to "Delete Attachment", thema_attachment_path(a.thema,a), method: "DELETE", confirm: "Sure?" , class: "btn-danger " %>
|
||||||
|
</li></ul>
|
||||||
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<% end %>
|
<% end %>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
@@ -2,19 +2,33 @@
|
|||||||
<% select.attachments.each_slice(6) do |row| %>
|
<% select.attachments.each_slice(6) do |row| %>
|
||||||
<div class="row-fluid">
|
<div class="row-fluid">
|
||||||
<% row.each do |attachment|
|
<% row.each do |attachment|
|
||||||
data_ext = attachment.datei.file.extension.downcase %>
|
%>
|
||||||
<div class="span2" align="center">
|
<div class="span2" align="center">
|
||||||
<%= link_to attachment.name, edit_thema_attachment_path(@thema,attachment) %></br>
|
<div class="dropdown">
|
||||||
<% if (!["jpg","png","jpeg"].find_index(data_ext).nil?) %>
|
<a class="dropdown-toggle" data-toggle="dropdown" href="#">
|
||||||
|
<% if attachment.image? %>
|
||||||
<%= image_tag attachment.datei.thumb.url %>
|
<%= image_tag attachment.datei.thumb.url %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<%= image_tag "pdf-logo.jpg" %>
|
<%= image_tag "pdf-logo.jpg" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
</a>
|
||||||
<% if(editor) %>
|
<% if(editor) %>
|
||||||
</br><button type="button" onclick="insertAttachment(<%="\"" + attachment.datei.url + "\""%>,<%="\""+attachment.name+"\""%>)">Insert Me!</button>
|
</br>
|
||||||
<% else %>
|
<ul class="dropdown-menu">
|
||||||
</br><%= link_to 'Destroy',[@thema,attachment], method: :delete, data: { confirm: 'Are you sure?' } %>
|
<li>
|
||||||
|
<a href="#" onclick="insertAttachment(<%="\"" + attachment.datei.url + "\""%>,<%="\""+attachment.name+"\""%>)"> Datei einfügen</a></li>
|
||||||
|
<% if attachment.image? %>
|
||||||
|
<li><a type="button" onclick="insertAttachment(<%="\"" + attachment.datei.thumb_big.url + "\""%>,<%="\""+attachment.name+"\""%>)">Thumb einfügen</a></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<% else %>
|
||||||
|
<ul class="dropdown-menu">
|
||||||
|
<li>
|
||||||
|
<%= link_to 'Destroy',[@thema,attachment], method: :delete, data: { confirm: 'Are you sure?' } %>
|
||||||
|
</li>
|
||||||
|
</ul> <% end %>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
<% if can? :show, small %>
|
||||||
<a name="thema_<%=small.id%>" href="#<%=small.id%>">
|
<a name="thema_<%=small.id%>" href="#<%=small.id%>">
|
||||||
<h2><%= small.title %> <%= link_to fa_icon("pencil"), verwalten_thema_path(small) if can? :edit, small %></h2>
|
<h2><%= small.title %> <%= link_to fa_icon("pencil"), verwalten_thema_path(small) if can? :edit, small %></h2>
|
||||||
</a>
|
</a>
|
||||||
@@ -30,3 +31,6 @@
|
|||||||
@small_elements << {:icon=>:pencil, :hicon=>'icon-pencil', :text=>I18n.t('thema.edit'), :path=>small} if can? :edit, small
|
@small_elements << {:icon=>:pencil, :hicon=>'icon-pencil', :text=>I18n.t('thema.edit'), :path=>small} if can? :edit, small
|
||||||
@small_elements << {:hicon=>'icon-remove-circle',:text=>I18n.t('thema.remove'), :path=>small, :method=>:delete,:confirm=>I18n.t('thema.sure')} if can? :delete, small %>
|
@small_elements << {:hicon=>'icon-remove-circle',:text=>I18n.t('thema.remove'), :path=>small, :method=>:delete,:confirm=>I18n.t('thema.sure')} if can? :delete, small %>
|
||||||
<% render :partial=>'layouts/pretty_toolbar', :object=>@small_elements unless @small_elements.empty? %>
|
<% render :partial=>'layouts/pretty_toolbar', :object=>@small_elements unless @small_elements.empty? %>
|
||||||
|
<% else %>
|
||||||
|
Error
|
||||||
|
<% end %>
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
<%= thema.title%>
|
<%= thema.title if can? :show , thema %>
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,13 @@
|
|||||||
<% verw_liste.each do |thema| %>
|
<% verw_liste.each do |thema| %>
|
||||||
<li id="themen_<%= thema.id %>" class="sort" ><div class="contentbox handle" ><b><%= thema.title %></b> </div>
|
<li id="themen_<%= thema.id %>" class="sort" >
|
||||||
|
<div class="dropdown contentbox handle">
|
||||||
<%= link_to thema_path(thema),:remote=>true do %> Show <% end %>
|
<a href="#" data-toggle="dropdown" class="dropdown-toggle"><b><%= thema.title %></b></a> <%= link_to thema_path(thema),:remote=>true do %> <%= fa_icon('eye') %> <% end %><%= link_to edit_thema_path(thema),:remote=>true do %> <%= ff_icon('icon-pencil') %> <% end %>
|
||||||
<%= link_to edit_thema_path(thema),:remote=>true do %> Edit <% end %>
|
|
||||||
<%= link_to fragen_thema_path(thema),:remote=>true do %> Fragen <% end %>
|
<ul class="dropdown-menu">
|
||||||
<%= link_to attachments_thema_path(thema),:remote=>true do %> Attachments <% end %></li>
|
<li><%= link_to thema_path(thema),:remote=>true do %> <%= fa_icon('eye') %> Show <% end %></li>
|
||||||
|
<li><%= link_to edit_thema_path(thema),:remote=>true do %> <%= ff_icon('icon-pencil') %> Edit <% end %> </li>
|
||||||
|
<li><%= link_to fragen_thema_path(thema),:remote=>true do %> Fragen <% end %></li>
|
||||||
|
<li><%= link_to attachments_thema_path(thema),:remote=>true do %> Attachments <% end %></li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<%= link_to themengruppe,{:class=>'linkbox color-1-dark'} do %>
|
<%= link_to themengruppe,{:class=>'linkbox color-1-dark'} do %>
|
||||||
|
<div class="container-fluid">
|
||||||
<div class="row-fluid">
|
<div class="row-fluid">
|
||||||
<div class="span12">
|
<div class="span12">
|
||||||
<div class="media">
|
<div class="media">
|
||||||
@@ -45,5 +46,5 @@
|
|||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -2,21 +2,21 @@
|
|||||||
<%= render :partial=>'layouts/pretty_toolbar' %>
|
<%= render :partial=>'layouts/pretty_toolbar' %>
|
||||||
<ul class="linklist">
|
<ul class="linklist">
|
||||||
<li>
|
<li>
|
||||||
<%= link_to fa_icon("question")+ I18n.t("themengruppe.faqs"), faqs_themengruppen_path,class: :linkbox %>
|
<%= link_to fa_icon("question")+ I18n.t("themengruppe.faqs"), faqs_themengruppen_path,class: :linkbox %>
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</p>
|
|
||||||
<ul class="unstyled linkbox-list">
|
|
||||||
<li>
|
|
||||||
<% @themengruppen.each do |themengruppe| %>
|
|
||||||
<div class="container-fluid">
|
|
||||||
<%= render themengruppe if can?(:show,themengruppe)%>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
</p>
|
||||||
|
<ul class="unstyled linkbox-list">
|
||||||
|
<% @themengruppen.each do |themengruppe| %>
|
||||||
|
<li>
|
||||||
|
|
||||||
<br/>
|
<%= render themengruppe if can?(:show,themengruppe)%>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
<% end %>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<br/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script class="hidden-phone">
|
<script class="hidden-phone">
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
<div class="content-wrap content-column" >
|
<div class="content-wrap content-column" >
|
||||||
<ul class="linklist">
|
<ul class="linklist">
|
||||||
<% if @themengruppe.public %>
|
<% if @themengruppe.public %>
|
||||||
<li> <%= link_to fa_icon("arrow-circle-left 2x")+I18n.t("themengruppe.showall"), themengruppen_path, :class=>"linkbox" %></li>
|
<li><%= link_to fa_icon("arrow-circle-left 2x")+I18n.t("themengruppe.showall"), themengruppen_path, :class=>"linkbox" %></li>
|
||||||
<% else %>
|
<% else %>
|
||||||
<li> <%= link_to fa_icon("arrow-circle-left 2x")+I18n.t("common.intern"), intern_home_index_path, :class=>"linkbox" %></li>
|
<li> <%= link_to fa_icon("arrow-circle-left 2x")+I18n.t("common.intern"), intern_home_index_path, :class=>"linkbox" %></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
<li><%= link_to fa_icon("question 2x")+ I18n.t("themengruppe.faqs"), faqs_themengruppen_path(:anchor=>"themengruppe_"+@themengruppe.id.to_s), :class=>"linkbox" %>
|
<li><%= link_to fa_icon("question 2x")+ I18n.t("themengruppe.faqs"), faqs_themengruppen_path(:anchor=>"themengruppe_"+@themengruppe.id.to_s), :class=>"linkbox" %>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<%= render :partial=>'layouts/pretty_toolbar' %>
|
<%= render :partial=>'layouts/pretty_toolbar' %>
|
||||||
|
|
||||||
<h1> <% unless @themengruppe.icon.nil? or @themengruppe.icon.empty? %> <i class="<%= @themengruppe.icon %>" style="font-size:1.5em;margin:0"></i>
|
<h1> <% unless @themengruppe.icon.nil? or @themengruppe.icon.empty? %> <i class="<%= @themengruppe.icon %>" style="font-size:1.5em;margin:0"></i>
|
||||||
|
|||||||
@@ -3,11 +3,18 @@
|
|||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<div class="row-fluid">
|
<div class="row-fluid">
|
||||||
<div class="span6">
|
<div class="span6">
|
||||||
|
|
||||||
|
<ul class="linklist">
|
||||||
<p>
|
<li>
|
||||||
<%= ffi1_icon "academic" %><%= link_to I18n.t('home.login'), user_omniauth_authorize_path(:ldap) %>
|
<%= link_to ffi1_icon("academic") + I18n.t('home.login'), user_omniauth_authorize_path(:ldap) ,class: :linkbox %>
|
||||||
</p>
|
</li>
|
||||||
|
<li>
|
||||||
|
<%= link_to "Entwicklungsstatus" , dev_home_index_path ,class: :linkbox %>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<%= link_to "FAQS", faqs_themengruppen_path,class: :btn ,class: :linkbox %>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
<div class="alert">
|
<div class="alert">
|
||||||
<h2>Beta Test</h2>
|
<h2>Beta Test</h2>
|
||||||
<p>Die Webseite befindet sich derzeit in einem Entwicklungsstadium,
|
<p>Die Webseite befindet sich derzeit in einem Entwicklungsstadium,
|
||||||
@@ -28,9 +35,7 @@
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<%= link_to "Entwicklungsstatus" , dev_home_index_path %>
|
|
||||||
<p>
|
|
||||||
<%= link_to "FAQS", faqs_themengruppen_path,class: :btn %>
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<%= render 'beispiele' %>
|
<%= render 'beispiele' %>
|
||||||
|
|||||||
@@ -1,29 +1,38 @@
|
|||||||
<h1><%= @themengruppe.title %></h1>
|
<h1><% unless @themengruppe.icon.nil? or @themengruppe.icon.empty? %> <i class="<%= @themengruppe.icon %>" style="font-size:1.5em;margin:0"></i>
|
||||||
|
<% end %><%= @themengruppe.title %></h1>
|
||||||
<p>
|
<p>
|
||||||
<%= @themengruppe.text %>
|
<%= @themengruppe.text %>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div class="accordion" id="accordion1">
|
<div class="accordion" id="accordion1">
|
||||||
<% @themen.each do |thema| %>
|
<% @themen.each do |thema| %>
|
||||||
<div class="accordion-group">
|
<div class="accordion-group">
|
||||||
<div class="accordion-heading">
|
<div class="accordion-heading">
|
||||||
<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion1" href="#collapse<%=thema.id%>">
|
<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion1" href="#collapse<%=thema.id%>">
|
||||||
<%= thema.title %>
|
<%= thema.title %>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div id="collapse<%=thema.id%>" class="accordion-body<%= ' collapse' unless params['thema'].to_i==thema.id %>">
|
<div id="collapse<%=thema.id%>" class="accordion-body<%= ' collapse' unless params['thema'].to_i==thema.id %>">
|
||||||
<div class="accordion-inner">
|
<div class="accordion-inner">
|
||||||
<% unless thema.gremium.nil? %>
|
|
||||||
<p><%= link_to "Zu dem Gremium ..." , thema.gremium %>
|
|
||||||
</p>
|
|
||||||
<% end %>
|
|
||||||
<%= render :partial => 'themen/small', :object => thema %>
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
<%= render :partial => 'themen/small', :object => thema %>
|
||||||
</div>
|
<ul class="unstyled">
|
||||||
</div>
|
<% unless thema.gremium.nil? %>
|
||||||
|
<li>
|
||||||
|
<%= link_to fa_icon("users 2x")+thema.gremium.name , thema.gremium,:class=>"linkbox" %>
|
||||||
|
</li>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<% thema.nlinks.each do |l| %>
|
||||||
|
<li>
|
||||||
|
<%= render l.neuigkeit if can? :show, l.neuigkeit%>
|
||||||
|
</li>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ require File.expand_path('../boot', __FILE__)
|
|||||||
|
|
||||||
require 'rails/all'
|
require 'rails/all'
|
||||||
require File.expand_path('lib/like_voteable.rb')
|
require File.expand_path('lib/like_voteable.rb')
|
||||||
|
require File.expand_path('lib/is_commentable.rb')
|
||||||
|
|
||||||
if defined?(Bundler)
|
if defined?(Bundler)
|
||||||
# If you precompile assets before deploying to production, use this line
|
# If you precompile assets before deploying to production, use this line
|
||||||
Bundler.require(*Rails.groups(:assets => %w(development test)))
|
Bundler.require(*Rails.groups(:assets => %w(development test)))
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
Fetsite::Application.routes.draw do
|
Fetsite::Application.routes.draw do
|
||||||
|
resources :comments
|
||||||
|
|
||||||
|
|
||||||
themes_for_rails
|
themes_for_rails
|
||||||
devise_for :users, :controllers => { :omniauth_callbacks => "users/omniauth_callbacks" }
|
devise_for :users, :controllers => { :omniauth_callbacks => "users/omniauth_callbacks" }
|
||||||
resources :home, :only=>[:index] do
|
resources :home, :only=>[:index] do
|
||||||
@@ -73,6 +76,7 @@ Fetsite::Application.routes.draw do
|
|||||||
get 'beispiel_sammlung'
|
get 'beispiel_sammlung'
|
||||||
get 'compare_tiss'
|
get 'compare_tiss'
|
||||||
get 'load_tiss'
|
get 'load_tiss'
|
||||||
|
get 'verwalten'
|
||||||
end
|
end
|
||||||
resources :beispiele#, :only=>[:show,:index,:create]
|
resources :beispiele#, :only=>[:show,:index,:create]
|
||||||
|
|
||||||
@@ -126,7 +130,7 @@ Fetsite::Application.routes.draw do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
resources :comments
|
||||||
resources :home, :only=>[:index] do
|
resources :home, :only=>[:index] do
|
||||||
get :search, :on => :collection
|
get :search, :on => :collection
|
||||||
collection do
|
collection do
|
||||||
@@ -135,7 +139,8 @@ Fetsite::Application.routes.draw do
|
|||||||
get 'dev'
|
get 'dev'
|
||||||
get 'startdev'
|
get 'startdev'
|
||||||
get 'linksnotimplemented'
|
get 'linksnotimplemented'
|
||||||
get 'kontakt'
|
get 'kontakt'
|
||||||
|
get 'choose_contact_topics'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
19
db/migrate/20140723172934_create_comments.rb
Normal file
19
db/migrate/20140723172934_create_comments.rb
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
class CreateComments < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
create_table :comments do |t|
|
||||||
|
t.integer :user_id
|
||||||
|
t.integer :commentable_id
|
||||||
|
t.string :commentable_type
|
||||||
|
t.text :text
|
||||||
|
t.integer :parent_id
|
||||||
|
t.integer :lft
|
||||||
|
t.integer :rgt
|
||||||
|
t.integer :depth
|
||||||
|
t.boolean :hidden
|
||||||
|
t.boolean :official
|
||||||
|
t.boolean :intern
|
||||||
|
t.boolean :anonym
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
20
lib/is_commentable.rb
Normal file
20
lib/is_commentable.rb
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
module IsCommentable
|
||||||
|
def self.included(base)
|
||||||
|
base.class_eval do
|
||||||
|
include InstanceMethods
|
||||||
|
has_many :comments, as: :commentable, dependent: :destroy
|
||||||
|
# extend ClassMethods
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
module InstanceMethods
|
||||||
|
def is_commentable?
|
||||||
|
true
|
||||||
|
end
|
||||||
|
def comment(user, text, attr={})
|
||||||
|
comments << Comment.build_for(self, user, text, attr)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
@@ -8,13 +8,39 @@ module LikeVoteable
|
|||||||
module InstanceMethods
|
module InstanceMethods
|
||||||
def like
|
def like
|
||||||
@obj=controller_name.classify.constantize.find(params[:id])
|
@obj=controller_name.classify.constantize.find(params[:id])
|
||||||
@obj.liked_by current_user
|
if current_user.liked? @obj
|
||||||
redirect_to @obj
|
@obj.unliked_by current_user
|
||||||
|
else
|
||||||
|
@obj.liked_by current_user
|
||||||
|
end
|
||||||
|
respond_to do |format|
|
||||||
|
format.html {
|
||||||
|
redirect_to @obj
|
||||||
|
}
|
||||||
|
format.js {
|
||||||
|
render :show
|
||||||
|
}
|
||||||
|
#
|
||||||
|
end
|
||||||
end
|
end
|
||||||
def dislike
|
def dislike
|
||||||
@obj=controller_name.classify.constantize.find(params[:id])
|
@obj=controller_name.classify.constantize.find(params[:id])
|
||||||
@obj.disliked_by current_user
|
if current_user.disliked?(@obj)
|
||||||
redirect_to @obj
|
@obj.undisliked_by current_user
|
||||||
|
else
|
||||||
|
@obj.disliked_by current_user
|
||||||
|
end
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html {
|
||||||
|
redirect_to @obj
|
||||||
|
}
|
||||||
|
format.js {
|
||||||
|
render :show
|
||||||
|
}
|
||||||
|
#
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
160
spec/controllers/comments_controller_spec.rb
Normal file
160
spec/controllers/comments_controller_spec.rb
Normal file
@@ -0,0 +1,160 @@
|
|||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
# This spec was generated by rspec-rails when you ran the scaffold generator.
|
||||||
|
# It demonstrates how one might use RSpec to specify the controller code that
|
||||||
|
# was generated by Rails when you ran the scaffold generator.
|
||||||
|
#
|
||||||
|
# It assumes that the implementation code is generated by the rails scaffold
|
||||||
|
# generator. If you are using any extension libraries to generate different
|
||||||
|
# controller code, this generated spec may or may not pass.
|
||||||
|
#
|
||||||
|
# It only uses APIs available in rails and/or rspec-rails. There are a number
|
||||||
|
# of tools you can use to make these specs even more expressive, but we're
|
||||||
|
# sticking to rails and rspec-rails APIs to keep things simple and stable.
|
||||||
|
#
|
||||||
|
# Compared to earlier versions of this generator, there is very limited use of
|
||||||
|
# stubs and message expectations in this spec. Stubs are only used when there
|
||||||
|
# is no simpler way to get a handle on the object needed for the example.
|
||||||
|
# Message expectations are only used when there is no simpler way to specify
|
||||||
|
# that an instance is receiving a specific message.
|
||||||
|
|
||||||
|
describe CommentsController do
|
||||||
|
|
||||||
|
# This should return the minimal set of attributes required to create a valid
|
||||||
|
# Comment. As you add validations to Comment, be sure to
|
||||||
|
# adjust the attributes here as well.
|
||||||
|
let(:valid_attributes) { { } }
|
||||||
|
|
||||||
|
# This should return the minimal set of values that should be in the session
|
||||||
|
# in order to pass any filters (e.g. authentication) defined in
|
||||||
|
# CommentsController. Be sure to keep this updated too.
|
||||||
|
let(:valid_session) { {} }
|
||||||
|
|
||||||
|
describe "GET index" do
|
||||||
|
it "assigns all comments as @comments" do
|
||||||
|
comment = Comment.create! valid_attributes
|
||||||
|
get :index, {}, valid_session
|
||||||
|
assigns(:comments).should eq([comment])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "GET show" do
|
||||||
|
it "assigns the requested comment as @comment" do
|
||||||
|
comment = Comment.create! valid_attributes
|
||||||
|
get :show, {:id => comment.to_param}, valid_session
|
||||||
|
assigns(:comment).should eq(comment)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "GET new" do
|
||||||
|
it "assigns a new comment as @comment" do
|
||||||
|
get :new, {}, valid_session
|
||||||
|
assigns(:comment).should be_a_new(Comment)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "GET edit" do
|
||||||
|
it "assigns the requested comment as @comment" do
|
||||||
|
comment = Comment.create! valid_attributes
|
||||||
|
get :edit, {:id => comment.to_param}, valid_session
|
||||||
|
assigns(:comment).should eq(comment)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "POST create" do
|
||||||
|
describe "with valid params" do
|
||||||
|
it "creates a new Comment" do
|
||||||
|
expect {
|
||||||
|
post :create, {:comment => valid_attributes}, valid_session
|
||||||
|
}.to change(Comment, :count).by(1)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "assigns a newly created comment as @comment" do
|
||||||
|
post :create, {:comment => valid_attributes}, valid_session
|
||||||
|
assigns(:comment).should be_a(Comment)
|
||||||
|
assigns(:comment).should be_persisted
|
||||||
|
end
|
||||||
|
|
||||||
|
it "redirects to the created comment" do
|
||||||
|
post :create, {:comment => valid_attributes}, valid_session
|
||||||
|
response.should redirect_to(Comment.last)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "with invalid params" do
|
||||||
|
it "assigns a newly created but unsaved comment as @comment" do
|
||||||
|
# Trigger the behavior that occurs when invalid params are submitted
|
||||||
|
Comment.any_instance.stub(:save).and_return(false)
|
||||||
|
post :create, {:comment => { }}, valid_session
|
||||||
|
assigns(:comment).should be_a_new(Comment)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "re-renders the 'new' template" do
|
||||||
|
# Trigger the behavior that occurs when invalid params are submitted
|
||||||
|
Comment.any_instance.stub(:save).and_return(false)
|
||||||
|
post :create, {:comment => { }}, valid_session
|
||||||
|
response.should render_template("new")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "PUT update" do
|
||||||
|
describe "with valid params" do
|
||||||
|
it "updates the requested comment" do
|
||||||
|
comment = Comment.create! valid_attributes
|
||||||
|
# Assuming there are no other comments in the database, this
|
||||||
|
# specifies that the Comment created on the previous line
|
||||||
|
# receives the :update_attributes message with whatever params are
|
||||||
|
# submitted in the request.
|
||||||
|
Comment.any_instance.should_receive(:update_attributes).with({ "these" => "params" })
|
||||||
|
put :update, {:id => comment.to_param, :comment => { "these" => "params" }}, valid_session
|
||||||
|
end
|
||||||
|
|
||||||
|
it "assigns the requested comment as @comment" do
|
||||||
|
comment = Comment.create! valid_attributes
|
||||||
|
put :update, {:id => comment.to_param, :comment => valid_attributes}, valid_session
|
||||||
|
assigns(:comment).should eq(comment)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "redirects to the comment" do
|
||||||
|
comment = Comment.create! valid_attributes
|
||||||
|
put :update, {:id => comment.to_param, :comment => valid_attributes}, valid_session
|
||||||
|
response.should redirect_to(comment)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "with invalid params" do
|
||||||
|
it "assigns the comment as @comment" do
|
||||||
|
comment = Comment.create! valid_attributes
|
||||||
|
# Trigger the behavior that occurs when invalid params are submitted
|
||||||
|
Comment.any_instance.stub(:save).and_return(false)
|
||||||
|
put :update, {:id => comment.to_param, :comment => { }}, valid_session
|
||||||
|
assigns(:comment).should eq(comment)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "re-renders the 'edit' template" do
|
||||||
|
comment = Comment.create! valid_attributes
|
||||||
|
# Trigger the behavior that occurs when invalid params are submitted
|
||||||
|
Comment.any_instance.stub(:save).and_return(false)
|
||||||
|
put :update, {:id => comment.to_param, :comment => { }}, valid_session
|
||||||
|
response.should render_template("edit")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "DELETE destroy" do
|
||||||
|
it "destroys the requested comment" do
|
||||||
|
comment = Comment.create! valid_attributes
|
||||||
|
expect {
|
||||||
|
delete :destroy, {:id => comment.to_param}, valid_session
|
||||||
|
}.to change(Comment, :count).by(-1)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "redirects to the comments list" do
|
||||||
|
comment = Comment.create! valid_attributes
|
||||||
|
delete :destroy, {:id => comment.to_param}, valid_session
|
||||||
|
response.should redirect_to(comments_url)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
6
spec/factories/comments.rb
Normal file
6
spec/factories/comments.rb
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
# Read about factories at https://github.com/thoughtbot/factory_girl
|
||||||
|
|
||||||
|
FactoryGirl.define do
|
||||||
|
factory :comment do
|
||||||
|
end
|
||||||
|
end
|
||||||
15
spec/helpers/comments_helper_spec.rb
Normal file
15
spec/helpers/comments_helper_spec.rb
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
# Specs in this file have access to a helper object that includes
|
||||||
|
# the CommentsHelper. For example:
|
||||||
|
#
|
||||||
|
# describe CommentsHelper 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
|
||||||
|
describe CommentsHelper do
|
||||||
|
pending "add some examples to (or delete) #{__FILE__}"
|
||||||
|
end
|
||||||
5
spec/models/comment_spec.rb
Normal file
5
spec/models/comment_spec.rb
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe Comment do
|
||||||
|
pending "add some examples to (or delete) #{__FILE__}"
|
||||||
|
end
|
||||||
11
spec/requests/comments_spec.rb
Normal file
11
spec/requests/comments_spec.rb
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe "Comments" do
|
||||||
|
describe "GET /comments" do
|
||||||
|
it "works! (now write some real specs)" do
|
||||||
|
# Run the generator again with the --webrat flag if you want to use webrat methods/matchers
|
||||||
|
get comments_path
|
||||||
|
response.status.should be(200)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
35
spec/routing/comments_routing_spec.rb
Normal file
35
spec/routing/comments_routing_spec.rb
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
require "spec_helper"
|
||||||
|
|
||||||
|
describe CommentsController do
|
||||||
|
describe "routing" do
|
||||||
|
|
||||||
|
it "routes to #index" do
|
||||||
|
get("/comments").should route_to("comments#index")
|
||||||
|
end
|
||||||
|
|
||||||
|
it "routes to #new" do
|
||||||
|
get("/comments/new").should route_to("comments#new")
|
||||||
|
end
|
||||||
|
|
||||||
|
it "routes to #show" do
|
||||||
|
get("/comments/1").should route_to("comments#show", :id => "1")
|
||||||
|
end
|
||||||
|
|
||||||
|
it "routes to #edit" do
|
||||||
|
get("/comments/1/edit").should route_to("comments#edit", :id => "1")
|
||||||
|
end
|
||||||
|
|
||||||
|
it "routes to #create" do
|
||||||
|
post("/comments").should route_to("comments#create")
|
||||||
|
end
|
||||||
|
|
||||||
|
it "routes to #update" do
|
||||||
|
put("/comments/1").should route_to("comments#update", :id => "1")
|
||||||
|
end
|
||||||
|
|
||||||
|
it "routes to #destroy" do
|
||||||
|
delete("/comments/1").should route_to("comments#destroy", :id => "1")
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
15
spec/views/comments/edit.html.erb_spec.rb
Normal file
15
spec/views/comments/edit.html.erb_spec.rb
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe "comments/edit" do
|
||||||
|
before(:each) do
|
||||||
|
@comment = assign(:comment, stub_model(Comment))
|
||||||
|
end
|
||||||
|
|
||||||
|
it "renders the edit comment form" do
|
||||||
|
render
|
||||||
|
|
||||||
|
# Run the generator again with the --webrat flag if you want to use webrat matchers
|
||||||
|
assert_select "form[action=?][method=?]", comment_path(@comment), "post" do
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
15
spec/views/comments/index.html.erb_spec.rb
Normal file
15
spec/views/comments/index.html.erb_spec.rb
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe "comments/index" do
|
||||||
|
before(:each) do
|
||||||
|
assign(:comments, [
|
||||||
|
stub_model(Comment),
|
||||||
|
stub_model(Comment)
|
||||||
|
])
|
||||||
|
end
|
||||||
|
|
||||||
|
it "renders a list of comments" do
|
||||||
|
render
|
||||||
|
# Run the generator again with the --webrat flag if you want to use webrat matchers
|
||||||
|
end
|
||||||
|
end
|
||||||
15
spec/views/comments/new.html.erb_spec.rb
Normal file
15
spec/views/comments/new.html.erb_spec.rb
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe "comments/new" do
|
||||||
|
before(:each) do
|
||||||
|
assign(:comment, stub_model(Comment).as_new_record)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "renders new comment form" do
|
||||||
|
render
|
||||||
|
|
||||||
|
# Run the generator again with the --webrat flag if you want to use webrat matchers
|
||||||
|
assert_select "form[action=?][method=?]", comments_path, "post" do
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
12
spec/views/comments/show.html.erb_spec.rb
Normal file
12
spec/views/comments/show.html.erb_spec.rb
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe "comments/show" do
|
||||||
|
before(:each) do
|
||||||
|
@comment = assign(:comment, stub_model(Comment))
|
||||||
|
end
|
||||||
|
|
||||||
|
it "renders attributes in <p>" do
|
||||||
|
render
|
||||||
|
# Run the generator again with the --webrat flag if you want to use webrat matchers
|
||||||
|
end
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user