Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow to hook the initial build from outside (#4033)
* Allow to hook the initial build from outside Add a new attribute to `trigger_build` to do not execute the task but just return the immutable signature of it, so it can be chained into a bigger task from outside when it's needed to do something else before/after it's execution. * Remove unused basic attribute on trigger build * Split trigger_build to be able to prepare_build first Added a ``ImportWizard.trigger_initial_build`` method to be override from corporate site. Also, instead of using ``trigger_build`` to create the Celery task and call it immediately, split it to use ``prepare_build`` first to create the task and use ``trigger_build`` to effectively triggers it. * Remove now unused signal * Fix Celery signature creation * Fix testcases with basic on trigger_build * Fix mock calls in test cases * Fix test mock check * Use async task to attach webhook * Use proper context object * Make it compatible with newer Django versions * Py2 and Py3 compatible line * Dismiss the sticky message and stay in the same page * Use Context to render the template * Lint errors fixed * Call the task in a sync way properly * Update common submodule to latest * Define NonPersistentStorage for one-time notifications NonPersistentNotification backed together with SiteNotification class helps us to create one-time site notifications and attach it to a user without the needs of a request/session object. The message/notification is saved into the database as a PersistentMessage and it's marked as read while it's retrived the first time. This system is useful for notifications that need to be attached from a Celery task where we know the user but we don't have the request. * Make string translatable * Fix merge conflicts * Recover accidentally deleted line * Fixed linting errors * Replace message_key with reason to be clearer * Rename non persistent storage class * Remove old templates * Make SiteNotification more flexible - render strings messages as Django Templates - accept extra_context for the template - do not crash if the reason is incorrect * Adapt AttachWebhookNotification to the new features * Refactor the task to attach a webhook Instantiate only once the notification and adapt it depending the context. Also, if there are no connected services into our application do not show a message to the user, but log it as a warning. * Test cases for SiteNotification and NonPersistentStorage * Remove unnecessary lines * Show a persistent message for invalid project webhook If we can setup a valid webhook, we show a persistent message with an actionable link using our notifications abstraction. At this point, the message is duplicated because we have a "fixed template message" also which is planned to be removed soon. * Improve copy * Allow to hook the initial build from outside Add a new attribute to `trigger_build` to do not execute the task but just return the immutable signature of it, so it can be chained into a bigger task from outside when it's needed to do something else before/after it's execution. * Remove unused basic attribute on trigger build * Split trigger_build to be able to prepare_build first Added a ``ImportWizard.trigger_initial_build`` method to be override from corporate site. Also, instead of using ``trigger_build`` to create the Celery task and call it immediately, split it to use ``prepare_build`` first to create the task and use ``trigger_build`` to effectively triggers it. * Remove now unused signal * Fix Celery signature creation * Fix testcases with basic on trigger_build * Fix mock calls in test cases * Fix test mock check * Use proper context object * Make it compatible with newer Django versions * Py2 and Py3 compatible line * Dismiss the sticky message and stay in the same page * Use Context to render the template * Lint errors fixed * Call the task in a sync way properly * Update common submodule to latest * Define NonPersistentStorage for one-time notifications NonPersistentNotification backed together with SiteNotification class helps us to create one-time site notifications and attach it to a user without the needs of a request/session object. The message/notification is saved into the database as a PersistentMessage and it's marked as read while it's retrived the first time. This system is useful for notifications that need to be attached from a Celery task where we know the user but we don't have the request. * Make string translatable * Use async task to attach webhook * Fix merge conflicts * Recover accidentally deleted line * Fixed linting errors * Replace message_key with reason to be clearer * Rename non persistent storage class * Remove old templates * Make SiteNotification more flexible - render strings messages as Django Templates - accept extra_context for the template - do not crash if the reason is incorrect * Adapt AttachWebhookNotification to the new features * Refactor the task to attach a webhook Instantiate only once the notification and adapt it depending the context. Also, if there are no connected services into our application do not show a message to the user, but log it as a warning. * Test cases for SiteNotification and NonPersistentStorage * Remove unnecessary lines * Show a persistent message for invalid project webhook If we can setup a valid webhook, we show a persistent message with an actionable link using our notifications abstraction. At this point, the message is duplicated because we have a "fixed template message" also which is planned to be removed soon. * Improve copy * Remove fixed template notification about Project.has_valid_webhook
- Loading branch information