Compare commits
2 commits
d9bf4f745b
...
ab238ab2a6
| Author | SHA1 | Date | |
|---|---|---|---|
| ab238ab2a6 | |||
| 0d2648d030 |
6 changed files with 41 additions and 14 deletions
|
|
@ -4,7 +4,7 @@ require 'async/container'
|
||||||
class ApplicationController < ActionController::Base
|
class ApplicationController < ActionController::Base
|
||||||
protect_from_forgery
|
protect_from_forgery
|
||||||
|
|
||||||
helper_method :current_user, :user_signed_in?
|
helper_method :current_user, :support_staff?, :user_signed_in?
|
||||||
|
|
||||||
before_action :set_locale
|
before_action :set_locale
|
||||||
|
|
||||||
|
|
@ -111,10 +111,12 @@ class ApplicationController < ActionController::Base
|
||||||
return_to || root_path
|
return_to || root_path
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def support_staff?
|
||||||
|
current_user&.support_staff?
|
||||||
|
end
|
||||||
|
|
||||||
def support_staff_only
|
def support_staff_only
|
||||||
unless current_user&.support_staff?
|
raise AccessDenied, "Support staff only" unless support_staff?
|
||||||
raise AccessDenied, "Support staff only"
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,10 +35,7 @@ class PetStatesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def next_unlabeled_appearance_path
|
def next_unlabeled_appearance_path
|
||||||
# Rather than just getting the newest unlabeled pet state, prioritize the
|
unlabeled_appearance = PetState.next_unlabeled_appearance
|
||||||
# newest *pet type*. This better matches the user's perception of what the
|
|
||||||
# newest state is, because the Rainbow Pool UI is grouped by pet type!
|
|
||||||
unlabeled_appearance = PetState.needs_labeling.newest_pet_type.newest.first
|
|
||||||
|
|
||||||
if unlabeled_appearance
|
if unlabeled_appearance
|
||||||
edit_pet_type_pet_state_path(
|
edit_pet_type_pet_state_path(
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,16 @@ class PetTypesController < ApplicationController
|
||||||
if @selected_species && @selected_color && @pet_types.size == 1
|
if @selected_species && @selected_color && @pet_types.size == 1
|
||||||
redirect_to @pet_types.first
|
redirect_to @pet_types.first
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if support_staff?
|
||||||
|
@counts = {
|
||||||
|
total: PetState.count,
|
||||||
|
glitched: PetState.glitched.count,
|
||||||
|
needs_labeling: PetState.needs_labeling.count,
|
||||||
|
usable: PetState.usable.count,
|
||||||
|
}
|
||||||
|
@unlabeled_appearance = PetState.next_unlabeled_appearance
|
||||||
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
format.json {
|
format.json {
|
||||||
|
|
|
||||||
|
|
@ -127,10 +127,6 @@ module ApplicationHelper
|
||||||
!@hide_home_link
|
!@hide_home_link
|
||||||
end
|
end
|
||||||
|
|
||||||
def support_staff?
|
|
||||||
user_signed_in? && current_user.support_staff?
|
|
||||||
end
|
|
||||||
|
|
||||||
def impress_2020_meta_tags
|
def impress_2020_meta_tags
|
||||||
origin = Rails.configuration.impress_2020_origin
|
origin = Rails.configuration.impress_2020_origin
|
||||||
support_secret = Rails.application.credentials.dig(
|
support_secret = Rails.application.credentials.dig(
|
||||||
|
|
|
||||||
|
|
@ -17,10 +17,13 @@ class PetState < ApplicationRecord
|
||||||
|
|
||||||
alias_method :swf_asset_ids_from_association, :swf_asset_ids
|
alias_method :swf_asset_ids_from_association, :swf_asset_ids
|
||||||
|
|
||||||
|
scope :glitched, -> { where(glitched: true) }
|
||||||
|
scope :needs_labeling, -> { unlabeled.where(glitched: false) }
|
||||||
|
scope :unlabeled, -> { with_pose("UNKNOWN") }
|
||||||
|
scope :usable, -> { where(labeled: true, glitched: false) }
|
||||||
|
|
||||||
scope :newest, -> { order(created_at: :desc) }
|
scope :newest, -> { order(created_at: :desc) }
|
||||||
scope :newest_pet_type, -> { joins(:pet_type).merge(PetType.newest) }
|
scope :newest_pet_type, -> { joins(:pet_type).merge(PetType.newest) }
|
||||||
scope :unlabeled, -> { with_pose("UNKNOWN") }
|
|
||||||
scope :needs_labeling, -> { unlabeled.where(glitched: false) }
|
|
||||||
|
|
||||||
# A simple ordering that tries to bring reliable pet states to the front.
|
# A simple ordering that tries to bring reliable pet states to the front.
|
||||||
scope :emotion_order, -> {
|
scope :emotion_order, -> {
|
||||||
|
|
@ -138,5 +141,12 @@ class PetState < ApplicationRecord
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.next_unlabeled_appearance
|
||||||
|
# Rather than just getting the newest unlabeled pet state, prioritize the
|
||||||
|
# newest *pet type*. This better matches the user's perception of what the
|
||||||
|
# newest state is, because the Rainbow Pool UI is grouped by pet type!
|
||||||
|
needs_labeling.newest_pet_type.newest.first
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,18 @@
|
||||||
|
|
||||||
[1]: #{alt_styles_path}
|
[1]: #{alt_styles_path}
|
||||||
|
|
||||||
|
- if support_staff?
|
||||||
|
%p
|
||||||
|
%strong 💡 Support summary:
|
||||||
|
✅ #{number_with_delimiter @counts[:usable]} usable
|
||||||
|
+ 👾 #{number_with_delimiter @counts[:glitched]} glitched
|
||||||
|
- if @unlabeled_appearance
|
||||||
|
+ ❓️
|
||||||
|
= link_to "#{number_with_delimiter @counts[:needs_labeling]} unknown",
|
||||||
|
edit_pet_type_pet_state_path(@unlabeled_appearance.pet_type,
|
||||||
|
@unlabeled_appearance, next: "unlabeled-appearance")
|
||||||
|
\= #{number_with_delimiter @counts[:total]} total
|
||||||
|
|
||||||
= form_with method: :get, class: "rainbow-pool-filters" do |form|
|
= form_with method: :get, class: "rainbow-pool-filters" do |form|
|
||||||
%fieldset
|
%fieldset
|
||||||
%legend Filter by:
|
%legend Filter by:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue