aboutsummaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorJohan Herland <johan@herland.net>2019-12-01 02:49:53 +0100
committerStephen Finucane <stephen@that.guru>2019-12-01 11:59:25 +0000
commit79a3efb63a3ac2dea0382a4d6ec1b675a7b154c9 (patch)
tree093019e0872b34f8c98970013f4df80474e78ce0 /docs
parent17a0e05114fd3c75bd773d2694fa1f5e4076782f (diff)
downloadpatchwork-79a3efb63a3ac2dea0382a4d6ec1b675a7b154c9.tar
patchwork-79a3efb63a3ac2dea0382a4d6ec1b675a7b154c9.tar.gz
Include the responsible actor in applicable events
We want to use the events as an audit log. An important part of this is recording _who_ made the changes that the events represent. To accomplish this, we need to know the current user (aka. request.user) at the point where we create the Event instance. Event creation is currently triggered by signals, but neither the signal handlers, nor the model classes themselves have easy access to request.user. For some Patch-based events (patch-state-changed, patch-delegated), we can do the following hack: The relevant events are created in signal handlers that are all hooked up to either the pre_save or post_save signals sent by Patch.save(). But before calling Patch.save(), Patchwork must naturally query Patch.is_editable() to ascertain whether the patch can in fact be changed by the current user. Thus, we only need a way to communicate the current user from Patch.is_editable() to the signal handlers that create the resulting Events. The Patch object itself is available in both places, so we simply add an '_edited_by' attribute to the instance (which fortunately is not detected as a persistent db field by Django). For the check-created event the current user always happens to be the same as the 'user' field recorded in the Check object itself. For the other Patch-based events (patch-created, patch-completed, and series-completed), although they are also triggered by Patch.save(), they are triggered as a result of incoming emails, hence have no real actor as such, so we simply leave the actor as None/NULL. The same argument also applies to the cover-created and series-created events. Signed-off-by: Johan Herland <johan@herland.net> Reviewed-by: Stephen Finucane <stephen@that.guru> Cc: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Diffstat (limited to 'docs')
0 files changed, 0 insertions, 0 deletions