Add Positional Arguments to Get Next/Previous
Added filter_args array argument to be passed to get_next/previous methods. Added extra boolean fields to project model for testing.
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 2.1 on 2018-10-06 12:57
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('samples', '0002_auto_20180319_2117'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='project',
|
||||
name='isApproved',
|
||||
field=models.BooleanField(default=False),
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 2.1 on 2018-10-06 13:01
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('samples', '0003_project_isapproved'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='project',
|
||||
name='isFunded',
|
||||
field=models.BooleanField(default=False),
|
||||
),
|
||||
]
|
||||
@@ -49,9 +49,15 @@ class Project(SimpleModel, SortableMixin):
|
||||
|
||||
category = SortableForeignKey(Category, on_delete=models.CASCADE)
|
||||
description = models.TextField()
|
||||
isApproved = models.BooleanField(default=False)
|
||||
isFunded = models.BooleanField(default=False)
|
||||
|
||||
order = models.PositiveIntegerField(default=0, editable=False)
|
||||
|
||||
def get_next(self):
|
||||
return super(Project, self).get_next(
|
||||
filter_args=[models.Q(isApproved=True) | models.Q(isFunded=True)])
|
||||
|
||||
|
||||
# Registered as a tabular inline on `Project`
|
||||
@python_2_unicode_compatible
|
||||
|
||||
Reference in New Issue
Block a user