mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 07:52:19 +08:00
d1bdb6c65d
* FEATURE: upload an avatar option for uploading avatars with selectable avatars Allow staff or users at or above a trust level to upload avatars even when the site has selectable avatars enabled. Everyone can still pick from the list of avatars. The option to upload is shown below the selectable avatar list. refactored boolean site setting into an enum with the following values: disabled: No selectable avatars enabled (default) everyone: Show selectable avatars, and allow everyone to upload custom avatars tl1: Show selectable avatars, but require tl1+ and staff to upload custom avatars tl2: Show selectable avatars, but require tl2+ and staff to upload custom avatars tl3: Show selectable avatars, but require tl3+ and staff to upload custom avatars tl4: Show selectable avatars, but require tl4 and staff to upload custom avatars staff: Show selectable avatars, but only allow staff to upload custom avatars no_one: Show selectable avatars. No users can upload custom avatars Co-authored-by: Régis Hanol <regis@hanol.fr>
32 lines
925 B
Ruby
32 lines
925 B
Ruby
# frozen_string_literal: true
|
|
|
|
class MigrateSelectableAvatarsEnabled < ActiveRecord::Migration[6.1]
|
|
def up
|
|
execute <<~SQL
|
|
UPDATE site_settings AS s
|
|
SET value =
|
|
CASE WHEN t.value = 't' THEN 'no_one'
|
|
ELSE 'disabled'
|
|
END,
|
|
data_type = #{SiteSettings::TypeSupervisor.types[:enum]},
|
|
name = 'selectable_avatars_mode'
|
|
FROM site_settings t
|
|
WHERE s.id = t.id AND s.name = 'selectable_avatars_enabled'
|
|
SQL
|
|
end
|
|
|
|
def down
|
|
execute <<~SQL
|
|
UPDATE site_settings AS s
|
|
SET value =
|
|
CASE WHEN t.value IN ('everyone', 'no_one', 'staff', 'tl1','tl2', 'tl3', 'tl4') THEN 't'
|
|
ELSE 'f'
|
|
END,
|
|
data_type = #{SiteSettings::TypeSupervisor.types[:bool]},
|
|
name = 'selectable_avatars_enabled'
|
|
FROM site_settings t
|
|
WHERE s.id = t.id AND s.name = 'selectable_avatars_mode'
|
|
SQL
|
|
end
|
|
end
|