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
Closed

Comments

@xuziheng1002
Copy link
Contributor

@xuziheng1002 xuziheng1002 commented Feb 4, 2020

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

This comment has been minimized.

Copy link
Contributor Author

@xuziheng1002 xuziheng1002 commented Feb 4, 2020

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

@javrasya

This comment has been minimized.

Copy link
Owner

@javrasya 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

This comment has been minimized.

Copy link
Contributor Author

@xuziheng1002 xuziheng1002 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.

@javrasya

This comment has been minimized.

Copy link
Owner

@javrasya 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

This comment has been minimized.

Copy link
Contributor Author

@xuziheng1002 xuziheng1002 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

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

This comment has been minimized.

Copy link
Owner

@javrasya 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

This comment has been minimized.

Copy link
Owner

@javrasya 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

This comment has been minimized.

Copy link
Contributor Author

@xuziheng1002 xuziheng1002 commented Feb 7, 2020

Fixed it in #139
Close

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

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.