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

Refactor PublicTask into a decorator task #4656

Merged
merged 2 commits into from Oct 2, 2018

Conversation

@stsewd
Copy link
Member

@stsewd stsewd commented Sep 21, 2018

Still wip, I need to update some docstrings, but I already tested it, and it works :)

Fix #3974 and ref to #3973

user = User.objects.get(pk=user_id)
for service_cls in registry:
for service in service_cls.for_user(user):
service.sync()
Copy link
Member Author

@stsewd stsewd Sep 21, 2018

The api for defining a public task is cleaner now :D

Copy link
Contributor

@agjohnson agjohnson Oct 2, 2018

Much nicer!

@@ -22,20 +31,12 @@


@permission_check(user_id_matches)
Copy link
Member Author

@stsewd stsewd Sep 21, 2018

In the celery docs, it says that we shouldn't do this (put the task decorator down), but the task decorator overrides all function's attributes and deletes the added by permission_check, this way we can keep the added attribute.

@stsewd
Copy link
Member Author

@stsewd stsewd commented Sep 21, 2018

I believe this is ready, I also tested it locally, it works as expected.

Copy link
Contributor

@agjohnson agjohnson left a comment

Looks great! We'll want to make sure this has some QA before release, but I don't think we use public task anywhere else at the moment.

user = User.objects.get(pk=user_id)
for service_cls in registry:
for service in service_cls.for_user(user):
service.sync()
Copy link
Contributor

@agjohnson agjohnson Oct 2, 2018

Much nicer!

@agjohnson agjohnson merged commit a8bd00a into readthedocs:master Oct 2, 2018
1 check passed
@stsewd stsewd deleted the refactor-public-task branch Oct 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants