Provide current-contributor application-wide
* This change allows us to reuse the current user in multiple places.
This commit is contained in:

committed by
Sebastian Serth

parent
c29256aa81
commit
883169121c
@ -36,8 +36,9 @@ $(document).on('turbolinks:load', function() {
|
||||
window.location.reload();
|
||||
});
|
||||
|
||||
// Set current user
|
||||
// Set current user and current contributor
|
||||
window.current_user = JSON.parse($('meta[name="current-user"]')?.attr('content') || null);
|
||||
window.current_contributor = JSON.parse($('meta[name="current-contributor"]')?.attr('content') || null);
|
||||
|
||||
// Set locale for all JavaScript functions
|
||||
const htmlTag = $('html')
|
||||
|
@ -55,6 +55,15 @@ class ProgrammingGroup < ApplicationRecord
|
||||
"Programming Group #{id}"
|
||||
end
|
||||
|
||||
def to_page_context
|
||||
{
|
||||
id:,
|
||||
type: self.class.name,
|
||||
consumer: '',
|
||||
displayname:,
|
||||
}
|
||||
end
|
||||
|
||||
def programming_partner_ids
|
||||
users.map(&:id_with_type)
|
||||
end
|
||||
|
@ -4,7 +4,7 @@
|
||||
- show_tips_interventions = @show_tips_interventions || "false"
|
||||
- hide_rfc_button = @hide_rfc_button || false
|
||||
|
||||
#editor.row data-exercise-id=@exercise.id data-message-depleted=t('exercises.editor.depleted') data-message-timeout=t('exercises.editor.timeout', permitted_execution_time: @exercise.execution_environment.permitted_execution_time) data-message-out-of-memory=t('exercises.editor.out_of_memory', memory_limit: @exercise.execution_environment.memory_limit) data-submissions-url=submissions_path data-contributor-id=current_contributor.id data-user-external-id=external_user_external_id data-working-times-url=working_times_exercise_path(@exercise) data-intervention-save-url=intervention_exercise_path(@exercise) data-rfc-interventions=show_rfc_interventions data-break-interventions=show_break_interventions data-tips-interventions=show_tips_interventions
|
||||
#editor.row data-exercise-id=@exercise.id data-message-depleted=t('exercises.editor.depleted') data-message-timeout=t('exercises.editor.timeout', permitted_execution_time: @exercise.execution_environment.permitted_execution_time) data-message-out-of-memory=t('exercises.editor.out_of_memory', memory_limit: @exercise.execution_environment.memory_limit) data-submissions-url=submissions_path data-user-external-id=external_user_external_id data-working-times-url=working_times_exercise_path(@exercise) data-intervention-save-url=intervention_exercise_path(@exercise) data-rfc-interventions=show_rfc_interventions data-break-interventions=show_break_interventions data-tips-interventions=show_tips_interventions
|
||||
- unless @embed_options[:hide_sidebar]
|
||||
- additional_classes = 'sidebar-col'
|
||||
- if @tips.blank?
|
||||
|
@ -17,6 +17,7 @@ html lang="#{I18n.locale || I18n.default_locale}" data-default-locale="#{I18n.de
|
||||
= csrf_meta_tags
|
||||
meta name='sentry' data-enabled=SentryJavascript.active?.to_s data-release=SentryJavascript.release data-dsn=SentryJavascript.dsn data-environment=SentryJavascript.environment
|
||||
meta name='current-user' content=current_user&.to_page_context&.to_json
|
||||
meta name='current-contributor' content=current_contributor&.to_page_context&.to_json
|
||||
body
|
||||
- unless @embed_options[:hide_navbar]
|
||||
nav.navbar.bg-dark.navbar-expand-md.mb-4.py-1 role='navigation' data-bs-theme="dark"
|
||||
|
Reference in New Issue
Block a user