Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'TransitionApproval' object has no attribute 'iteration' #137

Closed
xuziheng1002 opened this issue Feb 4, 2020 · 8 comments

Comments

@xuziheng1002
Copy link
Contributor

Program raise error as title when I try to jump state

Is this a bug? I think iteration is a field in Transition model, not TransitionApproval

source in river.core.instanceworkflowobject.py (line:91)

    @property
    def recent_approval(self):
        try:
            return getattr(self.workflow_object, self.field_name + "_transition_approvals").filter(transaction_date__isnull=False).latest('transaction_date')
        except TransitionApproval.DoesNotExist:
            return None

    @transaction.atomic
    def jump_to(self, state):
        def _transitions_before(iteration):
            return Transition.objects.filter(workflow=self.workflow, workflow_object=self.workflow_object, iteration__lte=iteration)

        try:
            recent_iteration = self.recent_approval.iteration if self.recent_approval else 0
            jumped_transition = getattr(self.workflow_object, self.field_name + "_transitions").filter(
                iteration__gte=recent_iteration, destination_state=state, status=PENDING
            ).earliest("iteration")
@xuziheng1002
Copy link
Contributor Author

xuziheng1002 commented Feb 4, 2020

I think it should be self.recent_approval.transition.iteration (current: self.recent_approval.iteration)
is that right?

@javrasya
Copy link
Owner

javrasya commented Feb 4, 2020

Hi @xuziheng1002
At first glance, it seems to be. I would appreciate it if you can create PR with a test case for this. Otherwise, I can do it sometime this week.

@xuziheng1002
Copy link
Contributor Author

Hi @xuziheng1002
At first glance, it seems to be. I would appreciate it if you can create PR with a test case for this. Otherwise, I can do it sometime this week.

OK, I will create PR with testCase this week.

@javrasya
Copy link
Owner

javrasya commented Feb 4, 2020

Hi @xuziheng1002
At first glance, it seems to be. I would appreciate it if you can create PR with a test case for this. Otherwise, I can do it sometime this week.

OK, I will create PR with testCase this week.

Here is where jumping to a specific state test case is. I don't know why it doesn't manage to catch this. But it is a good starting point to get some inspiration;

https://github.com/javrasya/django-river/blob/master/river/tests/core/test__instance_api.py#L1577

@xuziheng1002
Copy link
Contributor Author

Hi @xuziheng1002
At first glance, it seems to be. I would appreciate it if you can create PR with a test case for this. Otherwise, I can do it sometime this week.

OK, I will create PR with testCase this week.

Here is where jumping to a specific state test case is. I don't know why it doesn't manage to catch this. But it is a good starting point to get some inspiration;

https://github.com/javrasya/django-river/blob/master/river/tests/core/test__instance_api.py#L1577

ok, is there any document that let me know how to initialize test db?
it seems should use the migration file in river.test.tmigration/* , isn't it?

@javrasya
Copy link
Owner

javrasya commented Feb 4, 2020

Unfortunately no documentation but if you want to run the tests with tox you don't need to do anything.
But if you want to run them through PyCharm, just run python manage.py migrate --run-syncdb before you run the tests.

xuziheng1002 pushed a commit to xuziheng1002/django-river that referenced this issue Feb 5, 2020
xuziheng1002 pushed a commit to xuziheng1002/django-river that referenced this issue Feb 5, 2020
xuziheng1002 pushed a commit to xuziheng1002/django-river that referenced this issue Feb 6, 2020
javrasya pushed a commit that referenced this issue Feb 6, 2020
* [#137] Fix jump to future problem
@javrasya
Copy link
Owner

javrasya commented Feb 6, 2020

Your PR is merged to master. Thanks for that again ❤️
Do you need the new version released on PyPI immediately @xuziheng1002 ? Or can you use it from GitHub until it 3.1.4 is released? Otherwise, I can release a hotfix release today.

@xuziheng1002
Copy link
Contributor Author

Fixed it in #139
Close

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants