# Path: disaster_recovery/jobs/workflows/create.py
# class ActionsConfigurationAction(workflows.Action):
#     class Meta(object):
# class ActionsConfiguration(workflows.Step):
# class ClientsConfigurationAction(workflows.MembershipAction):
#     class Meta:
# class ClientsConfiguration(workflows.UpdateMembersStep):
# class InfoConfigurationAction(workflows.Action):
#     class Meta(object):
# class InfoConfiguration(workflows.Step):
# class ConfigureJob(workflows.Workflow):
#     def __init__(self, request, *args, **kwargs):
#     def contribute(self, data, context):
#     def __init__(self, request, context, *args, **kwargs):
#     def clean(self):
#     def _validate_iso_format(self, start_date):
#     def populate_interval_uint_choices(self, request, context):
#     def _check_start_datetime(self, cleaned_data):
#     def _check_end_datetime(self, cleaned_data):
#     def handle(self, request, context):
# 
# Path: disaster_recovery/jobs/workflows/update_job.py
# class InfoConfigurationAction(workflows.Action):
#     class Meta(object):
# class InfoConfiguration(workflows.Step):
# class UpdateJob(workflows.Workflow):
#     def __init__(self, request, context, *args, **kwargs):
#     def clean(self):
#     def _validate_iso_format(self, start_date):
#     def _check_start_datetime(self, cleaned_data):
#     def _check_end_datetime(self, cleaned_data):
#     def handle(self, request, context):
# 
# Path: disaster_recovery/jobs/workflows/update_actions.py
# class ActionsConfigurationAction(workflows.Action):
#     class Meta(object):
# class ActionsConfiguration(workflows.Step):
# class UpdateActions(workflows.Workflow):
#     def handle(self, request, context):
# 
# Path: disaster_recovery/utils.py
# def shield(message, redirect=''):
#     """decorator to reduce boilerplate try except blocks for horizon functions
#     :param message: a str error message
#     :param redirect: a str with the redirect namespace without including
#                      horizon:disaster_recovery:
#                      eg. @shield('error', redirect='jobs:index')
#     """
#     def wrap(function):
# 
#         @wraps(function)
#         def wrapped_function(view, *args, **kwargs):
# 
#             try:
#                 return function(view, *args, **kwargs)
#             except Exception as error:
#                 LOG.error(error.message)
#                 namespace = "horizon:disaster_recovery:"
#                 r = reverse("{0}{1}".format(namespace, redirect))
# 
#                 if view.request.path == r:
#                     # To avoid an endless loop, we must not redirect to the
#                     # same page on which the error happened
#                     user_home = get_user_home(view.request.user)
#                     exceptions.handle(view.request, _(error.message),
#                                       redirect=user_home)
#                 else:
#                     exceptions.handle(view.request, _(error.message),
#                                       redirect=r)
# 
#         return wrapped_function
#     return wrap


from horizon import browsers
from horizon import workflows
from disaster_recovery.jobs.workflows import create as configure_workflow
from disaster_recovery.jobs.workflows import update_job as update_job_workflow
from disaster_recovery.jobs.workflows import update_actions as update_workflow
from disaster_recovery.utils import shield
import disaster_recovery.api.api as freezer_api
import disaster_recovery.jobs.browsers as project_browsers
            initial.update(**job)
            initial.update(**job['job_schedule'])

        return initial


class EditJobWorkflowView(workflows.WorkflowView):
    workflow_class = update_job_workflow.UpdateJob

    @shield("Unable to get job", redirect="jobs:index")
    def get_object(self):
        return freezer_api.Job(self.request).get(self.kwargs['job_id'])

    def is_update(self):
        return 'job_id' in self.kwargs and bool(self.kwargs['job_id'])

    @shield("Unable to get job", redirect="jobs:index")
    def get_initial(self):
        initial = super(EditJobWorkflowView, self).get_initial()
        if self.is_update():
            initial.update({'job_id': None})
            job = freezer_api.Job(self.request).get(self.kwargs['job_id'],
                                                    json=True)
            initial.update(**job)
            initial.update(**job['job_schedule'])

        return initial


class ActionsInJobView(workflows.WorkflowView):

# Path: disaster_recovery/jobs/workflows/create.py
# class ActionsConfigurationAction(workflows.Action):
#     class Meta(object):
# class ActionsConfiguration(workflows.Step):
# class ClientsConfigurationAction(workflows.MembershipAction):
#     class Meta:
# class ClientsConfiguration(workflows.UpdateMembersStep):
# class InfoConfigurationAction(workflows.Action):
#     class Meta(object):
# class InfoConfiguration(workflows.Step):
# class ConfigureJob(workflows.Workflow):
#     def __init__(self, request, *args, **kwargs):
#     def contribute(self, data, context):
#     def __init__(self, request, context, *args, **kwargs):
#     def clean(self):
#     def _validate_iso_format(self, start_date):
#     def populate_interval_uint_choices(self, request, context):
#     def _check_start_datetime(self, cleaned_data):
#     def _check_end_datetime(self, cleaned_data):
#     def handle(self, request, context):
# 
# Path: disaster_recovery/jobs/workflows/update_job.py
# class InfoConfigurationAction(workflows.Action):
#     class Meta(object):
# class InfoConfiguration(workflows.Step):
# class UpdateJob(workflows.Workflow):
#     def __init__(self, request, context, *args, **kwargs):
#     def clean(self):
#     def _validate_iso_format(self, start_date):
#     def _check_start_datetime(self, cleaned_data):
#     def _check_end_datetime(self, cleaned_data):
#     def handle(self, request, context):
# 
# Path: disaster_recovery/jobs/workflows/update_actions.py
# class ActionsConfigurationAction(workflows.Action):
#     class Meta(object):
# class ActionsConfiguration(workflows.Step):
# class UpdateActions(workflows.Workflow):
#     def handle(self, request, context):
# 
# Path: disaster_recovery/utils.py
# def shield(message, redirect=''):
#     """decorator to reduce boilerplate try except blocks for horizon functions
#     :param message: a str error message
#     :param redirect: a str with the redirect namespace without including
#                      horizon:disaster_recovery:
#                      eg. @shield('error', redirect='jobs:index')
#     """
#     def wrap(function):
# 
#         @wraps(function)
#         def wrapped_function(view, *args, **kwargs):
# 
#             try:
#                 return function(view, *args, **kwargs)
#             except Exception as error:
#                 LOG.error(error.message)
#                 namespace = "horizon:disaster_recovery:"
#                 r = reverse("{0}{1}".format(namespace, redirect))
# 
#                 if view.request.path == r:
#                     # To avoid an endless loop, we must not redirect to the
#                     # same page on which the error happened
#                     user_home = get_user_home(view.request.user)
#                     exceptions.handle(view.request, _(error.message),
#                                       redirect=user_home)
#                 else:
#                     exceptions.handle(view.request, _(error.message),
#                                       redirect=r)
# 
#         return wrapped_function
#     return wrap


# Path: disaster_recovery/jobs/views.py
from horizon import browsers
from horizon import workflows
from disaster_recovery.jobs.workflows import create as configure_workflow
from disaster_recovery.jobs.workflows import update_job as update_job_workflow
from disaster_recovery.jobs.workflows import update_actions as update_workflow
from disaster_recovery.utils import shield
import disaster_recovery.api.api as freezer_api
import disaster_recovery.jobs.browsers as project_browsers

            initial.update(**job)
            initial.update(**job['job_schedule'])

        return initial


class EditJobWorkflowView(workflows.WorkflowView):
    workflow_class = update_job_workflow.UpdateJob

    @shield("Unable to get job", redirect="jobs:index")
    def get_object(self):
        return freezer_api.Job(self.request).get(self.kwargs['job_id'])

    def is_update(self):
        return 'job_id' in self.kwargs and bool(self.kwargs['job_id'])

    @shield("Unable to get job", redirect="jobs:index")
    def get_initial(self):
        initial = super(EditJobWorkflowView, self).get_initial()
        if self.is_update():
            initial.update({'job_id': None})
            job = freezer_api.Job(self.request).get(self.kwargs['job_id'],
                                                    json=True)
            initial.update(**job)
            initial.update(**job['job_schedule'])

        return initial


class ActionsInJobView(workflows.WorkflowView):

    workflow_class = update_workflow.UpdateActions