Exemple #1
0
        def check_for_create():
            """Check for create/initiate operation"""
            module = get_request_params('app_name', request, **kwargs)
            flow = flow_config(module).FLOW
            initial = flow_config(module).INITIAL
            identifier = get_request_params('pk', request, **kwargs)

            activity = initial if identifier == REQUEST_IDENTIFIER \
                else Task.objects.get(id=identifier).activity_ref

            return flow[activity]['role'] not in [
                group.name for group in groups
            ]
Exemple #2
0
        def check_for_create():
            """Check for create/initiate operation"""
            module = get_request_params('app_name', request, **kwargs)
            flow = flow_config(module).FLOW
            initial = flow_config(module).INITIAL
            identifier = get_request_params(
                'pk', request, **kwargs)

            activity = initial if identifier == REQUEST_IDENTIFIER \
                else Task.objects.get(id=identifier).flow_ref_key

            return flow[activity]['role'] not in [
                group.name for group in groups]
Exemple #3
0
    def next_activity(self):
        """Compute the next possible activities"""
        transitions = flow_config(self.module_label).FLOW[
            self.task.flow_ref_key]['transitions']

        if transitions:
            return [transition for transition in
                    transitions if transitions[transition](self)]
        else:
            return None
Exemple #4
0
    def get_context_data(self, **kwargs):
        """Retrieve context data<"""
        context = super(WorkflowDetail, self).get_context_data(**kwargs)
        app_title = get_request_params('app_name', **kwargs)
        config = flow_config(app_title)
        model = config.FLOW[config.INITIAL]['model']().title
        context['requests'] = get_workflows_requests(app_title)
        context['request_identifier'] = REQUEST_IDENTIFIER
        context['workflow_title'] = config.TITLE
        context['description'] = config.DESCRIPTION
        context['initial'] = model

        return context
Exemple #5
0
    def get_context_data(self, **kwargs):
        """Retrieve context data<"""
        context = super(WorkflowDetail, self).get_context_data(**kwargs)
        app_title = get_request_params('app_name', **kwargs)
        config = flow_config(app_title)
        model = config.FLOW[config.INITIAL]['model']().title
        context['requests'] = get_workflows_requests(app_title)
        context['request_identifier'] = REQUEST_IDENTIFIER
        context['workflow_title'] = config.TITLE
        context['description'] = config.DESCRIPTION
        context['initial'] = model

        return context
Exemple #6
0
    def initiate_request(self, user, module):
        """Initiates new workflow requests"""
        config = flow_config(self.module_label)
        role = Group.objects.get(name=config.FLOW[config.INITIAL]['role'])

        request = Request.objects.create(requester=user,
                                         module_ref=module,
                                         status='Initiated')

        task = Task.objects.create(request=request,
                                   assignee=role,
                                   updated_by=user,
                                   activity_ref=config.INITIAL,
                                   status='In Progress')

        self.task = task
        self.save()
Exemple #7
0
    def submit(self, module, user, next_activity=None):
        """Submits the task"""
        config = flow_config(module)
        transitions = transition_config(module, self.activity_ref)
        role = Group.objects.get(name=config.FLOW[next_activity]['role'])

        self.status = 'Completed'
        self.save()

        if transitions is not None:
            Task.objects.create(request=self.request,
                                assignee=role,
                                updated_by=user,
                                activity_ref=next_activity,
                                status='Not Started')
        else:
            self.request.status = 'Completed'
            self.request.save()
Exemple #8
0
    def initiate_request(self, user, module):
        """Initiates new workflow requests"""
        config = flow_config(self.module_label)
        role = Group.objects.get(
            name=config.FLOW[config.INITIAL]['role'])

        request = Request.objects.create(
            requester=user,
            module_ref=module,
            status='Initiated')

        task = Task.objects.create(
            request=request,
            assignee=role,
            updated_by=user,
            activity_ref=config.INITIAL,
            status='In Progress')

        self.task = task
        self.save()
Exemple #9
0
    def submit(self, module, user, next_activity=None):
        """Submits the task"""
        config = flow_config(module)
        transitions = transition_config(module, self.activity_ref)
        role = Group.objects.get(
            name=config.FLOW[next_activity]['role'])

        self.status = 'Completed'
        self.save()

        if transitions is not None:
            Task.objects.create(
                request=self.request,
                assignee=role,
                updated_by=user,
                activity_ref=next_activity,
                status='Not Started')
        else:
            self.request.status = 'Completed'
            self.request.save()
Exemple #10
0
def global_context(request):
    """Sets up global template context"""
    def get_value(key):
        """Returns value against specified key"""
        return get_request_params(key, request)

    app_title = get_value('app_name')
    activity_identifier = get_value('model_name')

    try:
        flow = flow_config(app_title).FLOW
        activity_title = flow[
            [identifier for identifier in flow if flow[identifier][
                'model']().title == activity_identifier][0]]['name']
    except (IndexError, LookupError, ImportError):
        activity_title = None

    return {
        'entity_title': activity_identifier,
        'app_title': app_title,
        'identifier': get_value('pk'),
        'activity_title': activity_title
    }
Exemple #11
0
def global_context(request):
    """Sets up global template context"""
    def get_value(key):
        """Returns value against specified key"""
        return get_request_params(key, request)

    app_title = get_value('app_name')
    activity_identifier = get_value('model_name')

    try:
        flow = flow_config(app_title).FLOW
        activity_title = flow[[
            identifier for identifier in flow
            if flow[identifier]['model']().title == activity_identifier
        ][0]]['name']
    except (IndexError, LookupError, ImportError):
        activity_title = None

    return {
        'entity_title': activity_identifier,
        'app_title': app_title,
        'identifier': get_value('pk'),
        'activity_title': activity_title
    }
Exemple #12
0
 def activity(self):
     """Returns the activity associated with the task"""
     flow = flow_config(self.request.module_ref).FLOW
     return getattr(
         self, flow[self.activity_ref]['model']().title.lower(), None)
Exemple #13
0
 def is_initial(self):
     """Checks if the activity is initial activity"""
     config = flow_config(self.module_label)
     return True if self.title == config.FLOW[
         config.INITIAL]['model']().title else False
Exemple #14
0
 def activity(self):
     """Returns the activity associated with the task"""
     flow = flow_config(self.request.module_ref).FLOW
     return getattr(
         self, flow[self.activity_ref]['model']().title.lower(), None)
Exemple #15
0
 def is_initial(self):
     """Checks if the activity is initial activity"""
     config = flow_config(self.module_label)
     return True if self.title == config.FLOW[
         config.INITIAL]['model']().title else False
Exemple #16
0
 def is_final(self):
     """Checks if the current task is final / end task"""
     flow = flow_config(
         self.request.module_ref).FLOW
     return not flow[self.flow_ref_key]['transitions']