forums
This commit is contained in:
@@ -6,7 +6,7 @@ class BlogpostsController < ApplicationController
|
||||
|
||||
def show
|
||||
@post = Blogpost.find(params[:id])
|
||||
@comment = Comment.new(:blogpost => @post)
|
||||
@comment = Comment.new(blogpost: @post)
|
||||
end
|
||||
|
||||
def new
|
||||
|
||||
@@ -1,19 +1,18 @@
|
||||
class ForumgroupsController < ApplicationController
|
||||
|
||||
def index
|
||||
@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]}
|
||||
redirect_to forums_path
|
||||
end
|
||||
|
||||
def show
|
||||
redirect_to forumgroups_path + "#forums-#{params[:id]}"
|
||||
redirect_to forums_path + "#forums-#{params[:id]}"
|
||||
end
|
||||
|
||||
def edit
|
||||
end
|
||||
|
||||
def update
|
||||
|
||||
end
|
||||
|
||||
def new
|
||||
@@ -21,7 +20,7 @@ class ForumgroupsController < ApplicationController
|
||||
@group = Forumgroup.new
|
||||
else
|
||||
flash[:alert] = "You are not allowed to create forums."
|
||||
redirect_to forumgroups_path
|
||||
redirect_to forums_path
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,11 +1,23 @@
|
||||
class ForumsController < ApplicationController
|
||||
def index
|
||||
redirect_to :forumgroups
|
||||
def index
|
||||
@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
|
||||
@forum = Forum.find(params[:id])
|
||||
@threads = @forum.forumthreads
|
||||
if @forum.role_read.nil? || current_user && @forum.role_read <= current_user.role
|
||||
@threads = @forum.forumthreads.reverse
|
||||
else
|
||||
redirect_to forums_path
|
||||
end
|
||||
end
|
||||
|
||||
def new
|
||||
@@ -14,7 +26,7 @@ class ForumsController < ApplicationController
|
||||
@forum = Forum.new(forumgroup: @group)
|
||||
else
|
||||
flash[:alert] = "You are not allowed to create a forum."
|
||||
redirect_to forumgroups_path
|
||||
redirect_to forums_path
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -3,4 +3,20 @@ class ForumthreadsController < ApplicationController
|
||||
f = Forum.find(params[:id])
|
||||
redirect_to forum_path(f.forumgroup, f)
|
||||
end
|
||||
|
||||
def new
|
||||
@forum = Forum.find(params[:id])
|
||||
if @forum && current_user && (@forum.group.role_read.nil? || @forum.group.role_read <= current_user.role) && (@forum.role_read.nil? || @forum.role_read <= current_user.role)
|
||||
@thread = Forumthread.new(forum: @forum)
|
||||
else
|
||||
flash[:alert] = "You are not allowed to create a new thread here!"
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
flash[:alert] = "Not yet ;("
|
||||
redirect_to forum_path(params[:id])
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
@@ -3,8 +3,10 @@ class SessionsController < ApplicationController
|
||||
|
||||
def new
|
||||
if current_user
|
||||
redirect_to current_user
|
||||
flash[:alert] = "You are already logged in!"
|
||||
redirect_to current_user
|
||||
else
|
||||
cookies[:return_path] = params[:return_path] if params[:return_path]
|
||||
end
|
||||
end
|
||||
|
||||
@@ -23,23 +25,27 @@ class SessionsController < ApplicationController
|
||||
user.save
|
||||
if user.disabled?
|
||||
flash[:alert] = "Your account has been disabled!"
|
||||
redirect_to login_path
|
||||
elsif user.banned?
|
||||
flash[:alert] = "You are banned!"
|
||||
redirect_to user
|
||||
else
|
||||
session[:user_id] = user.id
|
||||
flash[:alert] = "Remember to validate your email! Your account might be deleted" if user.unconfirmed?
|
||||
redirect_to root_path, :notice => "Logged in!"
|
||||
flash[:alert] = "Remember to validate your email! Your account may be deleted soon!" if user.unconfirmed?
|
||||
flash[:notice] = "Logged in!"
|
||||
end
|
||||
else
|
||||
flash[:alert] = "You're doing it wrong!"
|
||||
render action: 'new'
|
||||
return
|
||||
end
|
||||
else
|
||||
redirect_to current_user
|
||||
flash[:alert] = "You are already logged in!"
|
||||
end
|
||||
if cookies[:return_path]
|
||||
redirect_to cookies[:return_path]
|
||||
cookies.delete(:return_path)
|
||||
else
|
||||
redirect_to root_path
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
|
||||
Reference in New Issue
Block a user