diff --git a/app/assets/stylesheets/screen.css.scss b/app/assets/stylesheets/screen.css.scss index 759ff1f..a88487a 100644 --- a/app/assets/stylesheets/screen.css.scss +++ b/app/assets/stylesheets/screen.css.scss @@ -330,14 +330,17 @@ and (min-width: 0px) //TODO } } + .input { + height: 3em; + } input[type=text], input[type=email], input[type=password], input[type=number], textarea, select { background: #ddd; border: none; - display: block; height: 3em; margin: 0 0 1px 0; padding: 0.5em 1em; width: 100%; + display: block; } input, select, textarea { @@ -374,14 +377,14 @@ and (min-width: 0px) //TODO } .field_with_errors { - input { - &[type=text], &[type=email], &[type=password] { - border: 1px solid #f00; - box-shadow: 0 0 5px #faa inset; - } + input, select, textarea { + border: 1px solid #f00; + box-shadow: 0 0 5px #faa inset; } .error { color: #f60; + display: inline; + margin-left: 0.5em; } } @@ -518,6 +521,10 @@ and (min-width: 0px) //TODO #forum_groups { .group { margin: 10px 0; + &:hover .editlink { + opacity: 1; + margin-right: 0; + } .header { background: #ddd; border-radius: 5px 5px 0 0; diff --git a/app/controllers/blogposts_controller.rb b/app/controllers/blogposts_controller.rb index 86adbb3..789ed72 100644 --- a/app/controllers/blogposts_controller.rb +++ b/app/controllers/blogposts_controller.rb @@ -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 diff --git a/app/controllers/forumgroups_controller.rb b/app/controllers/forumgroups_controller.rb index bacadab..5b9528c 100644 --- a/app/controllers/forumgroups_controller.rb +++ b/app/controllers/forumgroups_controller.rb @@ -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 diff --git a/app/controllers/forums_controller.rb b/app/controllers/forums_controller.rb index 2ecb551..5c387a1 100644 --- a/app/controllers/forums_controller.rb +++ b/app/controllers/forums_controller.rb @@ -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 diff --git a/app/controllers/forumthreads_controller.rb b/app/controllers/forumthreads_controller.rb index 27e2bb7..3508d55 100644 --- a/app/controllers/forumthreads_controller.rb +++ b/app/controllers/forumthreads_controller.rb @@ -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 \ No newline at end of file diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index d3260fe..33e38d6 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -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 diff --git a/app/models/forumthread.rb b/app/models/forumthread.rb index d56c700..e72d157 100644 --- a/app/models/forumthread.rb +++ b/app/models/forumthread.rb @@ -3,6 +3,11 @@ class Forumthread < ActiveRecord::Base belongs_to :user_author, class_name: "User", foreign_key: "user_author_id" belongs_to :user_editor, class_name: "User", foreign_key: "user_editor_id" + attr_accessible :name, :content, :sticky, :locked, :user_author, :user_editor, :forum + + validates_presence_of :name + validates_presence_of :content + def to_s name end diff --git a/app/views/forumgroups/edit.html.erb b/app/views/forumgroups/edit.html.erb new file mode 100644 index 0000000..583bf25 --- /dev/null +++ b/app/views/forumgroups/edit.html.erb @@ -0,0 +1 @@ +