more forum stuff

This commit is contained in:
jomo
2013-10-16 00:51:50 +02:00
parent 7c578874c9
commit b6115970dd
25 changed files with 208 additions and 55 deletions

View File

@@ -1,9 +1,46 @@
class ForumgroupsController < ApplicationController
def index
@groups = Forumgroup.all.sort_by{|s| s[:position]}
@groups = Forumgroup.all
if current_user
@groups.select! do |g|
g.role_read == nil || g.role_read <= current_user.role
end
else
@groups.select!{|g| g.role_read == nil}
end
@groups.sort_by{|g| g[:position]}
end
def show
redirect_to forumgroups_path + "#forum-#{params[:id]}"
redirect_to forumgroups_path + "#forums-#{params[:id]}"
end
def new
if admin?
@group = Forumgroup.new
else
flash[:alert] = "You are not allowed to create forums."
redirect_to forumgroups_path
end
end
def create
if admin?
@group = Forumgroup.new(params[:forumgroup])
if @group.save
flash[:notice] = "Forums created."
redirect_to @group
else
flash[:alert] = "Something went wrong"
render :new
end
else
flash[:alert] = "You are not allowed to create forums."
redirect_to forumgroups_path
end
end
end