Add renumber lectures button
This commit is contained in:
parent
0a6a68b519
commit
c97041597b
@ -1,5 +1,11 @@
|
|||||||
module Admin
|
module Admin
|
||||||
class CoursesController < Admin::ApplicationController
|
class CoursesController < Admin::ApplicationController
|
||||||
|
def renumber_lectures
|
||||||
|
course = Course.find(params[:id])
|
||||||
|
course.renumber_lectures!
|
||||||
|
redirect_to admin_course_url(course), notice: "Lectures renumbered!"
|
||||||
|
end
|
||||||
|
|
||||||
# Overwrite any of the RESTful controller actions to implement custom behavior
|
# Overwrite any of the RESTful controller actions to implement custom behavior
|
||||||
# For example, you may want to send an email after a foo is updated.
|
# For example, you may want to send an email after a foo is updated.
|
||||||
#
|
#
|
||||||
|
|||||||
@ -67,6 +67,6 @@ as well as a link to its edit page.
|
|||||||
<% actions_template = "admin/#{page.resource.class.name.downcase}/actions" %>
|
<% actions_template = "admin/#{page.resource.class.name.downcase}/actions" %>
|
||||||
|
|
||||||
<% if lookup_context.template_exists?(actions_template, [], true) %>
|
<% if lookup_context.template_exists?(actions_template, [], true) %>
|
||||||
<%= render actions_template %>
|
<%= render actions_template, { page: } %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
5
app/views/admin/course/_actions.html.erb
Normal file
5
app/views/admin/course/_actions.html.erb
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<%= link_to(
|
||||||
|
"Renumber lectures",
|
||||||
|
[namespace, page.resource, :renumber_lectures],
|
||||||
|
class: "button",
|
||||||
|
) if accessible_action?(page.resource, :renumber_lectures) %>
|
||||||
@ -7,6 +7,8 @@ Rails.application.routes.draw do
|
|||||||
resources :recordings
|
resources :recordings
|
||||||
|
|
||||||
root to: "courses#index"
|
root to: "courses#index"
|
||||||
|
|
||||||
|
get '/courses/:id/renumber_lectures', to: 'courses#renumber_lectures', as: :course_renumber_lectures
|
||||||
end
|
end
|
||||||
|
|
||||||
root controller: :attendance_tracker, action: :index
|
root controller: :attendance_tracker, action: :index
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user