mirror of
https://github.com/discourse/discourse.git
synced 2024-11-24 04:31:56 +08:00
a23d0f9961
Currently the process of adding a custom image to badge is quite clunky; you have to upload your image to a topic, and then copy the image URL and pasting it in a text field. Besides being clucky, if the topic or post that contains the image is deleted, the image will be garbage-collected in a few days and the badge will lose the image because the application is not that the image is referenced by a badge. This commit improves that by adding a proper image uploader widget for badge images.
30 lines
586 B
Ruby
30 lines
586 B
Ruby
# frozen_string_literal: true
|
|
|
|
class BadgeSerializer < ApplicationSerializer
|
|
attributes :id, :name, :description, :grant_count, :allow_title,
|
|
:multiple_grant, :icon, :image_url, :listable, :enabled, :badge_grouping_id,
|
|
:system, :long_description, :slug, :has_badge, :manually_grantable?
|
|
|
|
has_one :badge_type
|
|
|
|
def include_has_badge?
|
|
object.has_badge
|
|
end
|
|
|
|
def has_badge
|
|
true
|
|
end
|
|
|
|
def system
|
|
object.system?
|
|
end
|
|
|
|
def include_long_description?
|
|
options[:include_long_description]
|
|
end
|
|
|
|
def name
|
|
object.display_name
|
|
end
|
|
end
|