DateTime.now -> DateTime.current

This commit is contained in:
Yuki 2015-04-23 06:48:17 +05:30
parent 1184410275
commit 5764c36b32
3 changed files with 7 additions and 7 deletions

View File

@ -109,7 +109,7 @@ namespace :justask do
fail "screen name required" if args[:screen_name].nil? fail "screen name required" if args[:screen_name].nil?
user = User.find_by_screen_name(args[:screen_name]) user = User.find_by_screen_name(args[:screen_name])
user.permanently_banned = false user.permanently_banned = false
user.banned_until = DateTime.now + 1 user.banned_until = DateTime.current + 1
user.ban_reason = args[:reason] user.ban_reason = args[:reason]
user.save! user.save!
puts "#{user.screen_name} got hit by\033[5m YE OLDE BANHAMMER\033[0m!!1!" puts "#{user.screen_name} got hit by\033[5m YE OLDE BANHAMMER\033[0m!!1!"
@ -120,7 +120,7 @@ namespace :justask do
fail "screen name required" if args[:screen_name].nil? fail "screen name required" if args[:screen_name].nil?
user = User.find_by_screen_name(args[:screen_name]) user = User.find_by_screen_name(args[:screen_name])
user.permanently_banned = false user.permanently_banned = false
user.banned_until = DateTime.now + 7 user.banned_until = DateTime.current + 7
user.ban_reason = args[:reason] user.ban_reason = args[:reason]
user.save! user.save!
puts "#{user.screen_name} got hit by\033[5m YE OLDE BANHAMMER\033[0m!!1!" puts "#{user.screen_name} got hit by\033[5m YE OLDE BANHAMMER\033[0m!!1!"
@ -131,7 +131,7 @@ namespace :justask do
fail "screen name required" if args[:screen_name].nil? fail "screen name required" if args[:screen_name].nil?
user = User.find_by_screen_name(args[:screen_name]) user = User.find_by_screen_name(args[:screen_name])
user.permanently_banned = false user.permanently_banned = false
user.banned_until = DateTime.now + 30 user.banned_until = DateTime.current + 30
user.ban_reason = args[:reason] user.ban_reason = args[:reason]
user.save! user.save!
puts "#{user.screen_name} got hit by\033[5m YE OLDE BANHAMMER\033[0m!!1!" puts "#{user.screen_name} got hit by\033[5m YE OLDE BANHAMMER\033[0m!!1!"
@ -142,7 +142,7 @@ namespace :justask do
fail "screen name required" if args[:screen_name].nil? fail "screen name required" if args[:screen_name].nil?
user = User.find_by_screen_name(args[:screen_name]) user = User.find_by_screen_name(args[:screen_name])
user.permanently_banned = false user.permanently_banned = false
user.banned_until = DateTime.now + 365 user.banned_until = DateTime.current + 365
user.ban_reason = args[:reason] user.ban_reason = args[:reason]
user.save! user.save!
puts "#{user.screen_name} got hit by\033[5m YE OLDE BANHAMMER\033[0m!!1!" puts "#{user.screen_name} got hit by\033[5m YE OLDE BANHAMMER\033[0m!!1!"
@ -153,7 +153,7 @@ namespace :justask do
fail "screen name required" if args[:screen_name].nil? fail "screen name required" if args[:screen_name].nil?
user = User.find_by_screen_name(args[:screen_name]) user = User.find_by_screen_name(args[:screen_name])
user.permanently_banned = false user.permanently_banned = false
user.banned_until = DateTime.now + 365_000_000_000 user.banned_until = DateTime.current + 365_000_000_000
user.ban_reason = args[:reason] user.ban_reason = args[:reason]
user.save! user.save!
puts "#{user.screen_name} got hit by\033[5m YE OLDE BANHAMMER\033[0m!!1!" puts "#{user.screen_name} got hit by\033[5m YE OLDE BANHAMMER\033[0m!!1!"

View File

@ -199,7 +199,7 @@ class User < ActiveRecord::Base
# forwards fill # forwards fill
def banned? def banned?
self.permanently_banned? or ((not self.banned_until.nil?) and self.banned_until > DateTime.now) self.permanently_banned? or ((not self.banned_until.nil?) and self.banned_until >= DateTime.current)
end end
def unban def unban

View File

@ -14,7 +14,7 @@
#ban-controls{style: "#{"display: none" unless @user.banned?}"} #ban-controls{style: "#{"display: none" unless @user.banned?}"}
= f.check_box :permaban, label: "Permanently?", checked: @user.permanently_banned? = f.check_box :permaban, label: "Permanently?", checked: @user.permanently_banned?
#ban-controls-time{style: "#{"display: none" unless not @user.permanently_banned?}"} #ban-controls-time{style: "#{"display: none" unless not @user.permanently_banned?}"}
= f.datetime_local_field :until, label: "", required: true, value: (@user.banned_until || DateTime.now).strftime("%Y-%m-%dT%H:%M") = f.datetime_local_field :until, label: "", required: true, value: (@user.banned_until || DateTime.current).strftime("%Y-%m-%dT%H:%M")
= f.text_field :reason, placeholder: "Reason", value: @user.ban_reason = f.text_field :reason, placeholder: "Reason", value: @user.ban_reason
.modal-footer .modal-footer
%button.btn.btn-default{name: 'stop-time', type: :button, data: { dismiss: :modal }} Close %button.btn.btn-default{name: 'stop-time', type: :button, data: { dismiss: :modal }} Close