diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/user_controller.rb | 12 | ||||
-rw-r--r-- | app/models/user.rb | 12 | ||||
-rw-r--r-- | app/views/user/set_draft_profile_photo.html.erb | 4 | ||||
-rw-r--r-- | app/views/user/set_profile_about_me.html.erb | 8 | ||||
-rw-r--r-- | app/views/user/show.html.erb | 2 |
5 files changed, 32 insertions, 6 deletions
diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb index 56f42891d..d66b4aa8e 100644 --- a/app/controllers/user_controller.rb +++ b/app/controllers/user_controller.rb @@ -460,6 +460,12 @@ class UserController < ApplicationController return end if !params[:submitted_draft_profile_photo].nil? + if @user.banned? + flash[:error]= _('Banned users cannot edit their profile') + redirect_to set_profile_photo_path + return + end + # check for uploaded image file_name = nil file_content = nil @@ -569,6 +575,12 @@ class UserController < ApplicationController return end + if @user.banned? + flash[:error] = _('Banned users cannot edit their profile') + redirect_to set_profile_about_me_path + return + end + @about_me = AboutMeValidator.new(params[:about_me]) if !@about_me.valid? render :action => 'set_profile_about_me' diff --git a/app/models/user.rb b/app/models/user.rb index c953e52f2..920c0da46 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -207,7 +207,7 @@ class User < ActiveRecord::Base if not name.nil? name.strip! end - if public_banned? + if banned? # Use interpolation to return a string rather than a SafeBuffer so that # gsub can be called on it until we upgrade to Rails 3.2. The name returned # is not marked as HTML safe so will be escaped automatically in views. We @@ -294,10 +294,18 @@ class User < ActiveRecord::Base def admin_page_links? super? end + # Is it public that they are banned? + def banned? + !ban_text.empty? + end + def public_banned? - !ban_text.empty? + warn %q([DEPRECATION] User#public_banned? will be replaced with + User#banned? as of 0.22).squish + banned? end + # Various ways the user can be banned, and text to describe it if failed def can_file_requests? ban_text.empty? && !exceeded_limit? diff --git a/app/views/user/set_draft_profile_photo.html.erb b/app/views/user/set_draft_profile_photo.html.erb index b4bdd80f3..ba44f54f4 100644 --- a/app/views/user/set_draft_profile_photo.html.erb +++ b/app/views/user/set_draft_profile_photo.html.erb @@ -11,7 +11,9 @@ <%= form_tag 'set_photo', :id => 'set_draft_profile_photo_form', :multipart => true do %> <p> <label class="form_label" for="file_1"><%= _('Photo of you:')%></label> - <%= file_field_tag :file, :size => 35, :id => 'file_1' %> + <% file_opts = { :size => 35, :id => 'file_1' } %> + <% file_opts.merge!({ :disabled => true }) if @user.banned? %> + <%= file_field_tag :file, file_opts %> </p> <ul> diff --git a/app/views/user/set_profile_about_me.html.erb b/app/views/user/set_profile_about_me.html.erb index fb7de7e97..42607ddf8 100644 --- a/app/views/user/set_profile_about_me.html.erb +++ b/app/views/user/set_profile_about_me.html.erb @@ -17,8 +17,12 @@ </div> <p> - <label class="form_label" for="set_profile_about_me"><%= _('About you:')%></label> - <%= f.text_area :about_me, :rows => 5, :cols => 55 %> + <label class="form_label" for="set_profile_about_me"> + <%= _('About you:')%> + </label> + <% about_me_opts = { :rows => 5, :cols => 55 } %> + <% about_me_opts.merge!({ :disabled => 'disabled' }) if @user.banned? %> + <%= f.text_area :about_me, about_me_opts %> </p> <div class="form_note"> diff --git a/app/views/user/show.html.erb b/app/views/user/show.html.erb index 7c8d52568..78b513d6a 100644 --- a/app/views/user/show.html.erb +++ b/app/views/user/show.html.erb @@ -78,7 +78,7 @@ <% end %> </p> - <% if @display_user.public_banned? %> + <% if @display_user.banned? %> <div id="user_public_banned"> <p> <strong> |