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)
--- /dev/null
+# -*- 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')]),
+ ),
+ ]
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')