Class: I18nProofreading::SubmissionsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- I18nProofreading::SubmissionsController
- Defined in:
- app/controllers/i18n_proofreading/submissions_controller.rb
Overview
The widget's public API: the context lookup it reads and the suggestion it posts.
Public, so it stays on ApplicationController and never inherits a host's admin base controller — a proofreader must not be asked for a staff session. The triage actions live in SuggestionsController, which does inherit it.
Instance Method Summary collapse
-
#context ⇒ Object
Pending suggestions for one key/locale, shown as read-only context when the proofreader reopens the popover for a string someone already flagged.
- #create ⇒ Object
Instance Method Details
#context ⇒ Object
Pending suggestions for one key/locale, shown as read-only context when the proofreader reopens the popover for a string someone already flagged.
28 29 30 31 32 33 34 35 36 |
# File 'app/controllers/i18n_proofreading/submissions_controller.rb', line 28 def context suggestions = Suggestion .where(translation_key: params[:key], locale: params[:locale]) .status_pending .newest_first .limit(20) render json: suggestions.map { |suggestion| suggestion_json(suggestion) } end |
#create ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 |
# File 'app/controllers/i18n_proofreading/submissions_controller.rb', line 38 def create suggestion = Suggestion.new(suggestion_params) (suggestion) if suggestion.save I18nProofreading.config.on_submit.call(suggestion) head :created else render json: { errors: suggestion.errors. }, status: :unprocessable_entity end end |