Replace manual activerecord translations with helpers

This commit is contained in:
Sebastian Serth
2024-04-14 14:00:51 +02:00
committed by Sebastian Serth
parent e551c8a699
commit f8330b39fb
72 changed files with 265 additions and 264 deletions

View File

@@ -2,7 +2,7 @@
form#tip-selection
.mb-3
span.badge = t('activerecord.attributes.exercise_tip.tip')
span.badge = ExerciseTip.human_attribute_name('tip')
.mb-2
= collection_select({}, :tip_ids, tips, :id, :to_s, {}, {id: 'add-tip-list', class: 'form-control', multiple: true})

View File

@@ -23,7 +23,7 @@
=<> t('shared.out_of')
span.number
| 0
= row(label: 'activerecord.attributes.submission.score') do
= row(label: 'submission.score') do
span.number
| 0
=<> t('shared.out_of')
@@ -43,7 +43,7 @@
=<> t('shared.out_of')
span.number
| 0
= row(label: 'activerecord.attributes.submission.score') do
= row(label: 'submission.score') do
span.number
| 0
=<> t('shared.out_of')
@@ -53,7 +53,7 @@
= row(label: 'exercises.implement.messages')
#score data-maximum-score=@exercise.maximum_score data-score=@exercise.final_submission(current_contributor).try(:score)
h4
span == "#{t('activerecord.attributes.submission.score')}:&nbsp;"
span == "#{Submission.human_attribute_name('score')}:&nbsp;"
span.score
.progress
.progress-bar role='progressbar'

View File

@@ -41,25 +41,25 @@
.form-check
label.form-check-label
= f.check_box(:public, class: 'form-check-input')
= t('activerecord.attributes.exercise.public')
= f.label(:public, class: 'form-label mb-0')
.form-check
label.form-check-label
= f.check_box(:unpublished, class: 'form-check-input')
= t('activerecord.attributes.exercise.unpublished')
= f.label(:unpublished, class: 'form-label mb-0')
.form-check
label.form-check-label
= f.check_box(:hide_file_tree, class: 'form-check-input')
= t('activerecord.attributes.exercise.hide_file_tree')
= f.label(:hide_file_tree, class: 'form-label mb-0')
.form-check
label.form-check-label
= f.check_box(:allow_file_creation, class: 'form-check-input')
= t('activerecord.attributes.exercise.allow_file_creation')
= f.label(:allow_file_creation, class: 'form-label mb-0')
.form-check.mb-3
label.form-check-label
= f.check_box(:allow_auto_completion, class: 'form-check-input')
= t('activerecord.attributes.exercise.allow_auto_completion')
= f.label(:allow_auto_completion, class: 'form-label mb-0')
.mb-3
= f.label(t('activerecord.attributes.exercise.difficulty'), class: 'form-label')
= f.label(:expected_difficulty, class: 'form-label')
= f.number_field :expected_difficulty, in: 1..10, step: 1, class: 'form-control'
h2 = t('exercises.form.tags')
@@ -74,9 +74,9 @@
table.table#tags-table
thead
tr
th = t('activerecord.attributes.exercise.selection')
th = t('activerecord.attributes.tag.name')
th = t('activerecord.attributes.tag.difficulty')
th = Exercise.human_attribute_name('selection')
th = Tag.human_attribute_name('name')
th = Tag.human_attribute_name('difficulty')
= collection_check_boxes :exercise, :tag_ids, @exercise_tags, :tag_id, :id do |b|
tr
td = b.check_box class: 'form-check-input'
@@ -96,7 +96,7 @@
= render(partial: 'tips/sortable_tip', collection: @tips, as: :exercise_tip)
button.btn.btn-outline-primary.my-2.w-100 type='button' data-bs-toggle='modal' data-bs-target='#add-tips-modal' = t('.add_tips')
h2 = t('activerecord.attributes.exercise.files')
h2 = Exercise.human_attribute_name('files')
ul#files.list-unstyled
= f.fields_for :files do |files_form|
= render('file_form', f: files_form)

View File

@@ -8,5 +8,5 @@ p = ''
.d-grid.gap-2
button#askForCommentsButton.btn.btn-primary(type='button' data-cause='requestComments' data-message-success=t('exercises.editor.request_for_comments_sent'))
i.fa-solid.fa-circle-notch.fa-spin.d-none
= t('exercises.implement.comment.request')
button#closeAskForCommentsButton.btn.btn-warning(type='button') = t('activerecord.attributes.request_for_comments.close')
=t('exercises.implement.comment.request')
button#closeAskForCommentsButton.btn.btn-warning(type='button') = RequestForComment.human_attribute_name('close')

View File

@@ -1,13 +1,13 @@
h1 = link_to_if(policy(@exercise).show?, @exercise, exercise_path(@exercise))
.feedback-page
.header = t('activerecord.attributes.exercise.description')
.header = Exercise.human_attribute_name('description')
.value = render_markdown(@exercise.description)
span.header.col-sm-3.ps-0 = "#{t('activerecord.attributes.exercise.maximum_score')}:"
span.header.col-sm-3.ps-0 = "#{Exercise.human_attribute_name('maximum_score')}:"
span.col-sm-9 =< @exercise.maximum_score
.header.mt-3 = t('activerecord.models.user_exercise_feedback.other')
.header.mt-3 = UserExerciseFeedback.model_name.human(count: :other)
- if @feedbacks.blank?
.no-feedback = t('user_exercise_feedback.no_feedback')

View File

@@ -1,28 +1,28 @@
h1 = Exercise.model_name.human(count: 2)
h1 = Exercise.model_name.human(count: :other)
= render(layout: 'shared/form_filters') do |f|
.col-auto
= f.label(:execution_environment_id_eq, t('activerecord.attributes.exercise.execution_environment'), class: 'visually-hidden form-label')
= f.collection_select(:execution_environment_id_eq, @execution_environments.with_exercises, :id, :name, class: 'form-control', prompt: t('activerecord.attributes.exercise.execution_environment'))
= f.label(:execution_environment_id_eq, Exercise.human_attribute_name('execution_environment'), class: 'visually-hidden form-label')
= f.collection_select(:execution_environment_id_eq, @execution_environments.with_exercises, :id, :name, class: 'form-control', prompt: Exercise.human_attribute_name('execution_environment'))
.col-auto
= f.label(:title_or_internal_title_cont, t('activerecord.attributes.exercise.title'), class: 'visually-hidden form-label')
= f.search_field(:title_or_internal_title_cont, class: 'form-control', placeholder: t('activerecord.attributes.exercise.title'))
= f.label(:title_or_internal_title_cont, Exercise.human_attribute_name('title'), class: 'visually-hidden form-label')
= f.search_field(:title_or_internal_title_cont, class: 'form-control', placeholder: Exercise.human_attribute_name('title'))
.table-responsive
table.table.mt-2
thead
tr
th.p-1 = sort_link(@search, :title, t('activerecord.attributes.exercise.title'))
th.p-1 = sort_link(@search, :execution_environment_id, t('activerecord.attributes.exercise.execution_environment'))
th.p-1 = sort_link(@search, :title, Exercise.human_attribute_name('title'))
th.p-1 = sort_link(@search, :execution_environment_id, Exercise.human_attribute_name('execution_environment'))
th.p-1 = t('.test_files')
th.p-1 = t('activerecord.attributes.exercise.maximum_score')
th.p-1 = t('activerecord.attributes.exercise.tags')
th.p-1 = t('activerecord.attributes.exercise.difficulty')
th.p-1 = Exercise.human_attribute_name('maximum_score')
th.p-1 = Exercise.human_attribute_name('tags')
th.p-1 = Exercise.human_attribute_name('expected_difficulty')
th.p-1
= t('activerecord.attributes.exercise.public')
= Exercise.human_attribute_name('public')
- if policy(Exercise).batch_update?
br
span.batch = link_to(t('shared.batch_update'), '#', 'data-text': t('shared.update', model: t('activerecord.models.exercise.other')))
span.batch = link_to(t('shared.batch_update'), '#', 'data-text': t('shared.update', model: Exercise.model_name.human(count: :other)))
th.p-1 colspan=6 = t('shared.actions')
tbody
- @exercises.each do |exercise|
@@ -48,9 +48,9 @@ h1 = Exercise.model_name.human(count: 2)
button.btn.btn-outline-primary.btn-sm.dropdown-toggle data-bs-toggle='dropdown' type='button' = t('shared.actions_button')
ul.dropdown-menu.float-end role='menu'
li = link_to(t('shared.show'), exercise, 'data-turbolinks': 'false', class: 'dropdown-item') if policy(exercise).show?
li = link_to(t('activerecord.models.user_exercise_feedback.other'), feedback_exercise_path(exercise), class: 'dropdown-item') if policy(exercise).feedback?
li = link_to(t('activerecord.models.request_for_comment.other'), exercise_request_for_comments_path(exercise), class: 'dropdown-item') if policy(exercise).rfcs_for_exercise?
li = link_to(t('activerecord.models.programming_group.other'), exercise_programming_groups_path(exercise), class: 'dropdown-item') if policy(exercise).programming_groups_for_exercise?
li = link_to(UserExerciseFeedback.model_name.human(count: :other), feedback_exercise_path(exercise), class: 'dropdown-item') if policy(exercise).feedback?
li = link_to(RequestForComment.model_name.human(count: :other), exercise_request_for_comments_path(exercise), class: 'dropdown-item') if policy(exercise).rfcs_for_exercise?
li = link_to(ProgrammingGroup.model_name.human(count: :other), exercise_programming_groups_path(exercise), class: 'dropdown-item') if policy(exercise).programming_groups_for_exercise?
li = link_to(t('shared.destroy'), exercise, data: {confirm: t('shared.confirm_destroy')}, method: :delete, class: 'dropdown-item') if policy(exercise).destroy?
li = link_to(t('.clone'), clone_exercise_path(exercise), data: {confirm: t('shared.confirm_destroy')}, method: :post, class: 'dropdown-item') if policy(exercise).clone?
li = link_to(t('exercises.export_codeharbor.label'), '', class: 'dropdown-item export-start', data: {'exercise-id': exercise.id}) if policy(exercise).export_external_confirm?

View File

@@ -17,9 +17,9 @@ h1.d-inline-block
ul.dropdown-menu.dropdown-menu-end role='menu'
li = link_to(t('exercises.index.implement'), implement_exercise_path(@exercise), 'data-turbolinks': 'false', class: 'dropdown-item') if policy(@exercise).implement?
li = link_to(t('shared.statistics'), statistics_exercise_path(@exercise), 'data-turbolinks': 'false', class: 'dropdown-item') if policy(@exercise).statistics?
li = link_to(t('activerecord.models.user_exercise_feedback.other'), feedback_exercise_path(@exercise), class: 'dropdown-item') if policy(@exercise).feedback?
li = link_to(t('activerecord.models.request_for_comment.other'), exercise_request_for_comments_path(@exercise), class: 'dropdown-item') if policy(@exercise).rfcs_for_exercise?
li = link_to(t('activerecord.models.programming_group.other'), exercise_programming_groups_path(@exercise), class: 'dropdown-item') if policy(@exercise).programming_groups_for_exercise?
li = link_to(UserExerciseFeedback.model_name.human(count: :other), feedback_exercise_path(@exercise), class: 'dropdown-item') if policy(@exercise).feedback?
li = link_to(RequestForComment.model_name.human(count: :other), exercise_request_for_comments_path(@exercise), class: 'dropdown-item') if policy(@exercise).rfcs_for_exercise?
li = link_to(ProgrammingGroup.model_name.human(count: :other), exercise_programming_groups_path(@exercise), class: 'dropdown-item') if policy(@exercise).programming_groups_for_exercise?
li = link_to(t('shared.destroy'), @exercise, data: {confirm: t('shared.confirm_destroy')}, method: :delete, class: 'dropdown-item') if policy(@exercise).destroy?
li = link_to(t('exercises.index.clone'), clone_exercise_path(@exercise), data: {confirm: t('shared.confirm_destroy')}, method: :post, class: 'dropdown-item') if policy(@exercise).clone?
li = link_to(t('exercises.export_codeharbor.label'), '', class: 'dropdown-item export-start', data: {'exercise-id': @exercise.id}) if policy(@exercise).export_external_confirm?
@@ -38,7 +38,7 @@ h1.d-inline-block
= row(label: 'exercise.hide_file_tree', value: @exercise.hide_file_tree?)
= row(label: 'exercise.allow_file_creation', value: @exercise.allow_file_creation?)
= row(label: 'exercise.allow_auto_completion', value: @exercise.allow_auto_completion?)
= row(label: 'exercise.difficulty', value: @exercise.expected_difficulty)
= row(label: 'exercise.expected_difficulty', value: @exercise.expected_difficulty)
= row(label: 'exercise.uuid', value: @exercise.uuid)
= row(label: 'exercise.tags', value: @exercise.exercise_tags.map {|et| "#{et.tag.name} (#{et.factor})" }.sort.join(', '))
= row(label: 'exercise.embedding_parameters', class: 'mb-4') do
@@ -48,7 +48,7 @@ h1.d-inline-block
.mt-2
= render(partial: 'tips_content')
h2.mt-4 = t('activerecord.attributes.exercise.files')
h2.mt-4 = Exercise.human_attribute_name('files')
ul.list-unstyled#files
- @exercise.files.each do |file|

View File

@@ -30,8 +30,8 @@ h4.mt-4
i.me-0.fa-regular.fa-lightbulb aria-hidden='true' title = t('request_for_comments.solved')
th.text-center
i.me-0.fa-solid.fa-comment aria-hidden='true' title = t('request_for_comments.comments') align='center'
th.col-12 = t('activerecord.attributes.request_for_comments.question')
th = t('activerecord.attributes.request_for_comments.username')
th.text-nowrap = t('activerecord.attributes.request_for_comments.requested_at')
th.col-12 = RequestForComment.human_attribute_name('question')
th = RequestForComment.human_attribute_name('username')
th.text-nowrap = RequestForComment.human_attribute_name('requested_at')
tbody#posted_rfcs
= render(partial: 'request_for_comments/list_entry', collection: @request_for_comments, as: :request_for_comment)