Compare commits
3 commits
8502b780c2
...
7f62417294
| Author | SHA1 | Date | |
|---|---|---|---|
| 7f62417294 | |||
| fe6d42ef67 | |||
| b8772c3aad |
4 changed files with 28 additions and 16 deletions
|
|
@ -2,20 +2,15 @@ class AltStylesController < ApplicationController
|
|||
before_action :support_staff_only, except: [:index]
|
||||
|
||||
def index
|
||||
@all_alt_styles = AltStyle.includes(:species, :color)
|
||||
|
||||
@all_colors = @all_alt_styles.map(&:color).uniq.sort_by(&:name)
|
||||
@all_species = @all_alt_styles.map(&:species).uniq.sort_by(&:name)
|
||||
|
||||
@all_series_names = @all_alt_styles.map(&:series_name).uniq.sort
|
||||
@all_color_names = @all_colors.map(&:human_name)
|
||||
@all_species_names = @all_species.map(&:human_name)
|
||||
@all_series_names = AltStyle.all_series_names
|
||||
@all_color_names = AltStyle.all_supported_colors.map(&:human_name).sort
|
||||
@all_species_names = AltStyle.all_supported_species.map(&:human_name).sort
|
||||
|
||||
@series_name = params[:series]
|
||||
@color = find_color
|
||||
@species = find_species
|
||||
|
||||
@alt_styles = @all_alt_styles.includes(:swf_assets)
|
||||
@alt_styles = AltStyle.includes(:color, :species, :swf_assets)
|
||||
@alt_styles.where!(series_name: @series_name) if @series_name.present?
|
||||
@alt_styles.merge!(@color.alt_styles) if @color
|
||||
@alt_styles.merge!(@species.alt_styles) if @species
|
||||
|
|
|
|||
|
|
@ -20,7 +20,11 @@ class AltStyle < ApplicationRecord
|
|||
where(series_name:, color_id: color.id, species_id: species.id)
|
||||
}
|
||||
scope :by_creation_date, -> {
|
||||
order("DATE(created_at) DESC")
|
||||
# HACK: Setting up named time zones in MySQL takes effort, so we assume
|
||||
# it's not Daylight Savings. This will produce slightly incorrect
|
||||
# sorting when it *is* Daylight Savings, and records happen to be
|
||||
# created around midnight.
|
||||
order(Arel.sql("DATE(CONVERT_TZ(created_at, '+00:00', '-08:00')) DESC"))
|
||||
}
|
||||
scope :unlabeled, -> { where(series_name: nil) }
|
||||
scope :newest, -> { order(created_at: :desc) }
|
||||
|
|
@ -101,6 +105,18 @@ class AltStyle < ApplicationRecord
|
|||
"<New?>"
|
||||
end
|
||||
|
||||
def self.all_series_names
|
||||
distinct.where.not(series_name: nil).pluck(:series_name).sort
|
||||
end
|
||||
|
||||
def self.all_supported_colors
|
||||
Color.find(distinct.pluck(:color_id))
|
||||
end
|
||||
|
||||
def self.all_supported_species
|
||||
Species.find(distinct.pluck(:species_id))
|
||||
end
|
||||
|
||||
# For convenience in the console!
|
||||
def self.find_by_name(color_name, species_name)
|
||||
color = Color.find_by_name(color_name)
|
||||
|
|
|
|||
|
|
@ -34,11 +34,12 @@
|
|||
selected: @species&.human_name, include_blank: "Species…"
|
||||
= f.submit "Go", name: nil
|
||||
|
||||
= will_paginate @alt_styles, class: "rainbow-pool-pagination"
|
||||
|
||||
%ul.rainbow-pool-list= render @alt_styles
|
||||
|
||||
= will_paginate @alt_styles, class: "rainbow-pool-pagination"
|
||||
- if @alt_styles.present?
|
||||
= will_paginate @alt_styles, class: "rainbow-pool-pagination"
|
||||
%ul.rainbow-pool-list= render @alt_styles
|
||||
= will_paginate @alt_styles, class: "rainbow-pool-pagination"
|
||||
- else
|
||||
%p.rainbow-pool-no-results We don't have any styles matching that search.
|
||||
|
||||
- content_for :stylesheets do
|
||||
= stylesheet_link_tag "application/breadcrumbs"
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@
|
|||
%ui.rainbow-pool-list= render @pet_types
|
||||
= will_paginate @pet_types, class: "rainbow-pool-pagination"
|
||||
- else
|
||||
%p.rainbow-pool-no-results No matching pets found!
|
||||
%p.rainbow-pool-no-results We don't have any pets matching that search.
|
||||
|
||||
- content_for :stylesheets do
|
||||
= stylesheet_link_tag "application/rainbow-pool"
|
||||
|
|
|
|||
Loading…
Reference in a new issue