Class: Admin::EmailTemplatesController
- Inherits:
-
AdminController
- Object
- AdminController
- Admin::EmailTemplatesController
- Defined in:
- app/controllers/admin/email_templates_controller.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.email_keys ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'app/controllers/admin/email_templates_controller.rb', line 4 def self.email_keys @email_keys ||= %w[ custom_invite_forum_mailer custom_invite_mailer invite_forum_mailer invite_mailer invite_password_instructions new_version_mailer new_version_mailer_with_notes system_messages.backup_failed system_messages.backup_succeeded system_messages.bulk_invite_failed system_messages.bulk_invite_succeeded system_messages.csv_export_failed system_messages.csv_export_succeeded system_messages.download_remote_images_disabled system_messages.email_error_notification system_messages.email_reject_auto_generated system_messages.email_reject_bad_destination_address system_messages.email_reject_empty system_messages.email_reject_invalid_access system_messages.email_reject_parsing system_messages.email_reject_reply_key system_messages.email_reject_screened_email system_messages.email_reject_topic_closed system_messages.email_reject_topic_not_found system_messages.email_reject_unrecognized_error system_messages.email_reject_user_not_found system_messages.email_revoked system_messages.pending_users_reminder system_messages.post_hidden system_messages.post_hidden_again system_messages.queued_posts_reminder system_messages.restore_failed system_messages.restore_succeeded system_messages.silenced_by_staff system_messages.spam_post_blocked system_messages.too_many_spam_flags system_messages.unsilenced system_messages.user_automatically_silenced system_messages.welcome_invite system_messages.welcome_user system_messages.welcome_staff test_mailer user_notifications.account_created user_notifications.admin_login user_notifications.confirm_new_email user_notifications.email_login user_notifications.forgot_password user_notifications.notify_old_email user_notifications.set_password user_notifications.signup user_notifications.signup_after_approval user_notifications.suspicious_login user_notifications.user_invited_to_private_message_pm user_notifications.user_invited_to_private_message_pm_group user_notifications.user_invited_to_topic user_notifications.user_linked user_notifications.user_mentioned user_notifications.user_posted user_notifications.user_posted_pm user_notifications.user_quoted user_notifications.user_replied ] end |
Instance Method Details
#index ⇒ Object
124 125 126 127 128 129 130 131 132 |
# File 'app/controllers/admin/email_templates_controller.rb', line 124 def index render_serialized( self.class.email_keys, AdminEmailTemplateSerializer, root: "email_templates", rest_serializer: true, overridden_keys: overridden_keys, ) end |
#revert ⇒ Object
111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'app/controllers/admin/email_templates_controller.rb', line 111 def revert key = params[:id] raise Discourse::NotFound unless self.class.email_keys.include?(params[:id]) revert_and_log("#{key}.subject_template", "#{key}.text_body_template") render_serialized( key, AdminEmailTemplateSerializer, root: "email_template", rest_serializer: true, ) end |
#show ⇒ Object
70 71 |
# File 'app/controllers/admin/email_templates_controller.rb', line 70 def show end |
#update ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'app/controllers/admin/email_templates_controller.rb', line 73 def update et = params[:email_template] key = params[:id] raise Discourse::NotFound unless self.class.email_keys.include?(params[:id]) subject_result = update_key("#{key}.subject_template", et[:subject]) body_result = update_key("#{key}.text_body_template", et[:body]) = [] if subject_result[:error_messages].present? << (subject_result, "subject") end if body_result[:error_messages].present? << (body_result, "body") end if .blank? log_site_text_change(subject_result) log_site_text_change(body_result) render_serialized( key, AdminEmailTemplateSerializer, root: "email_template", rest_serializer: true, ) else TranslationOverride.upsert!( I18n.locale, "#{key}.subject_template", subject_result[:old_value], ) TranslationOverride.upsert!(I18n.locale, "#{key}.text_body_template", body_result[:old_value]) render_json_error() end end |