mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Associate category logo and background to uploads record.
This commit is contained in:
@@ -15,6 +15,8 @@ class Category < ActiveRecord::Base
|
||||
|
||||
belongs_to :user
|
||||
belongs_to :latest_post, class_name: "Post"
|
||||
belongs_to :uploaded_logo, class_name: "Upload"
|
||||
belongs_to :uploaded_background, class_name: "Upload"
|
||||
|
||||
has_many :topics
|
||||
has_many :category_users
|
||||
@@ -38,9 +40,6 @@ class Category < ActiveRecord::Base
|
||||
|
||||
validate :email_in_validator
|
||||
|
||||
validates :logo_url, upload_url: true, if: :logo_url_changed?
|
||||
validates :background_url, upload_url: true, if: :background_url_changed?
|
||||
|
||||
validate :ensure_slug
|
||||
before_save :apply_permissions
|
||||
before_save :downcase_email
|
||||
|
||||
@@ -49,7 +49,13 @@ class CategoryList
|
||||
end
|
||||
|
||||
def find_categories
|
||||
@categories = Category.includes(:topic_only_relative_url, subcategories: [:topic_only_relative_url]).secured(@guardian)
|
||||
@categories = Category.includes(
|
||||
:uploaded_background,
|
||||
:uploaded_logo,
|
||||
:topic_only_relative_url,
|
||||
subcategories: [:topic_only_relative_url]
|
||||
).secured(@guardian)
|
||||
|
||||
@categories = @categories.where(suppress_from_homepage: false) if @options[:is_homepage]
|
||||
@categories = @categories.where("categories.parent_category_id = ?", @options[:parent_category_id].to_i) if @options[:parent_category_id].present?
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ class Site
|
||||
def categories
|
||||
@categories ||= begin
|
||||
categories = Category
|
||||
.includes(:uploaded_logo, :uploaded_background)
|
||||
.secured(@guardian)
|
||||
.joins('LEFT JOIN topics t on t.id = categories.topic_id')
|
||||
.select('categories.*, t.slug topic_slug')
|
||||
|
||||
Reference in New Issue
Block a user