implemented basic functionality of YE OLDE BANHAMMER!
This commit is contained in:
parent
3574993746
commit
1bb369aa7d
24
Rakefile
24
Rakefile
|
@ -72,7 +72,7 @@ namespace :justask do
|
|||
user.save!
|
||||
puts "#{user.screen_name} no longer an admin."
|
||||
end
|
||||
|
||||
|
||||
desc "Gives moderator status to an user."
|
||||
task :mod, [:screen_name] => :environment do |t, args|
|
||||
fail "screen name required" if args[:screen_name].nil?
|
||||
|
@ -90,7 +90,27 @@ namespace :justask do
|
|||
fail "user #{args[:screen_name]} not found" if user.nil?
|
||||
user.moderator = false
|
||||
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
|
||||
|
||||
desc "Gives supporter status to an user."
|
||||
|
|
|
@ -120,4 +120,8 @@
|
|||
|
||||
.panel-badge-warning {
|
||||
background-color: #FF9800;
|
||||
}
|
||||
|
||||
.user--banned {
|
||||
text-decoration: line-through !important;
|
||||
}
|
|
@ -4,6 +4,18 @@ class ApplicationController < ActionController::Base
|
|||
protect_from_forgery with: :exception
|
||||
|
||||
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
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ module UserHelper
|
|||
def user_screen_name(user, anonymous=false, url=true)
|
||||
return APP_CONFIG['anonymous_name'] if user.nil? || anonymous
|
||||
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
|
||||
end
|
||||
end
|
||||
|
|
|
@ -6,47 +6,52 @@
|
|||
- else
|
||||
= @user.motivation_header
|
||||
.panel-body
|
||||
- if user_signed_in? or @user.privacy_allow_anonymous_questions?
|
||||
#question-box
|
||||
.row
|
||||
.col-xs-12
|
||||
%textarea.form-control{:name => "qb-question", :placeholder => "Type your question here…"}
|
||||
.row{:style => "padding-top: 5px; padding-left: 5px; padding-right: 5px;"}
|
||||
.col-xs-6
|
||||
- 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;"}
|
||||
- if @user.banned?
|
||||
.row
|
||||
.col-xs-12.text-center
|
||||
%strong This user got hit with ye olde banhammer.
|
||||
- else
|
||||
- if user_signed_in? or @user.privacy_allow_anonymous_questions?
|
||||
#question-box
|
||||
.row
|
||||
.col-xs-12.text-center
|
||||
%strong Your question has been sent.
|
||||
.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
|
||||
.col-xs-12
|
||||
%textarea.form-control{:name => "qb-question", :placeholder => "Type your question here…"}
|
||||
.row{:style => "padding-top: 5px; padding-left: 5px; padding-right: 5px;"}
|
||||
.col-xs-6
|
||||
- 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
|
||||
.col-xs-12.text-center
|
||||
%strong Your question has been sent.
|
||||
.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
|
||||
%i.fa.fa-star
|
||||
Supporter
|
||||
- if @user.banned?
|
||||
.profile--panel-badge.panel-badge-default
|
||||
%i.fa.fa-ban
|
||||
Banned
|
||||
- if @user.following? current_user
|
||||
.profile--panel-badge.panel-badge-default
|
||||
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