[PATCH 1/3] models.Event: Add the user responsible for the event

Johan Herland johan at herland.net
Mon Oct 7 09:57:23 AEDT 2019


This allows using the events as a kind of audit log, to see how a
patch came to its current state/delegate.

Cc: Mauro Carvalho Chehab <mchehab at osg.samsung.com>
Signed-off-by: Johan Herland <johan at herland.net>
---
 patchwork/migrations/0037_event_user.py | 23 +++++++++++++++++++++++
 patchwork/models.py                     |  4 ++++
 2 files changed, 27 insertions(+)
 create mode 100644 patchwork/migrations/0037_event_user.py

diff --git a/patchwork/migrations/0037_event_user.py b/patchwork/migrations/0037_event_user.py
new file mode 100644
index 0000000..3a6e228
--- /dev/null
+++ b/patchwork/migrations/0037_event_user.py
@@ -0,0 +1,23 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11.20 on 2019-09-28 21:35
+from __future__ import unicode_literals
+
+from django.conf import settings
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
+        ('patchwork', '0036_project_commit_url_format'),
+    ]
+
+    operations = [
+        migrations.AddField(
+            model_name='event',
+            name='user',
+            field=models.ForeignKey(blank=True, help_text=b'The user that created this event.', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to=settings.AUTH_USER_MODEL),
+        ),
+    ]
diff --git a/patchwork/models.py b/patchwork/models.py
index c198bc2..3d4e222 100644
--- a/patchwork/models.py
+++ b/patchwork/models.py
@@ -944,6 +944,10 @@ class Event(models.Model):
     date = models.DateTimeField(
         default=datetime.datetime.utcnow,
         help_text='The time this event was created.')
+    user = models.ForeignKey(
+        User, related_name='+', null=True, blank=True,
+        on_delete=models.SET_NULL,
+        help_text='The user that created this event.')
 
     # event object
 
-- 
2.19.2



More information about the Patchwork mailing list