DEV: Do not include method definitions in serializer `attributes`

These accidental inclusions are mostly no-ops (because the method name is also included as an explicit symbol). The mistakes were made more obvious because syntax_tree adjusted the indentation of these methods
This commit is contained in:
David Taylor 2023-01-09 13:59:43 +00:00
parent 5a003715d3
commit f05da14fb6
No known key found for this signature in database
GPG Key ID: 46904C18B1D3F434
5 changed files with 29 additions and 27 deletions

View File

@ -17,10 +17,11 @@ class CurrentUserOptionSerializer < ApplicationSerializer
:seen_popups, :seen_popups,
:should_be_redirected_to_top, :should_be_redirected_to_top,
:redirected_to_top, :redirected_to_top,
:treat_as_new_topic_start_date, :treat_as_new_topic_start_date
def likes_notifications_disabled
object.likes_notifications_disabled? def likes_notifications_disabled
end object.likes_notifications_disabled?
end
def include_redirected_to_top? def include_redirected_to_top?
object.redirected_to_top.present? object.redirected_to_top.present?

View File

@ -10,10 +10,11 @@ class TopicLinkSerializer < ApplicationSerializer
:clicks, :clicks,
:user_id, :user_id,
:domain, :domain,
:root_domain, :root_domain
def attachment
Discourse.store.has_been_uploaded?(object.url) def attachment
end Discourse.store.has_been_uploaded?(object.url)
end
def include_user_id? def include_user_id?
object.user_id.present? object.user_id.present?

View File

@ -9,10 +9,11 @@ class TopicPostCountSerializer < BasicUserSerializer
:flair_bg_color, :flair_bg_color,
:admin, :admin,
:moderator, :moderator,
:trust_level, :trust_level
def id
object[:user].id def id
end object[:user].id
end
def username def username
object[:user].username object[:user].username

View File

@ -36,11 +36,11 @@ class UserOptionSerializer < ApplicationSerializer
:skip_new_user_tips, :skip_new_user_tips,
:default_calendar, :default_calendar,
:oldest_search_log_date, :oldest_search_log_date,
:seen_popups, :seen_popups
def auto_track_topics_after_msecs
object.auto_track_topics_after_msecs || def auto_track_topics_after_msecs
SiteSetting.default_other_auto_track_topics_after_msecs object.auto_track_topics_after_msecs || SiteSetting.default_other_auto_track_topics_after_msecs
end end
def notification_level_when_replying def notification_level_when_replying
object.notification_level_when_replying || object.notification_level_when_replying ||

View File

@ -67,16 +67,15 @@ class UserSerializer < UserCardSerializer
:sidebar_list_destination, :sidebar_list_destination,
:display_sidebar_tags :display_sidebar_tags
untrusted_attributes :bio_raw, untrusted_attributes :bio_raw, :bio_cooked, :profile_background_upload_url
:bio_cooked,
:profile_background_upload_url, ###
### ### ATTRIBUTES
### ATTRIBUTES ###
### #
# def user_notification_schedule
def user_notification_schedule object.user_notification_schedule || UserNotificationSchedule::DEFAULT
object.user_notification_schedule || UserNotificationSchedule::DEFAULT end
end
def mailing_list_posts_per_day def mailing_list_posts_per_day
val = Post.estimate_posts_per_day val = Post.estimate_posts_per_day