[Patchew-devel] [PATCH 17/17] models: remove property tables

Paolo Bonzini posted 17 patches 5 years, 7 months ago
[Patchew-devel] [PATCH 17/17] models: remove property tables
Posted by Paolo Bonzini 5 years, 7 months ago
---
 api/admin.py                              | 14 +--------
 api/migrations/0053_auto_20190418_1357.py | 37 +++++++++++++++++++++++
 api/models.py                             | 29 +-----------------
 api/search.py                             |  2 +-
 mods/git.py                               |  3 +-
 mods/testing.py                           |  3 +-
 6 files changed, 42 insertions(+), 46 deletions(-)
 create mode 100644 api/migrations/0053_auto_20190418_1357.py

diff --git a/api/admin.py b/api/admin.py
index bd9e85b..ef0e21b 100644
--- a/api/admin.py
+++ b/api/admin.py
@@ -9,27 +9,15 @@
 # http://opensource.org/licenses/MIT.
 
 from django.contrib import admin
-from .models import Message, MessageProperty, Module, Project, ProjectProperty
+from .models import Message, Module, Project
 from mod import get_module
 
 
-class ProjectPropertyInline(admin.TabularInline):
-    model = ProjectProperty
-    extra = 0
-
-
 class ProjectAdmin(admin.ModelAdmin):
     filter_horizontal = ('maintainers',)
-    inlines = [ProjectPropertyInline]
-
-
-class MessagePropertyInline(admin.TabularInline):
-    model = MessageProperty
-    extra = 0
 
 
 class MessageAdmin(admin.ModelAdmin):
-    inlines = [MessagePropertyInline]
     list_filter = [('is_series_head')]
     search_fields = [
         'message_id',
diff --git a/api/migrations/0053_auto_20190418_1357.py b/api/migrations/0053_auto_20190418_1357.py
new file mode 100644
index 0000000..4621bcd
--- /dev/null
+++ b/api/migrations/0053_auto_20190418_1357.py
@@ -0,0 +1,37 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11.20 on 2019-04-18 13:57
+from __future__ import unicode_literals
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('api', '0052_populate_property_fields'),
+    ]
+
+    operations = [
+        migrations.AlterUniqueTogether(
+            name='messageproperty',
+            unique_together=set([]),
+        ),
+        migrations.RemoveField(
+            model_name='messageproperty',
+            name='message',
+        ),
+        migrations.AlterUniqueTogether(
+            name='projectproperty',
+            unique_together=set([]),
+        ),
+        migrations.RemoveField(
+            model_name='projectproperty',
+            name='project',
+        ),
+        migrations.DeleteModel(
+            name='MessageProperty',
+        ),
+        migrations.DeleteModel(
+            name='ProjectProperty',
+        ),
+    ]
diff --git a/api/models.py b/api/models.py
index 9573672..a4fb79c 100644
--- a/api/models.py
+++ b/api/models.py
@@ -312,16 +312,6 @@ class ProjectResult(Result):
         return self.project
 
 
-class ProjectProperty(models.Model):
-    project = models.ForeignKey('Project', on_delete=models.CASCADE)
-    name = models.CharField(max_length=1024, db_index=True)
-    value = jsonfield.JSONField()
-
-    class Meta:
-        unique_together = ('project', 'name',)
-        verbose_name_plural = "Project Properties"
-
-
 declare_event("SeriesComplete", project="project object",
               series="series instance that is marked complete")
 declare_event("SeriesMerged", project="project object",
@@ -369,7 +359,7 @@ class MessageManager(models.Manager):
                 return None
         else:
             q = super(MessageManager, self).get_queryset()
-        return q.filter(is_series_head=True).prefetch_related('messageproperty_set', 'project')
+        return q.filter(is_series_head=True).prefetch_related('project')
 
     def find_series(self, message_id, project_name=None):
         heads = self.series_heads(project_name)
@@ -807,23 +797,6 @@ class MessageResult(Result):
         return self.message
 
 
-class MessageProperty(models.Model):
-    message = models.ForeignKey('Message', on_delete=models.CASCADE)
-    name = models.CharField(max_length=256)
-    value = jsonfield.JSONField()
-
-    def __str__(self):
-        if len(self.value) > 30:
-            val_prev = self.value[:30] + "..."
-        else:
-            val_prev = self.value
-        return "%s: %s = %s" % (self.message.subject, self.name, val_prev)
-
-    class Meta:
-        unique_together = ('message', 'name',)
-        verbose_name_plural = "Message Properties"
-
-
 class Module(models.Model):
     """ Module information """
     name = models.CharField(max_length=128, unique=True)
diff --git a/api/search.py b/api/search.py
index 1c5aaaf..658ad4a 100644
--- a/api/search.py
+++ b/api/search.py
@@ -8,7 +8,7 @@
 # This work is licensed under the MIT License.  Please see the LICENSE file or
 # http://opensource.org/licenses/MIT.
 
-from .models import Message, MessageProperty, MessageResult, Result, QueuedSeries
+from .models import Message, MessageResult, Result, QueuedSeries
 from functools import reduce
 
 from django.db import connection
diff --git a/mods/git.py b/mods/git.py
index 8e868c2..c1909ab 100644
--- a/mods/git.py
+++ b/mods/git.py
@@ -20,8 +20,7 @@ from django.utils.html import format_html
 from django.db.models import Q
 from mod import PatchewModule
 from event import declare_event, register_handler, emit_event
-from api.models import (Message, MessageProperty, Project,
-        ProjectProperty, Result)
+from api.models import (Message, Project, Result)
 from api.rest import PluginMethodField, reverse_detail
 from api.views import APILoginRequiredView, prepare_series
 from patchew.logviewer import LogView
diff --git a/mods/testing.py b/mods/testing.py
index e5562ba..f238406 100644
--- a/mods/testing.py
+++ b/mods/testing.py
@@ -19,8 +19,7 @@ import datetime
 import time
 import math
 from api.views import APILoginRequiredView
-from api.models import (Message, MessageProperty, MessageResult,
-        Project, ProjectResult, Result)
+from api.models import (Message, MessageResult, Project, ProjectResult, Result)
 from api.rest import PluginMethodField, reverse_detail
 from api.search import SearchEngine, FLAG_TESTED
 from event import emit_event, declare_event, register_handler
-- 
2.21.0

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