Merge remote-tracking branch 'origin/master' into extrafeature

This commit is contained in:
Andreas Stephanides
2014-09-13 16:36:31 +02:00
61 changed files with 821 additions and 111 deletions

View File

@@ -17,7 +17,10 @@ class BeispieleController < ApplicationController
def show
# @lva = params([:lva]) unless params([:lva]).nil?
@beispiel = Beispiel.find(params[:id])
redirect_to @beispiel.lva
respond_to do |format|
format.html { redirect_to @beispiel.lva }
format.js
end
end
# GET /beispiele/new

View 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

View File

@@ -4,4 +4,6 @@ class ConfigController < ApplicationController
end
def choose_contact_topics
end
end

View File

@@ -8,6 +8,8 @@ class HomeController < ApplicationController
end
def kontakt
t=YAML.load_file("#{::Rails.root.to_s}/config/contact_topic.yml")
@themen = Thema.where(:id=>t)
end
def intern
authorize! :seeintern, User
@@ -51,4 +53,9 @@ class HomeController < ApplicationController
format.js
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

View File

@@ -1,7 +1,7 @@
class LvasController < ApplicationController
# GET /lvas
require 'zip'
before_filter :load_toolbar, :only => [:show]
before_filter :load_toolbar, :only => [:verwalten]
load_and_authorize_resource
def index
@lvas = Lva.all
@@ -43,6 +43,15 @@ class LvasController < ApplicationController
def show
@lva = Lva.find_by_id(params[:id])
@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
# GET /lvas/new

View File

@@ -69,7 +69,7 @@ class NeuigkeitenController < ApplicationController
unless @neuigkeit.published?
redirect_to [@neuigkeit.rubrik,@neuigkeit], notice: 'Neuigkeit muss veröffentlicht sein um sie auf Facebook zu posten.'
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)
redirect_to [@neuigkeit.rubrik,@neuigkeit], notice: 'Neuigkeit auf Facebook gepostet'
@@ -113,9 +113,14 @@ class NeuigkeitenController < ApplicationController
render action:"show"
end
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
def create
@@ -159,21 +164,23 @@ private
def load_toolbar_elements
@neuigkeit=Neuigkeit.find(params[:id])
@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?
@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=[]
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
@versions= @neuigkeit.translation.versions.select([:created_at]).reverse
@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

View File

@@ -17,7 +17,7 @@ class UsersController < ApplicationController
redirect_to intern_home_index_path
else
@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
redirect_to admin_home_index_path
end