AutoCommit Die Aug 4 22:03:01 CEST 2015

This commit is contained in:
Andreas Stephanides
2015-08-04 22:03:01 +02:00
parent aa06d2195e
commit 9b1c35f499
7 changed files with 57 additions and 18 deletions

View File

@@ -36,7 +36,12 @@
if user_signed_in?
flash[:error] = "Not authorized to view this page"
session[:user_return_to] = nil
redirect_to root_url
respond_to do |format|
format.html {redirect_to root_url}
format.js {render text:"alert(\"Not authorized to do this\");", status: 401}
end
else
flash[:error] = "You must first login to view this page"

View File

@@ -5,15 +5,15 @@ class BeispieleController < ApplicationController
include LikeVoteable
acts_as_flagable
def index
unless params[:lva_id].nil?
@beispiele= Lva.find(params[:lva_id]).beispiele.accessible_by(current_ability, :show)
else
@beispiele = Beispiel.accessible_by(current_ability, :show)
end
respond_to do |format|
format.html # index.html.erb
format.json { render json: @beispiele }
end
# unless params[:lva_id].nil?
# @beispiele= Lva.find(params[:lva_id]).beispiele.accessible_by(current_ability, :show)
# else
# @beispiele = Beispiel.accessible_by(current_ability, :show)
# end
# respond_to do |format|
# format.html # index.html.erb
# format.json { render json: @beispiele }
# end
end
# GET /beispiele/1

View File

@@ -36,14 +36,20 @@ cannot :destroy, Comment
can [:show], Modulgruppe
can [:show, :index], Modul
can [:show, :index, :beispiel_sammlung], Lva
can [:create, :show], Beispiel
can [:create, :show], Beispiel, flag_delete: false
if loggedin
can :like, Beispiel
can :dislike, Beispiel
end
if (user.has_role?("moderator",Beispiel))
if ((user.has_role?("moderator",Beispiel)) || user.has_role?("fetuser") || user.has_role?("fetadmin"))
can :flag, Beispiel
can [:edit, :update], Beispiel
can :flag, Beispiel
can :set_lecturer, Beispiel
can :flag_delete, Beispiel
can :flag_goodquality, Beispiel
can :flag_badquality, Beispiel
end
if (user.has_role?("moderator",Lva))
can [:verwalten, :edit, :compare_tiss, :load_tiss, :update], Lva
@@ -53,7 +59,9 @@ cannot :destroy, Comment
can :manage, Modul
can :manage, Lva
can :manage, Studium
can :manage, Beispiel
#can :manage, Beispiel
can :comment, Beispiel
can :manage, Lecturer
end

View File

@@ -5,6 +5,8 @@ class Survey::Question < ActiveRecord::Base
has_many :answers, through: :choices
include IsCommentable
scope :templates, ->{ where(flag_template:true)}
def add_yesno_choices
c=Survey::Choice.new(title: "Ja")
c.save

View File

@@ -1,9 +1,26 @@
class AddTemplateToSurveyQuestion < ActiveRecord::Migration
def change
add_column :survey_questions, :flag_template, :boolean
add_column :survey_questions, :flag_deleted, :boolean
add_column :survey_questions, :flag_intern,:boolean
def up
add_column :survey_questions, :flag_template, :boolean, :default => 0
add_column :survey_questions, :flag_delete, :boolean, :default => 0
add_column :survey_questions, :flag_intern,:boolean, :default => 0
add_column :survey_questions, :user_id, :integer
add_column :survey_questions, :flag_locked, :boolean
add_column :survey_questions, :flag_locked, :boolean, :default => 0
add_column :survey_questions, :flag_multiplechoice, :boolean, :default => 0
add_column :survey_questions, :sort, :integer
add_column :survey_questions, :flag_hidden, :boolean, :default => 0
add_column :survey_questions, :flag_emailed, :boolean, :default => 0
end
def down
remove_column :survey_questions, :flag_template
remove_column :survey_questions, :flag_delete
remove_column :survey_questions, :flag_intern
remove_column :survey_questions, :user_id
remove_column :survey_questions, :flag_locked
remove_column :survey_questions, :flag_multiplechoice
remove_column :survey_questions, :sort
remove_column :survey_questions, :flag_hidden
remove_column :survey_questions, :flag_emailed
end
end

View File

@@ -0,0 +1,6 @@
class AddFlagsToUsers < ActiveRecord::Migration
def change
add_column :users, :flag_getemails, :boolean, default: 0
add_column :users, :flag_delete, :boolean, default: 0
end
end

View File

@@ -20,6 +20,7 @@ module Flagable
@obj=controller_name.classify.constantize.find(params[:id])
lflag=("flag_"+params[:flag]).to_sym
authorize! lflag, @obj
unless params[:flag].nil? || params[:flag].empty? || params[:value].nil?
if @obj.respond_to?(lflag.to_s+"=")
@obj.send(lflag.to_s+"=",params[:value]=="true")