]> git.ipfire.org Git - thirdparty/patchwork.git/commitdiff
models: Add DelegationRule object
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Sat, 28 Nov 2015 12:14:37 +0000 (10:14 -0200)
committerStephen Finucane <stephen.finucane@intel.com>
Tue, 19 Jan 2016 21:22:17 +0000 (21:22 +0000)
Delegation rules are used to automatically set the delegate of a patch
based on the files touched by the patch.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Acked-by: Stephen Finucane <stephen.finucane@intel.com>
patchwork/admin.py
patchwork/migrations/0004_add_delegation_rule_model.py [new file with mode: 0644]
patchwork/models.py

index 082885bfb84d23184fa822f3ee1d1c9e0c86f84d..22d95e7a2ddb966777877e8743f5697a8c0ed1d3 100644 (file)
@@ -22,11 +22,19 @@ from __future__ import absolute_import
 from django.contrib import admin
 
 from patchwork.models import (Project, Person, UserProfile, State, Patch,
-                              Comment, Bundle, Tag, Check)
+                              Comment, Bundle, Tag, Check, DelegationRule)
+
+
+class DelegationRuleInline(admin.TabularInline):
+    model = DelegationRule
+    fields = ('path', 'user', 'priority')
 
 
 class ProjectAdmin(admin.ModelAdmin):
     list_display = ('name', 'linkname', 'listid', 'listemail')
+    inlines = [
+        DelegationRuleInline,
+    ]
 admin.site.register(Project, ProjectAdmin)
 
 
diff --git a/patchwork/migrations/0004_add_delegation_rule_model.py b/patchwork/migrations/0004_add_delegation_rule_model.py
new file mode 100644 (file)
index 0000000..cec9014
--- /dev/null
@@ -0,0 +1,33 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+from django.conf import settings
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
+        ('patchwork', '0003_add_check_model'),
+    ]
+
+    operations = [
+        migrations.CreateModel(
+            name='DelegationRule',
+            fields=[
+                ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
+                ('path', models.CharField(max_length=255)),
+                ('priority', models.IntegerField(default=0)),
+                ('project', models.ForeignKey(to='patchwork.Project')),
+                ('user', models.ForeignKey(to=settings.AUTH_USER_MODEL)),
+            ],
+            options={
+                'ordering': ['-priority', 'path'],
+            },
+        ),
+        migrations.AlterUniqueTogether(
+            name='delegationrule',
+            unique_together=set([('path', 'project')]),
+        ),
+    ]
index d239fe8e6251eb1bb2d62f2877c8a241a59715ae..be25fbc2b710b64f51def9af0fd9cc79c55e26dc 100644 (file)
@@ -91,6 +91,21 @@ class Project(models.Model):
         ordering = ['linkname']
 
 
+@python_2_unicode_compatible
+class DelegationRule(models.Model):
+    user = models.ForeignKey(User)
+    path = models.CharField(max_length=255)
+    project = models.ForeignKey(Project)
+    priority = models.IntegerField(default=0)
+
+    def __str__(self):
+        return self.path
+
+    class Meta:
+        ordering = ['-priority', 'path']
+        unique_together = (('path', 'project'))
+
+
 @python_2_unicode_compatible
 class UserProfile(models.Model):
     user = models.OneToOneField(User, unique=True, related_name='profile')