diff mbox

[05/10] models: Add priority field to DelegationRule

Message ID 1448712886-3221-6-git-send-email-mchehab@osg.samsung.com
State Accepted
Delegated to: Stephen Finucane
Headers show

Commit Message

Mauro Carvalho Chehab Nov. 28, 2015, 12:14 p.m. UTC
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

The priority allows sorting delegation rules according to their
priorities. Higher priority rules will be evaluated first.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
---
 patchwork/admin.py  | 2 +-
 patchwork/models.py | 5 +++++
 2 files changed, 6 insertions(+), 1 deletion(-)

Comments

Stephen Finucane Dec. 24, 2015, 1:59 p.m. UTC | #1
On 28 Nov 10:14, Mauro Carvalho Chehab wrote:
> From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> 
> The priority allows sorting delegation rules according to their
> priorities. Higher priority rules will be evaluated first.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

Good idea. Are you OK for me to combine this with patch three (? the
one where this model is created)?

Stephen
Laurent Pinchart Dec. 26, 2015, 11:23 a.m. UTC | #2
Hi Stephen,

On Thursday 24 December 2015 13:59:17 Finucane, Stephen wrote:
> On 28 Nov 10:14, Mauro Carvalho Chehab wrote:
> > From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > 
> > The priority allows sorting delegation rules according to their
> > priorities. Higher priority rules will be evaluated first.
> > 
> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
> 
> Good idea. Are you OK for me to combine this with patch three (? the
> one where this model is created)?

Sure, no problem.
Stephen Finucane Jan. 6, 2016, 5:14 p.m. UTC | #3
On 26 Dec 13:23, Laurent Pinchart wrote:
> Hi Stephen,
> 
> On Thursday 24 December 2015 13:59:17 Finucane, Stephen wrote:
> > On 28 Nov 10:14, Mauro Carvalho Chehab wrote:
> > > From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > > 
> > > The priority allows sorting delegation rules according to their
> > > priorities. Higher priority rules will be evaluated first.
> > > 
> > > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > > Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
> > 
> > Good idea. Are you OK for me to combine this with patch three (? the
> > one where this model is created)?
> 
> Sure, no problem.
> 
> -- 
> Regards,
> 
> Laurent Pinchart

When merged with said patch...

Acked-by: Stephen Finucane <stephen.finucane@intel.com>
diff mbox

Patch

diff --git a/patchwork/admin.py b/patchwork/admin.py
index e05c8bc7cf03..216cdf583968 100644
--- a/patchwork/admin.py
+++ b/patchwork/admin.py
@@ -4,7 +4,7 @@  from patchwork.models import Project, Person, UserProfile, State, Patch, \
 
 class DelegationRuleInline(admin.TabularInline):
     model = DelegationRule
-    fields = ('path', 'user')
+    fields = ('path', 'user', 'priority')
 
 class ProjectAdmin(admin.ModelAdmin):
     list_display = ('name', 'linkname','listid', 'listemail')
diff --git a/patchwork/models.py b/patchwork/models.py
index 1bd9af24b510..101a9af9746f 100644
--- a/patchwork/models.py
+++ b/patchwork/models.py
@@ -82,10 +82,15 @@  class DelegationRule(models.Model):
     user = models.ForeignKey(User)
     path = models.CharField(max_length=255)
     project = models.ForeignKey(Project)
+    priority = models.IntegerField(default = 0)
 
     def __unicode__(self):
         return self.path
 
+    class Meta:
+        ordering = ['-priority', 'path']
+        unique_together = (('path', 'project'))
+
 class UserProfile(models.Model):
     user = models.OneToOneField(User, unique = True, related_name='profile')
     primary_project = models.ForeignKey(Project, null = True, blank = True)