more forum stuff
This commit is contained in:
@@ -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.'
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
6
app/controllers/youtube.regex
Normal file
6
app/controllers/youtube.regex
Normal 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
|
||||
Reference in New Issue
Block a user