You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.3 KiB
47 lines
1.3 KiB
module Api
|
|
module V1
|
|
class SettingsController < BaseController
|
|
def show
|
|
current_user.update_required_matrices!
|
|
render json: payload
|
|
end
|
|
def update
|
|
attributes = params.require(:settings).permit(
|
|
:email,
|
|
:total_required_hours,
|
|
:weekly_target_hours,
|
|
:praepedeutikum_done,
|
|
enabled_praktikums_typen: [],
|
|
required_hours_matrix: {},
|
|
weekly_target_matrix: {}
|
|
)
|
|
|
|
if current_user.update(attributes)
|
|
current_user.update_required_matrices!
|
|
render json: payload
|
|
else
|
|
render_validation(current_user)
|
|
end
|
|
end
|
|
private
|
|
def payload
|
|
current_user.as_json(
|
|
only: %i[
|
|
email
|
|
total_required_hours
|
|
weekly_target_hours
|
|
required_hours_matrix
|
|
weekly_target_matrix
|
|
praepedeutikum_done
|
|
]
|
|
).merge(
|
|
praktikums_typen: User::PRAKTIKUMSTYPEN,
|
|
enabled_praktikums_typen: current_user.enabled_praktikums_typen_list,
|
|
praktikums_typ_labels: User::PRAKTIKUMSTYP_LABELS,
|
|
entry_arten: User::ENTRY_ARTEN,
|
|
entry_arten_by_typ: User::ENTRY_ARTEN_BY_TYP
|
|
)
|
|
end
|
|
end
|
|
end
|
|
end
|