implemented basic functionality of YE OLDE BANHAMMER!
This commit is contained in:
parent
3574993746
commit
1bb369aa7d
22
Rakefile
22
Rakefile
|
@ -90,7 +90,27 @@ namespace :justask do
|
||||||
fail "user #{args[:screen_name]} not found" if user.nil?
|
fail "user #{args[:screen_name]} not found" if user.nil?
|
||||||
user.moderator = false
|
user.moderator = false
|
||||||
user.save!
|
user.save!
|
||||||
puts "#{user.screen_name} no longer an moderator."
|
puts "#{user.screen_name} is no longer an moderator."
|
||||||
|
end
|
||||||
|
|
||||||
|
desc "Hits an user with the banhammer."
|
||||||
|
task :ban, [:screen_name] => :environment do |t, args|
|
||||||
|
fail "screen name required" if args[:screen_name].nil?
|
||||||
|
user = User.find_by_screen_name(args[:screen_name])
|
||||||
|
fail "user #{args[:screen_name]} not found" if user.nil?
|
||||||
|
user.banned = true
|
||||||
|
user.save!
|
||||||
|
puts "#{user.screen_name} got hit by\033[5m YE OLDE BANHAMMER\033[0m!!1!"
|
||||||
|
end
|
||||||
|
|
||||||
|
desc "Removes banned status from an user."
|
||||||
|
task :unban, [:screen_name] => :environment do |t, args|
|
||||||
|
fail "screen name required" if args[:screen_name].nil?
|
||||||
|
user = User.find_by_screen_name(args[:screen_name])
|
||||||
|
fail "user #{args[:screen_name]} not found" if user.nil?
|
||||||
|
user.banned = false
|
||||||
|
user.save!
|
||||||
|
puts "#{user.screen_name} is no longer banned."
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "Gives supporter status to an user."
|
desc "Gives supporter status to an user."
|
||||||
|
|
|
@ -121,3 +121,7 @@
|
||||||
.panel-badge-warning {
|
.panel-badge-warning {
|
||||||
background-color: #FF9800;
|
background-color: #FF9800;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.user--banned {
|
||||||
|
text-decoration: line-through !important;
|
||||||
|
}
|
|
@ -4,6 +4,18 @@ class ApplicationController < ActionController::Base
|
||||||
protect_from_forgery with: :exception
|
protect_from_forgery with: :exception
|
||||||
|
|
||||||
before_filter :configure_permitted_parameters, if: :devise_controller?
|
before_filter :configure_permitted_parameters, if: :devise_controller?
|
||||||
|
before_filter :banned?
|
||||||
|
|
||||||
|
# check if user got hit by the banhammer of doom
|
||||||
|
def banned?
|
||||||
|
if current_user.present? && current_user.banned?
|
||||||
|
name = current_user.screen_name
|
||||||
|
# obligatory '2001: A Space Odyssey' reference
|
||||||
|
flash[:notice] = "I'm sorry, #{name}, I'm afraid I can't do that."
|
||||||
|
sign_out current_user
|
||||||
|
redirect_to new_user_session_path
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
include ApplicationHelper
|
include ApplicationHelper
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ module UserHelper
|
||||||
def user_screen_name(user, anonymous=false, url=true)
|
def user_screen_name(user, anonymous=false, url=true)
|
||||||
return APP_CONFIG['anonymous_name'] if user.nil? || anonymous
|
return APP_CONFIG['anonymous_name'] if user.nil? || anonymous
|
||||||
name = user.display_name.blank? ? user.screen_name : user.display_name
|
name = user.display_name.blank? ? user.screen_name : user.display_name
|
||||||
return link_to(name, show_user_profile_path(user.screen_name)) if url
|
return link_to(name, show_user_profile_path(user.screen_name), class: "#{"user--banned" if user.banned?}") if url
|
||||||
name
|
name
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,47 +6,52 @@
|
||||||
- else
|
- else
|
||||||
= @user.motivation_header
|
= @user.motivation_header
|
||||||
.panel-body
|
.panel-body
|
||||||
- if user_signed_in? or @user.privacy_allow_anonymous_questions?
|
- if @user.banned?
|
||||||
#question-box
|
.row
|
||||||
.row
|
.col-xs-12.text-center
|
||||||
.col-xs-12
|
%strong This user got hit with ye olde banhammer.
|
||||||
%textarea.form-control{:name => "qb-question", :placeholder => "Type your question here…"}
|
- else
|
||||||
.row{:style => "padding-top: 5px; padding-left: 5px; padding-right: 5px;"}
|
- if user_signed_in? or @user.privacy_allow_anonymous_questions?
|
||||||
.col-xs-6
|
#question-box
|
||||||
- if user_signed_in?
|
|
||||||
- if @user.privacy_allow_anonymous_questions?
|
|
||||||
%input{:name => "qb-anonymous", :type => "checkbox"}/
|
|
||||||
Hide your name
|
|
||||||
%br/
|
|
||||||
- else
|
|
||||||
%input{:name => "qb-anonymous", :type => "hidden", :value => "false"}/
|
|
||||||
.col-xs-6
|
|
||||||
%p.pull-right
|
|
||||||
%input{name: 'qb-to', type: 'hidden', :value => @user.id}/
|
|
||||||
%button.btn.btn-primary{name: 'qb-ask', :type => "button", data: {loading_text: 'Asking...', promote: user_signed_in? ? "false" : "true" }} Ask
|
|
||||||
- unless user_signed_in?
|
|
||||||
- if @user.privacy_allow_anonymous_questions?
|
|
||||||
#question-box-promote.row{:style => "display: none;"}
|
|
||||||
.row
|
.row
|
||||||
.col-xs-12.text-center
|
.col-xs-12
|
||||||
%strong Your question has been sent.
|
%textarea.form-control{:name => "qb-question", :placeholder => "Type your question here…"}
|
||||||
.row
|
.row{:style => "padding-top: 5px; padding-left: 5px; padding-right: 5px;"}
|
||||||
.col-sm-1
|
.col-xs-6
|
||||||
.col-sm-5
|
- if user_signed_in?
|
||||||
%button#create-account.btn.btn-block.btn-primary Create an account
|
- if @user.privacy_allow_anonymous_questions?
|
||||||
.col-sm-5
|
%input{:name => "qb-anonymous", :type => "checkbox"}/
|
||||||
%button#new-question.btn.btn-block.btn-default Ask another question
|
Hide your name
|
||||||
.col-sm-1
|
%br/
|
||||||
.row
|
- else
|
||||||
.col-sm-1
|
%input{:name => "qb-anonymous", :type => "hidden", :value => "false"}/
|
||||||
.col-xs-12.col-sm-10
|
.col-xs-6
|
||||||
%small
|
%p.pull-right
|
||||||
Join
|
%input{name: 'qb-to', type: 'hidden', :value => @user.id}/
|
||||||
= APP_CONFIG['site_name']
|
%button.btn.btn-primary{name: 'qb-ask', :type => "button", data: {loading_text: 'Asking...', promote: user_signed_in? ? "false" : "true" }} Ask
|
||||||
today! You'll be able to follow and ask people you know and a lot more.
|
- unless user_signed_in?
|
||||||
.col-sm-1
|
- if @user.privacy_allow_anonymous_questions?
|
||||||
- else
|
#question-box-promote.row{:style => "display: none;"}
|
||||||
%p
|
.row
|
||||||
This user does not want to get asked by strangers. Why don't you
|
.col-xs-12.text-center
|
||||||
= succeed "?" do
|
%strong Your question has been sent.
|
||||||
%a{:href => "{{ url_for('register') }}"} sign up
|
.row
|
||||||
|
.col-sm-1
|
||||||
|
.col-sm-5
|
||||||
|
%button#create-account.btn.btn-block.btn-primary Create an account
|
||||||
|
.col-sm-5
|
||||||
|
%button#new-question.btn.btn-block.btn-default Ask another question
|
||||||
|
.col-sm-1
|
||||||
|
.row
|
||||||
|
.col-sm-1
|
||||||
|
.col-xs-12.col-sm-10
|
||||||
|
%small
|
||||||
|
Join
|
||||||
|
= APP_CONFIG['site_name']
|
||||||
|
today! You'll be able to follow and ask people you know and a lot more.
|
||||||
|
.col-sm-1
|
||||||
|
- else
|
||||||
|
%p
|
||||||
|
This user does not want to get asked by strangers. Why don't you
|
||||||
|
= succeed "?" do
|
||||||
|
%a{:href => "{{ url_for('register') }}"} sign up
|
|
@ -12,6 +12,10 @@
|
||||||
.profile--panel-badge.panel-badge-warning
|
.profile--panel-badge.panel-badge-warning
|
||||||
%i.fa.fa-star
|
%i.fa.fa-star
|
||||||
Supporter
|
Supporter
|
||||||
|
- if @user.banned?
|
||||||
|
.profile--panel-badge.panel-badge-default
|
||||||
|
%i.fa.fa-ban
|
||||||
|
Banned
|
||||||
- if @user.following? current_user
|
- if @user.following? current_user
|
||||||
.profile--panel-badge.panel-badge-default
|
.profile--panel-badge.panel-badge-default
|
||||||
Follows you
|
Follows you
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
class AddBannedToUsers < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :users, :banned, :boolean, default: false
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue