extract controller base class

This commit is contained in:
Jens Kraemer
2021-10-05 04:33:47 +08:00
parent 317aa08365
commit d32845cc6e
2 changed files with 13 additions and 3 deletions

View File

@@ -0,0 +1,12 @@
# base class for stopwatch controllers
class StopwatchController < ApplicationController
helper :timelog, :custom_fields
before_action :require_login
private
def authorize_edit_time
@time_entry.editable_by?(User.current) or deny_access
end
end

View File

@@ -8,10 +8,8 @@
# - same for project, unless we are in a project context # - same for project, unless we are in a project context
# - focus first field that needs an action, depending on above # - focus first field that needs an action, depending on above
# #
class StopwatchTimersController < ApplicationController class StopwatchTimersController < StopwatchController
helper :timelog, :custom_fields
before_action :require_login
before_action :find_optional_data, only: %i(new create) before_action :find_optional_data, only: %i(new create)
before_action :authorize_log_time, only: %i(new create start stop current) before_action :authorize_log_time, only: %i(new create start stop current)
before_action :find_time_entry, only: %i(edit update start stop) before_action :find_time_entry, only: %i(edit update start stop)