From 8dc051ea46ba46c0e2798495f40bfa3e2bb83074 Mon Sep 17 00:00:00 2001 From: MrYummy Date: Tue, 20 Jun 2017 16:22:56 +0200 Subject: Added ban reason and expiration date to user pages --- app/controllers/users_controller.rb | 2 ++ app/views/users/show.html.erb | 9 +++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 5dc0e80..702d1e3 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -30,6 +30,8 @@ class UsersController < ApplicationController end def show + user = User.find(params[:id]) + @ban_json = JSON.parse(File.read("/etc/minecraft/redstoner/banned-players.json")).detect {|u| u["uuid"] == user.uuid} end # SIGNUP diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index e371a09..eb14575 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -15,11 +15,12 @@

<%= @user.name %>

- - <% if @user.banned? %> - This user is banned! + <% if @ban_json %> + This used is banned for "<%=@ban_json["reason"]%>"<%=" until #{@ban_json["expires"]}" unless @ban_json["expires"] == "forever"%> + <% elsif @user.banned? %> + This user is banned! <% end %> - +
<% if !@user.confirmed? %> <% if @user.is?(current_user) || mod? %> Please confirm your email <%= @user.email %> ! -- cgit v1.2.3 From 1ec464a4fce8db1e7f33706136639376f588632d Mon Sep 17 00:00:00 2001 From: MrYummy Date: Wed, 21 Jun 2017 01:19:02 +0200 Subject: utilized @user variable --- app/controllers/users_controller.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 702d1e3..e188d01 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -30,8 +30,7 @@ class UsersController < ApplicationController end def show - user = User.find(params[:id]) - @ban_json = JSON.parse(File.read("/etc/minecraft/redstoner/banned-players.json")).detect {|u| u["uuid"] == user.uuid} + @ban_json = JSON.parse(File.read("/etc/minecraft/redstoner/banned-players.json")).detect {|u| u["uuid"] == @user.uuid} end # SIGNUP -- cgit v1.2.3 From bd85a2c3ae8e7b58691c23439189d1d34d67fa7f Mon Sep 17 00:00:00 2001 From: MrYummy Date: Sun, 6 Aug 2017 13:32:21 +0200 Subject: fixed spelling error --- app/views/users/show.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index eb14575..3d9dcfe 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -16,7 +16,7 @@
<% if @ban_json %> - This used is banned for "<%=@ban_json["reason"]%>"<%=" until #{@ban_json["expires"]}" unless @ban_json["expires"] == "forever"%> + This user is banned for "<%=@ban_json["reason"]%>"<%=" until #{@ban_json["expires"]}" unless @ban_json["expires"] == "forever"%> <% elsif @user.banned? %> This user is banned! <% end %> -- cgit v1.2.3 From 2223f88d7bd94c98108e03307b5e52f26e8437ff Mon Sep 17 00:00:00 2001 From: MrYummy Date: Thu, 26 Oct 2017 22:21:00 +0200 Subject: minor edits --- app/controllers/users_controller.rb | 2 ++ app/views/users/show.html.erb | 7 ++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index e188d01..cc77c44 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -6,6 +6,8 @@ class UsersController < ApplicationController before_filter :set_user, except: [:index, :new, :create, :lost_password, :reset_password, :suggestions] + caches_action :show, expires_in: 10.seconds, layout: false + def index if params[:role] if params[:role].downcase == "staff" diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index 3d9dcfe..de784a2 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -16,9 +16,10 @@
<% if @ban_json %> - This user is banned for "<%=@ban_json["reason"]%>"<%=" until #{@ban_json["expires"]}" unless @ban_json["expires"] == "forever"%> - <% elsif @user.banned? %> - This user is banned! + This user is banned on the server for "<%=@ban_json["reason"]%>"<%=" until #{@ban_json["expires"]}" unless @ban_json["expires"] == "forever"%> + <% end %> + <% if @user.banned? %> + This user is banned on the website! <% end %>
<% if !@user.confirmed? %> -- cgit v1.2.3 From 3fb5924318dee8f023dbea5e31526a74ca1f35e8 Mon Sep 17 00:00:00 2001 From: MrYummy Date: Tue, 31 Oct 2017 15:44:18 -0400 Subject: trimmed UUIDs from banned-players.json --- app/controllers/users_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index cc77c44..d657053 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -32,7 +32,7 @@ class UsersController < ApplicationController end def show - @ban_json = JSON.parse(File.read("/etc/minecraft/redstoner/banned-players.json")).detect {|u| u["uuid"] == @user.uuid} + @ban_json = JSON.parse(File.read("/etc/minecraft/redstoner/banned-players.json")).detect {|u| u["uuid"].tr("-", "") == @user.uuid} end # SIGNUP -- cgit v1.2.3 From b9dcf0ac6355015b4d08a28049a7a8ddc361bb26 Mon Sep 17 00:00:00 2001 From: Logan Fick Date: Tue, 31 Oct 2017 21:59:01 -0400 Subject: Fixed user profile page returning internal server error if JSON file is missing. --- app/controllers/users_controller.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index d657053..a6a625d 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -32,7 +32,11 @@ class UsersController < ApplicationController end def show - @ban_json = JSON.parse(File.read("/etc/minecraft/redstoner/banned-players.json")).detect {|u| u["uuid"].tr("-", "") == @user.uuid} + begin + @ban_json = JSON.parse(File.read("/etc/minecraft/redstoner/banned-players.json")).detect {|u| u["uuid"].tr("-", "") == @user.uuid} + rescue + flash.now[:alert] = "An error occured while checking if this user is banned from the server!" + @ban_json = nil end # SIGNUP -- cgit v1.2.3 From 7ed1c2ac57038127ba95f5ef940a3ea7f7e042f7 Mon Sep 17 00:00:00 2001 From: Logan Fick Date: Tue, 31 Oct 2017 22:03:15 -0400 Subject: Fixed syntax error. --- app/controllers/users_controller.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index a6a625d..e7a13d6 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -37,6 +37,7 @@ class UsersController < ApplicationController rescue flash.now[:alert] = "An error occured while checking if this user is banned from the server!" @ban_json = nil + end end # SIGNUP -- cgit v1.2.3