* Notify users about the usage of deprecated webhooks
Each time a deprecated webhook is hit, a notification is
created (without duplicating it) to be sent.
* Extend notification to support de-dup and delayed email sent
* Improve decorator to support generic and specific VCS webhook views
* Remove no necessary settings
* DeprecatedWebhookEndpointNotification tests and improvements
* Better docstring
* Lint
* Update copy on notifications for github services deprecation (#5067)
* Updated copy on webhooks
* Drop "deprecated webhook endpoint" copy, this is core team nomenclature, not user
nomenclature.
* Add small amount of docs to point to
* Update docs and point to docs in notification message
* Add year
* Split up deprecated view notification to GitHub and other webhook endpoints (#5083)
* Updated copy on webhooks
* Drop "deprecated webhook endpoint" copy, this is core team nomenclature, not user
nomenclature.
* Add small amount of docs to point to
* Update docs and point to docs in notification message
* Split up deprecated view notification to GitHub and other webhook endpoints
This sets a date for deprecated of these endpoints as Mar 1st 2019. Too
soon?
* Reduce complexity and drop decorator pattern for Notification
classmethod pattern used in other notifications
* Add notifications for non-GitHub incoming webhooks
* Add docs as well
* More renaming and slight refactor
Found out 2x messages are being generated, so this stops the automated
mechanism for triggering these messages.
* Update dates
* Also update docs
* Typo on date
* Back out some more of the changes to notifications to make them operable without automation
* Add admin method for notification
* Add admin filter for project features
$ pre-commit run python-import-sorter --files `find readthedocs -name '*.py'`
It was ran with this configuration: https://github.com/rtfd/common/pull/28
* Upgrade all packages using pur
for reqs in `ls requirements`;
do
pur
--skip django-tastypie,django,docker,elasticsearch,pyelasticsearch,commonmark,stripe,djangorestframework,mkdocs,django-allauth,django-filter,mercurial
--requirement requirements/$reqs;
done
* Run lint with Python 3.6
* Downgrade gitpython to 2.1.10
* Linting error fixed
* Upgrade common
Branch: https://github.com/rtfd/common/pull/17
* Remove old note for testing
* Add note for django-filter
* no-else-return fixed in all the files
Some block needed to be re-idented to fulfill this check.
Basically, if you have a "if something: return another" the "else"
clause is not needed since it will be the common case for the flow to
continue if the condition is not met.
* Only # noqa comment
* Note about gitpython
* 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
* Handle general oauth services errors
This is a way to protect ourselves from random errors when syncing
OAuth services (create repository/organizations).
If a global exception is raised, we just skip this service and
continue with the rest of the connected ones.
* Handle revoked oauth permissions by the user
If the user revoked our app permission from the external service web
page, we are not notified. So, next time we try to use it, we will
receive a 401 status code in the first request.
Here we handle this case and we show a Persistent Notification to the
user so he/she knows that a reconnection of the account is needed.
* Remove unnecessary exception handling
* Style
* Add a user persistent notification when social access is revoked
* Raise an Exception when permissions revoked
Raise a simple Exception when the permissions from a particular social
service are revoked instead of using a persistent notification.
We want an Exception because it's immediately communicated using the
PublicTask mechanism. Otherwise, the user needs to refresh the page to
see the notification.
* Remove invalid imports
* Improve comment
* Add final dot to the phrase
* Remove unused return
* Alter usage of message extends
Instead of using the messages.add method directly, add message for the message
notification backend using the storage adapter directly. This also removes the
limitation on the storage backend that requires a request.user is authenticated,
as we are likely going to be mostly adding messages through celery or other
request-less mechanisms.
* Fix tests
* Make sure we can't add messages for anonymous users and fix tests
* Fix bug with on site notification
It would help if the notification went to the correct user.
* Fix tests
* Replace monkey patched add_message with actual method for linting fix
* Fix signup issues and brand allauth emails
This fixes a bug with the notification system on logged out users and overrides
the allauth email templates. The base emails are very generic, aren't themed like
the rest of our emails, and had very generic copy.
* Lint fix
* WIP for integrating persistent messaging for users
Combines notifications so that email/on site messaging will all be maintained in
the same place, and can extend from each other using normal template semantics.
* Add email support, clean up implementation
* Add reqs
* Drop unnecessary string conversion
* Change admin email form to look at templates, not ask for template source
* Add docs, tests, views for processing redirects
* Do the thing I meant to do
* Drop views, just use javascript instead
This adds javascript that intercepts link clicks in notifications,
hits the dismiss url defined on the dom object, and then redirects
to the correct url of the original link.
* Move classes around and rename module
* Drop unused notification for testing
* Clean up usage, drop test uses of the views/notifications
* Add example usage that will be used for notification on resource usage
* Fix mock module path
* Add more docs around implementation