diff --git a/app/assets/stylesheets/common/main_layout.css.scss b/app/assets/stylesheets/common/main_layout.css.scss index d21ab394e..e4a607b4b 100644 --- a/app/assets/stylesheets/common/main_layout.css.scss +++ b/app/assets/stylesheets/common/main_layout.css.scss @@ -8,7 +8,7 @@ div#page { overflow: visible; margin: 0 30px; - div#upgrade-account-notice, div#sign-up-notice, div#tos-notice { + div#upgrade-account-notice, div#sign-up-notice, div#tos-notice, div#ban-notice { margin: 1em 0; padding: 1em; text-align: center; diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index f7ba73b2b..456de2626 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -88,7 +88,7 @@ protected %w(member banned builder privileged platinum contributor janitor moderator admin).each do |level| define_method("#{level}_only") do - if CurrentUser.user.__send__("is_#{level}?") + if !CurrentUser.user.is_banned? && CurrentUser.user.__send__("is_#{level}?") true else access_denied() diff --git a/app/controllers/bans_controller.rb b/app/controllers/bans_controller.rb index b0dd2b44f..d31787883 100644 --- a/app/controllers/bans_controller.rb +++ b/app/controllers/bans_controller.rb @@ -2,7 +2,7 @@ class BansController < ApplicationController before_filter :moderator_only, :except => [:show, :index] def new - @ban = Ban.new + @ban = Ban.new(params[:ban]) end def edit diff --git a/app/logical/anonymous_user.rb b/app/logical/anonymous_user.rb index a4d49219b..c2590a0d5 100644 --- a/app/logical/anonymous_user.rb +++ b/app/logical/anonymous_user.rb @@ -32,6 +32,10 @@ class AnonymousUser true end + def is_banned? + false + end + def has_mail? false end diff --git a/app/models/ban.rb b/app/models/ban.rb index 223705f2a..eaf5424e6 100644 --- a/app/models/ban.rb +++ b/app/models/ban.rb @@ -1,5 +1,7 @@ class Ban < ActiveRecord::Base after_create :update_feedback + after_create :update_user_on_create + after_destroy :update_user_on_destroy belongs_to :user belongs_to :banner, :class_name => "User" attr_accessible :reason, :duration, :user_id, :user_name @@ -67,6 +69,14 @@ class Ban < ActiveRecord::Base end end + def update_user_on_create + user.update_attribute(:is_banned, true) + end + + def update_user_on_destroy + user.update_attribute(:is_banned, false) + end + def user_name user ? user.name : nil end diff --git a/app/views/bans/show.html.erb b/app/views/bans/show.html.erb index e76fb3249..a6edd264e 100644 --- a/app/views/bans/show.html.erb +++ b/app/views/bans/show.html.erb @@ -1,11 +1,15 @@
Reason: <%= CurrentUser.user.ban.reason %>
+Your ban will expire in <%= time_ago_in_words(CurrentUser.user.ban.expires_at) %>
+