[Patchew-devel] [PATCH 2/7] tags: remove reviewed property

Paolo Bonzini posted 7 patches 8 weeks ago

[Patchew-devel] [PATCH 2/7] tags: remove reviewed property

Posted by Paolo Bonzini 8 weeks ago
Just rely on the presence/absence of the reviewers property.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 .../0046_reviewed_message_property.py         | 29 +++++++++++++++++++
 mods/tags.py                                  |  5 ++--
 2 files changed, 31 insertions(+), 3 deletions(-)
 create mode 100644 api/migrations/0046_reviewed_message_property.py

diff --git a/api/migrations/0046_reviewed_message_property.py b/api/migrations/0046_reviewed_message_property.py
new file mode 100644
index 0000000..f90a71b
--- /dev/null
+++ b/api/migrations/0046_reviewed_message_property.py
@@ -0,0 +1,29 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.conf import settings
+from django.db import migrations
+
+def delete_reviewed(apps, schema_editor):
+    MessageProperty = apps.get_model('api', 'MessageProperty')
+    MessageProperty.objects.filter(name='reviewed').delete()
+
+def add_reviewed(apps, schema_editor):
+    Message = apps.get_model('api', 'Message')
+    MessageProperty = apps.get_model('api', 'MessageProperty')
+    props = MessageProperty.objects.filter(name='reviewers')
+    for p in props:
+        if p.value:
+            new_prop = MessageProperty(message=p.message, name='reviewed', value=True)
+            new_prop.save()
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('api', '0045_message_maintainers'),
+    ]
+
+    operations = [
+        migrations.RunPython(delete_reviewed,
+                             reverse_code=add_reviewed),
+    ]
diff --git a/mods/tags.py b/mods/tags.py
index 1ac27a7..e31db26 100644
--- a/mods/tags.py
+++ b/mods/tags.py
@@ -99,7 +99,6 @@ series cover letter, patch mail body and their replies.
         series_reviewers = _find_reviewers(series)
         reviewers = reviewers.union(series_reviewers)
         if num_reviewed == series.get_num()[1] or series_reviewers:
-            series.set_property("reviewed", True)
             series.set_property("reviewers", list(reviewers))
         if updated:
             emit_event("TagsUpdate", series=series)
@@ -124,8 +123,8 @@ series cover letter, patch mail body and their replies.
     def prepare_message_hook(self, request, message, detailed):
         if not message.is_series_head:
             return
-        if message.get_property("reviewed"):
-            reviewers = message.get_property("reviewers")
+        reviewers = message.get_property("reviewers", [])
+        if reviewers:
             message.status_tags.append({
                 "title": "Reviewed by " + ", ".join([x for x, y in reviewers]),
                 "type": "success",
-- 
2.21.0


_______________________________________________
Patchew-devel mailing list
Patchew-devel@redhat.com
https://www.redhat.com/mailman/listinfo/patchew-devel