From: Laurent Pinchart Date: Sat, 28 Nov 2015 12:14:37 +0000 (-0200) Subject: models: Add DelegationRule object X-Git-Tag: v1.1.0~80 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b1b8a4761ccbf7174fe9a9b17b478377b296d15d;p=thirdparty%2Fpatchwork.git models: Add DelegationRule object 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 Signed-off-by: Mauro Carvalho Chehab Acked-by: Stephen Finucane --- diff --git a/patchwork/admin.py b/patchwork/admin.py index 082885bf..22d95e7a 100644 --- a/patchwork/admin.py +++ b/patchwork/admin.py @@ -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 index 00000000..cec90144 --- /dev/null +++ b/patchwork/migrations/0004_add_delegation_rule_model.py @@ -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')]), + ), + ] diff --git a/patchwork/models.py b/patchwork/models.py index d239fe8e..be25fbc2 100644 --- a/patchwork/models.py +++ b/patchwork/models.py @@ -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')