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

@@ -29,7 +29,7 @@ class BlogpostsController < ApplicationController
def create
if mod?
@post = Blogpost.new(params[:blogpost])
@post = Blogpost.new(params[:blogpost] ? params[:blogpost].slice(:title, :content) : {})
@post.user_author = current_user
if @post.save
redirect_to @post, notice: 'Post has been created.'

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

View File

@@ -8,4 +8,31 @@ class ForumsController < ApplicationController
@threads = @forum.forumthreads
end
def new
if admin?
@group = Forumgroup.find(params[:forumgroup_id])
@forum = Forum.new(forumgroup: @group)
else
flash[:alert] = "You are not allowed to create a forum."
redirect_to forumgroups_path
end
end
def create
if admin?
@forum = Forum.new(params[:forum])
@forum.forumgroup = Forumgroup.find(params[:forumgroup_id])
if @forum.save
flash[:notice] = "Forum created."
redirect_to @forum
else
flash[:alert] = "Something went wrong"
render :new
end
else
flash[:alert] = "You are not allowed to create a forum."
redirect_to forums_path
end
end
end

View File

@@ -0,0 +1,6 @@
[yt](729o_Xwg1WU)
\[yt\]\(([a-zA-Z0-9\-_]+)\)
https://www.youtube.com/embed/{id}?theme=light&iv_load_policy=3&showinfo=1&showsearch=0&rel=0&modestbranding&hd=1&autohide=1