From 3366251172b164cf45215793f3d82bcec3e538ea Mon Sep 17 00:00:00 2001 From: Etienne Ischer Date: Wed, 5 May 2021 20:20:06 +0200 Subject: [PATCH] add global reputations page --- app/assets/stylesheets/wow_reputations.scss | 3 +++ app/controllers/wow_reputations_controller.rb | 9 ++++++++ app/helpers/wow_reputations_helper.rb | 2 ++ app/models/wow_reputation.rb | 3 ++- app/views/layouts/_navbar.html.erb | 9 +++++--- app/views/wow_reputations/_standing.html.erb | 5 +++++ app/views/wow_reputations/index.html.erb | 22 +++++++++++++++++++ config/locales/layouts/de-de.yml | 1 + config/locales/layouts/en-gb.yml | 1 + config/locales/layouts/en-us.yml | 1 + config/locales/layouts/es-es.yml | 1 + config/locales/layouts/es-mx.yml | 1 + config/locales/layouts/fr-fr.yml | 3 ++- config/locales/layouts/it.yml | 3 ++- config/locales/layouts/ko.yml | 1 + config/locales/layouts/pt-br.yml | 1 + config/locales/layouts/ru-ru.yml | 1 + config/locales/layouts/zh-cn.yml | 1 + config/locales/layouts/zh-tw.yml | 1 + config/locales/wow_reputations/de-de.yml | 7 ++++++ config/locales/wow_reputations/en-gb.yml | 7 ++++++ config/locales/wow_reputations/en-us.yml | 7 ++++++ config/locales/wow_reputations/es-es.yml | 7 ++++++ config/locales/wow_reputations/es-mx.yml | 7 ++++++ config/locales/wow_reputations/fr-fr.yml | 7 ++++++ config/locales/wow_reputations/it.yml | 7 ++++++ config/locales/wow_reputations/ko.yml | 7 ++++++ config/locales/wow_reputations/pt-br.yml | 7 ++++++ config/locales/wow_reputations/ru-ru.yml | 7 ++++++ config/locales/wow_reputations/zh-cn.yml | 7 ++++++ config/locales/wow_reputations/zh-tw.yml | 7 ++++++ config/routes.rb | 1 + spec/helpers/wow_reputations_helper_spec.rb | 15 +++++++++++++ spec/requests/wow_reputations_spec.rb | 7 ++++++ 34 files changed, 170 insertions(+), 6 deletions(-) create mode 100644 app/assets/stylesheets/wow_reputations.scss create mode 100644 app/controllers/wow_reputations_controller.rb create mode 100644 app/helpers/wow_reputations_helper.rb create mode 100644 app/views/wow_reputations/_standing.html.erb create mode 100644 app/views/wow_reputations/index.html.erb create mode 100644 config/locales/wow_reputations/de-de.yml create mode 100644 config/locales/wow_reputations/en-gb.yml create mode 100644 config/locales/wow_reputations/en-us.yml create mode 100644 config/locales/wow_reputations/es-es.yml create mode 100644 config/locales/wow_reputations/es-mx.yml create mode 100644 config/locales/wow_reputations/fr-fr.yml create mode 100644 config/locales/wow_reputations/it.yml create mode 100644 config/locales/wow_reputations/ko.yml create mode 100644 config/locales/wow_reputations/pt-br.yml create mode 100644 config/locales/wow_reputations/ru-ru.yml create mode 100644 config/locales/wow_reputations/zh-cn.yml create mode 100644 config/locales/wow_reputations/zh-tw.yml create mode 100644 spec/helpers/wow_reputations_helper_spec.rb create mode 100644 spec/requests/wow_reputations_spec.rb diff --git a/app/assets/stylesheets/wow_reputations.scss b/app/assets/stylesheets/wow_reputations.scss new file mode 100644 index 0000000..e8f8968 --- /dev/null +++ b/app/assets/stylesheets/wow_reputations.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the WowReputation controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: https://sass-lang.com/ diff --git a/app/controllers/wow_reputations_controller.rb b/app/controllers/wow_reputations_controller.rb new file mode 100644 index 0000000..ef2e11e --- /dev/null +++ b/app/controllers/wow_reputations_controller.rb @@ -0,0 +1,9 @@ +class WowReputationsController < ProtectedController + def index + @pagy, @wow_reputations = pagy(WowReputation.non_meta_reputations, items: 20) + end + + def show + @wow_reputation = WowReputation.find(params[:id]) + end +end diff --git a/app/helpers/wow_reputations_helper.rb b/app/helpers/wow_reputations_helper.rb new file mode 100644 index 0000000..3e532b6 --- /dev/null +++ b/app/helpers/wow_reputations_helper.rb @@ -0,0 +1,2 @@ +module WowReputationsHelper +end diff --git a/app/models/wow_reputation.rb b/app/models/wow_reputation.rb index 16ee3d6..e561e8a 100644 --- a/app/models/wow_reputation.rb +++ b/app/models/wow_reputation.rb @@ -11,5 +11,6 @@ class WowReputation < ApplicationRecord validates :name, presence: true validates :reputation_id, presence: true, uniqueness: true - scope :meta_reputations, -> { where(meta_wow_reputation: nil) } + scope :meta_reputations, -> { where(description: nil) } + scope :non_meta_reputations, -> { where.not(description: nil) } end diff --git a/app/views/layouts/_navbar.html.erb b/app/views/layouts/_navbar.html.erb index 35740f8..a13854b 100644 --- a/app/views/layouts/_navbar.html.erb +++ b/app/views/layouts/_navbar.html.erb @@ -5,13 +5,16 @@ <% if user_signed_in? %>