Commit 467a9956 authored by Laurent Pinchart's avatar Laurent Pinchart Committed by Damien Lespiau
Browse files

models: Add DelegationRule object



Delegation rules are used to automatically set the delegate of a patch
based on the files touched by the patch.

v2: Port to fdo's patchwork (Damien)
Signed-off-by: Laurent Pinchart's avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
Acked-by: default avatarStephen Finucane <stephen.finucane@intel.com>
parent 5169b28d
......@@ -22,11 +22,20 @@ from __future__ import absolute_import
from django.contrib import admin
from patchwork.models import (Project, Person, UserProfile, State, Patch,
Comment, Bundle, Tag, Test, TestResult)
Comment, Bundle, Tag, Test, TestResult,
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)
......
# -*- 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', '0015_remove_version_n_patches'),
]
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')]),
),
]
......@@ -125,6 +125,21 @@ def user_name(user):
auth.models.User.add_to_class('name', user_name)
@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')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment