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

Restore CELERY_TASK_EAGER_PROPAGATES to True #2962

Merged
merged 4 commits into from Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Expand Up @@ -6,6 +6,9 @@
- Organization can nom define a custom metadata of a choosen type
- Dataset belonging to the organization can assign a value to the defined metadata
- Metadata value must match the choosen type by the organization
- Fix: do not send mail about discussions when there is no owner / no organisation members [#2962](https://github.com/opendatateam/udata/pull/2962)
- Fix: 'backend' is now required in `HarvestSource` [#2962](https://github.com/opendatateam/udata/pull/2962)
- Fix: URL to organizations in mails are now independent from `udata-front` (show the URL of the API if no `udata-front`) [#2962](https://github.com/opendatateam/udata/pull/2962)

## 7.0.3 (2024-02-15)

Expand Down
6 changes: 2 additions & 4 deletions udata/core/discussions/api.py
Expand Up @@ -14,10 +14,8 @@
from .forms import DiscussionCreateForm, DiscussionCommentForm
from .models import Message, Discussion
from .permissions import CloseDiscussionPermission
from .signals import (
on_new_discussion, on_new_discussion_comment, on_discussion_closed,
on_discussion_deleted
)
from .signals import on_discussion_deleted


ns = api.namespace('discussions', 'Discussion related operations')

Expand Down
4 changes: 3 additions & 1 deletion udata/core/discussions/tasks.py
Expand Up @@ -16,8 +16,10 @@
def owner_recipients(discussion):
if getattr(discussion.subject, 'organization', None):
return [m.user for m in discussion.subject.organization.members]
else:
elif getattr(discussion.subject, 'owner', None):
return [discussion.subject.owner]
else:
return []


@connect(on_new_discussion, by_id=True)
Expand Down
4 changes: 2 additions & 2 deletions udata/harvest/backends/base.py
Expand Up @@ -156,15 +156,15 @@ def perform_initialization(self):
self.job.errors.append(error)
self.job.status = 'failed'
self.end()
return
return None
except Exception as e:
self.job.status = 'failed'
error = HarvestError(message=safe_unicode(e))
self.job.errors.append(error)
self.end()
msg = 'Initialization failed for "{0.name}" ({0.backend})'
log.exception(msg.format(self.source))
return
return None

if self.max_items:
self.job.items = self.job.items[:self.max_items]
Expand Down
2 changes: 1 addition & 1 deletion udata/harvest/models.py
Expand Up @@ -94,7 +94,7 @@ class HarvestSource(db.Owned, db.Document):
populate_from='name', update=True)
description = db.StringField()
url = db.StringField(required=True)
backend = db.StringField()
backend = db.StringField(required=True)
config = db.DictField()
periodic_task = db.ReferenceField('PeriodicTask',
reverse_delete_rule=db.NULLIFY)
Expand Down
9 changes: 6 additions & 3 deletions udata/harvest/tasks.py
Expand Up @@ -19,15 +19,18 @@ def harvest(self, ident):
Backend = backends.get(current_app, source.backend)
backend = Backend(source)
items = backend.perform_initialization()
if items > 0:
if items is None:
ThibaudDauce marked this conversation as resolved.
Show resolved Hide resolved
pass
elif items == 0:
backend.finalize()
else:
finalize = harvest_job_finalize.s(backend.job.id)
items = [
harvest_job_item.s(backend.job.id, item.remote_id)
for item in backend.job.items
]
chord(items)(finalize)
elif items == 0:
backend.finalize()



@task(ignore_result=False, route='low.harvest')
Expand Down
1 change: 1 addition & 0 deletions udata/harvest/tests/factories.py
Expand Up @@ -22,6 +22,7 @@ class Meta:
name = factory.Faker('name')
url = factory.Faker('url')
description = factory.Faker('text')
backend = 'factory'


class HarvestJobFactory(ModelFactory):
Expand Down
2 changes: 1 addition & 1 deletion udata/harvest/tests/test_models.py
Expand Up @@ -12,7 +12,7 @@
@pytest.mark.usefixtures('clean_db')
class HarvestSourceTest:
def test_defaults(self):
source = HarvestSource.objects.create(name='Test', url=faker.url())
source = HarvestSource.objects.create(name='Test', url=faker.url(), backend='factory')
assert source.name == 'Test'
assert source.slug == 'test'

Expand Down
3 changes: 1 addition & 2 deletions udata/settings.py
Expand Up @@ -470,8 +470,7 @@ class Testing(object):
WTF_CSRF_ENABLED = False
AUTO_INDEX = False
CELERY_TASK_ALWAYS_EAGER = True
# TODO: ideally, this should be set to True in order to reveal exceptions in delayed tasks
CELERY_TASK_EAGER_PROPAGATES = False
CELERY_TASK_EAGER_PROPAGATES = True
TEST_WITH_PLUGINS = False
PLUGINS = []
TEST_WITH_THEME = False
Expand Down
2 changes: 1 addition & 1 deletion udata/templates/mail/membership_refused.html
Expand Up @@ -7,7 +7,7 @@
{{ _('Your membership for the organization "%(org)s" has been refused',
org=(
'<a href="'|safe
+ url_for('organizations.show', org=org, _external=True)
+ org.url_for(_external=True)
+ '">'|safe
+ org.name
+ '</a>'|safe
Expand Down
2 changes: 1 addition & 1 deletion udata/templates/mail/membership_request.html
Expand Up @@ -15,7 +15,7 @@
),
org=(
'<a href="'|safe
+ url_for('organizations.show', org=org, _external=True)
+ org.url_for(_external=True)
+ '">'|safe
+ org.name
+ '</a>'|safe
Expand Down
4 changes: 2 additions & 2 deletions udata/templates/mail/new_member.html
Expand Up @@ -7,7 +7,7 @@
{{ _('Congratulations, you are now a member of the organization "%(org)s"',
org=(
'<a href="'|safe
+ url_for('organizations.show', org=org, _external=True)
+ org.url_for(_external=True)
+ '">'|safe
+ org.name
+ '</a>'|safe
Expand All @@ -19,7 +19,7 @@
<td align="center">
{{ mail_button(
_('See the organization page'),
url_for('organizations.show', org=org, _external=True)
org.url_for(_external=True)
) }}
</td>
</tr>
Expand Down
2 changes: 1 addition & 1 deletion udata/templates/mail/new_member.txt
Expand Up @@ -7,5 +7,5 @@


{{ _('You can go on your organization page') }}:
{{ url_for('organizations.show', org=org, _external=True) }}
{{ org.url_for(_external=True) }}
{% endblock %}