mirror of
https://github.com/Retrospring/retrospring.git
synced 2025-01-18 20:15:59 +01:00
Streamline strings for profile picture settings controller
This commit is contained in:
parent
11476d3ccc
commit
8ba2df1b80
2 changed files with 23 additions and 8 deletions
|
@ -7,14 +7,26 @@ class Settings::ProfilePictureController < ApplicationController
|
|||
user_attributes = params.require(:user).permit(:show_foreign_themes, :profile_picture_x, :profile_picture_y, :profile_picture_w, :profile_picture_h,
|
||||
:profile_header_x, :profile_header_y, :profile_header_w, :profile_header_h, :profile_picture, :profile_header)
|
||||
if current_user.update(user_attributes)
|
||||
text = t(".success")
|
||||
text += t(".notice.profile_picture") if user_attributes[:profile_picture]
|
||||
text += t(".notice.profile_header") if user_attributes[:profile_header]
|
||||
flash[:success] = text
|
||||
flash[:success] = success_flash_message(user_attributes)
|
||||
else
|
||||
flash[:error] = t(".error")
|
||||
end
|
||||
|
||||
redirect_to settings_profile_path
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def success_flash_message(user_attributes)
|
||||
if user_attributes[:profile_picture] && user_attributes[:profile_header]
|
||||
t(".update.success.both")
|
||||
elsif user_attributes[:profile_picture]
|
||||
t(".update.success.profile_picture")
|
||||
elsif user_attributes[:profile_header]
|
||||
t(".update.success.profile_header")
|
||||
else
|
||||
state = user_attributes[:show_foreign_themes] ? "enabled" : "disabled"
|
||||
t(".update.success.foreign_themes.#{state}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -177,11 +177,14 @@ en:
|
|||
error: "Unable to update profile."
|
||||
profile_picture:
|
||||
update:
|
||||
success: :settings.profile.update.success
|
||||
success:
|
||||
profile_picture: "Profile picture updated successfully. It might take a few minutes until your new profile picture is shown everywhere."
|
||||
profile_header: "Profile header updated successfully. It might take a few minutes until your new profile header is shown everywhere."
|
||||
both: "Profile picture and header updated successfully. It might take a few minutes until they are shown everywhere."
|
||||
foreign_themes:
|
||||
enabled: "You will now see other user's themes when viewing their profiles."
|
||||
disabled: "You will no longer see other user's themes."
|
||||
error: :settings.profile.update.error
|
||||
notice:
|
||||
profile_picture: " It might take a few minutes until your new profile picture is shown everywhere."
|
||||
profile_header: " It might take a few minutes until your new profile header is shown everywhere."
|
||||
theme:
|
||||
update:
|
||||
success: "Theme saved successfully."
|
||||
|
|
Loading…
Reference in a new issue