Skip to content

Commit

Permalink
Fix code quality issues
Browse files Browse the repository at this point in the history
  • Loading branch information
javrasya committed Nov 17, 2019
1 parent 1c7f104 commit c84cb83
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 14 deletions.
4 changes: 4 additions & 0 deletions .codacy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
exclude_paths:
- 'river/migrations/*'
- '**/tests/**'
2 changes: 1 addition & 1 deletion river/admin/function_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class FunctionAdmin(admin.ModelAdmin):
list_display = ('name', 'function_version', 'date_created', 'date_updated')
readonly_fields = ('version', 'date_created', 'date_updated')

def function_version(self, obj):
def function_version(self, obj): # pylint: disable=no-self-use
return "v%s" % obj.version


Expand Down
3 changes: 1 addition & 2 deletions river/admin/transitionmeta.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from django.contrib import admin
from django import forms
from django.contrib import admin

from river.models import TransitionMeta
from river.models.transitionapprovalmeta import TransitionApprovalMeta


class TransitionMetaForm(forms.ModelForm):
Expand Down
2 changes: 1 addition & 1 deletion river/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def _get_workflow_class_fields(cls, model):
from river.core.workflowregistry import workflow_registry
return workflow_registry.workflows[id(model)]

def _register_hook_inlines(self, model):
def _register_hook_inlines(self, model): # pylint: disable=no-self-use
from django.contrib import admin
from river.core.workflowregistry import workflow_registry
from river.admin import OnApprovedHookInline, OnTransitHookInline, OnCompleteHookInline, DefaultWorkflowModelAdmin
Expand Down
3 changes: 2 additions & 1 deletion river/core/instanceworkflowobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,8 @@ def _re_create_cycled_path(self, done_transition):
cycled_approval.permissions.set(old_approval.permissions.all())
cycled_approval.groups.set(old_approval.groups.all())

old_transitions = self._get_transition_images(old_transitions.values_list("destination_state__pk", flat=True)).exclude(source_state=done_transition.destination_state)
old_transitions = self._get_transition_images(old_transitions.values_list("destination_state__pk", flat=True)).exclude(
source_state=done_transition.destination_state)

iteration += 1

Expand Down
8 changes: 5 additions & 3 deletions river/models/on_approved_hook.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.db import models
from django.db.models import CASCADE, PROTECT
from django.db.models import CASCADE
from django.utils.translation import ugettext_lazy as _

from river.models import TransitionApprovalMeta, TransitionApproval
Expand All @@ -10,5 +10,7 @@ class OnApprovedHook(Hook):
class Meta:
unique_together = [('callback_function', 'workflow', 'transition_approval_meta', 'content_type', 'object_id', 'transition_approval')]

transition_approval_meta = models.ForeignKey(TransitionApprovalMeta, verbose_name=_("Transition Approval Meta"), related_name='on_approved_hooks', on_delete=CASCADE)
transition_approval = models.ForeignKey(TransitionApproval, verbose_name=_("Transition Approval"), related_name='on_approved_hooks', null=True, blank=True, on_delete=CASCADE)
transition_approval_meta = models.ForeignKey(
TransitionApprovalMeta, verbose_name=_("Transition Approval Meta"), related_name='on_approved_hooks', on_delete=CASCADE)
transition_approval = models.ForeignKey(
TransitionApproval, verbose_name=_("Transition Approval"), related_name='on_approved_hooks', null=True, blank=True, on_delete=CASCADE)
4 changes: 2 additions & 2 deletions river/models/on_transit_hook.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from django.db import models
from django.db.models import CASCADE, PROTECT
from django.db.models import CASCADE
from django.utils.translation import ugettext_lazy as _

from river.models import State, TransitionMeta, Transition
from river.models import TransitionMeta, Transition
from river.models.hook import Hook


Expand Down
14 changes: 12 additions & 2 deletions river/models/transition.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,18 @@ class Meta:

@property
def next_transitions(self):
return Transition.objects.filter(workflow=self.workflow, workflow_object=self.workflow_object, source_state=self.destination_state, iteration=self.iteration + 1)
return Transition.objects.filter(
workflow=self.workflow,
workflow_object=self.workflow_object,
source_state=self.destination_state,
iteration=self.iteration + 1
)

@property
def peers(self):
return Transition.objects.filter(workflow=self.workflow, workflow_object=self.workflow_object, source_state=self.source_state, iteration=self.iteration).exclude(pk=self.pk)
return Transition.objects.filter(
workflow=self.workflow,
workflow_object=self.workflow_object,
source_state=self.source_state,
iteration=self.iteration
).exclude(pk=self.pk)
6 changes: 4 additions & 2 deletions river/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ def __enter__(self):
):
hook.execute(self._get_context(BEFORE))

LOGGER.debug("The signal that is fired right before the transition ( %s ) happened for %s" % (self.transition_approval.transition, self.workflow_object))
LOGGER.debug("The signal that is fired right before the transition ( %s ) happened for %s"
% (self.transition_approval.transition, self.workflow_object))

def __exit__(self, type, value, traceback):
if self.status:
Expand All @@ -60,7 +61,8 @@ def __exit__(self, type, value, traceback):
)
):
hook.execute(self._get_context(AFTER))
LOGGER.debug("The signal that is fired right after the transition ( %s) happened for %s" % (self.transition_approval.transition, self.workflow_object))
LOGGER.debug("The signal that is fired right after the transition ( %s) happened for %s"
% (self.transition_approval.transition, self.workflow_object))

def _get_context(self, when):
return {
Expand Down

0 comments on commit c84cb83

Please sign in to comment.