diff options
-rw-r--r-- | bitbake/lib/toaster/orm/models.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/bitbake/lib/toaster/orm/models.py b/bitbake/lib/toaster/orm/models.py index bb018a9819..30599088e5 100644 --- a/bitbake/lib/toaster/orm/models.py +++ b/bitbake/lib/toaster/orm/models.py | |||
@@ -20,6 +20,7 @@ | |||
20 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | 20 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
21 | 21 | ||
22 | from django.db import models | 22 | from django.db import models |
23 | from django.db.models import F | ||
23 | from django.utils.encoding import python_2_unicode_compatible | 24 | from django.utils.encoding import python_2_unicode_compatible |
24 | 25 | ||
25 | 26 | ||
@@ -211,6 +212,12 @@ class Package(models.Model): | |||
211 | section = models.CharField(max_length=80, blank=True) | 212 | section = models.CharField(max_length=80, blank=True) |
212 | license = models.CharField(max_length=80, blank=True) | 213 | license = models.CharField(max_length=80, blank=True) |
213 | 214 | ||
215 | class Package_DependencyManager(models.Manager): | ||
216 | use_for_related_fields = True | ||
217 | |||
218 | def get_query_set(self): | ||
219 | return super(Package_DependencyManager, self).get_query_set().exclude(package_id = F('depends_on__id')) | ||
220 | |||
214 | class Package_Dependency(models.Model): | 221 | class Package_Dependency(models.Model): |
215 | TYPE_RDEPENDS = 0 | 222 | TYPE_RDEPENDS = 0 |
216 | TYPE_TRDEPENDS = 1 | 223 | TYPE_TRDEPENDS = 1 |
@@ -250,6 +257,7 @@ class Package_Dependency(models.Model): | |||
250 | depends_on = models.ForeignKey(Package, related_name='package_dependencies_target') # soft dependency | 257 | depends_on = models.ForeignKey(Package, related_name='package_dependencies_target') # soft dependency |
251 | dep_type = models.IntegerField(choices=DEPENDS_TYPE) | 258 | dep_type = models.IntegerField(choices=DEPENDS_TYPE) |
252 | target = models.ForeignKey(Target, null=True) | 259 | target = models.ForeignKey(Target, null=True) |
260 | objects = Package_DependencyManager() | ||
253 | 261 | ||
254 | class Target_Installed_Package(models.Model): | 262 | class Target_Installed_Package(models.Model): |
255 | target = models.ForeignKey(Target) | 263 | target = models.ForeignKey(Target) |
@@ -273,6 +281,11 @@ class Recipe(models.Model): | |||
273 | bugtracker = models.URLField(blank=True) | 281 | bugtracker = models.URLField(blank=True) |
274 | file_path = models.FilePathField(max_length=255) | 282 | file_path = models.FilePathField(max_length=255) |
275 | 283 | ||
284 | class Recipe_DependencyManager(models.Manager): | ||
285 | use_for_related_fields = True | ||
286 | |||
287 | def get_query_set(self): | ||
288 | return super(Recipe_DependencyManager, self).get_query_set().exclude(recipe_id = F('depends_on__id')) | ||
276 | 289 | ||
277 | class Recipe_Dependency(models.Model): | 290 | class Recipe_Dependency(models.Model): |
278 | TYPE_DEPENDS = 0 | 291 | TYPE_DEPENDS = 0 |
@@ -285,6 +298,7 @@ class Recipe_Dependency(models.Model): | |||
285 | recipe = models.ForeignKey(Recipe, related_name='r_dependencies_recipe') | 298 | recipe = models.ForeignKey(Recipe, related_name='r_dependencies_recipe') |
286 | depends_on = models.ForeignKey(Recipe, related_name='r_dependencies_depends') | 299 | depends_on = models.ForeignKey(Recipe, related_name='r_dependencies_depends') |
287 | dep_type = models.IntegerField(choices=DEPENDS_TYPE) | 300 | dep_type = models.IntegerField(choices=DEPENDS_TYPE) |
301 | objects = Recipe_DependencyManager() | ||
288 | 302 | ||
289 | class Layer(models.Model): | 303 | class Layer(models.Model): |
290 | name = models.CharField(max_length=100) | 304 | name = models.CharField(max_length=100) |