Skip to content

Commit

Permalink
Only allow admins to change course editors (#610)
Browse files Browse the repository at this point in the history
* whitelist editor_ids as parameter only for admins

* add helpdesk informing about inability to change editors

* remove unnecessry hash brackets

* fix typos

* put hash in one line

* remove obsolete parameter

* add helpdesk to cSpell
  • Loading branch information
fosterfarrell9 authored Apr 9, 2024
1 parent 1e6d953 commit 518de4e
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 7 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
//////////////////////////////////////
"cSpell.words": [
"commontator",
"helpdesk",
"turbolinks"
]
}
13 changes: 6 additions & 7 deletions app/controllers/courses_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,12 @@ def set_course_admin
end

def course_params
params.require(:course).permit(:title, :short_title, :organizational,
:organizational_concept, :locale,
:term_independent, :image,
tag_ids: [],
preceding_course_ids: [],
editor_ids: [],
division_ids: [])
allowed_params = [:title, :short_title, :organizational,
:organizational_concept, :locale,
:term_independent, :image,
{ tag_ids: [], preceding_course_ids: [], division_ids: [] }]
allowed_params.push(editor_ids: []) if current_user.admin?
params.require(:course).permit(allowed_params)
end

def tag_params
Expand Down
3 changes: 3 additions & 0 deletions app/views/courses/_basics.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@
</div>
<% else %>
<%= t('basics.editors') %>
<%= helpdesk(t('admin.course.info.no_right_to_change_editors',
project_email: mail_to(DefaultSetting::PROJECT_EMAIL)),
true) %>
<ul>
<% course.editors.each do |e| %>
<li>
Expand Down
4 changes: 4 additions & 0 deletions config/locales/de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,10 @@ de:
das Modul bearbeiten, insbesondere können sie Veranstaltungen innerhalb
des Moduls anlegen. ModuleditorInnen erben die Bearbeitungsrechte für
alle Veranstaltungen innerhalb des Moduls.
no_right_to_change_editors: >
ModuleditorInnen können nur von AdministratorInnen geändert werden.
Bitte wende Dich per Email an %{project_email}, wenn hier
eine Änderung vorgenommen werden soll.
preceding_courses: >
Hier kannst Du angeben, auf welchen Modulen das
vorliegende Modul aufbaut.
Expand Down
4 changes: 4 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -772,6 +772,10 @@ en:
in particular they can create event series within the course. Every course
editor inherits editing access for all event series belonging to the
course.
no_right_to_change_editors: >
Course editors can only be changed by administrators.
Please contact %{project_email} by email if you want a change to be made
here.
preceding_courses: >
Here you can enter which courses this course builds upon.
E.g., Linear Algebra 1 and Linear Algebra 2 might be preceding
Expand Down

0 comments on commit 518de4e

Please sign in to comment.