From a0660718e6599538dd65cadadbc04c6adc951b57 Mon Sep 17 00:00:00 2001 From: Alexandru DAMIAN Date: Thu, 9 Oct 2014 12:37:30 +0100 Subject: bitbake: toaster: improvements for admin pages The default django URL validator marks git URLs as not valid, so we change the default validators to a URLValidator-derived that adds git and ssh protocol schemas and inhibits the frontend URL validator. We update the branch names based on the white-listed branch names in the Releases name. Adds proper class string to ease usage in admin section. Other small improvements. (Bitbake rev: 7d51f895bd56bd18f2258059b377851c2ce82114) Signed-off-by: Alexandru DAMIAN Conflicts: bitbake/lib/toaster/orm/admin.py Signed-off-by: Richard Purdie --- bitbake/lib/toaster/orm/models.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'bitbake/lib/toaster/orm/models.py') diff --git a/bitbake/lib/toaster/orm/models.py b/bitbake/lib/toaster/orm/models.py index 309f8ea5be..2fd504cb5b 100644 --- a/bitbake/lib/toaster/orm/models.py +++ b/bitbake/lib/toaster/orm/models.py @@ -51,6 +51,9 @@ class ToasterSetting(models.Model): helptext = models.TextField() value = models.CharField(max_length=255) + def __unicode__(self): + return "Setting %s" % self.name + class ToasterSettingDefaultLayer(models.Model): layer_version = models.ForeignKey('Layer_Version') @@ -347,7 +350,7 @@ class Package(models.Model): installed_name = models.CharField(max_length=100, default='') version = models.CharField(max_length=100, blank=True) revision = models.CharField(max_length=32, blank=True) - summary = models.CharField(max_length=200, blank=True) + summary = models.TextField(blank=True) description = models.TextField(blank=True) size = models.IntegerField(default=0) installed_size = models.IntegerField(default=0) @@ -420,7 +423,7 @@ class Recipe(models.Model): name = models.CharField(max_length=100, blank=True) # pn version = models.CharField(max_length=100, blank=True) # pv layer_version = models.ForeignKey('Layer_Version', related_name='recipe_layer_version') - summary = models.CharField(max_length=100, blank=True) + summary = models.TextField(blank=True) description = models.TextField(blank=True) section = models.CharField(max_length=100, blank=True) license = models.CharField(max_length=200, blank=True) @@ -585,8 +588,8 @@ class LayerIndexLayerSource(LayerSource): print "EE: could not connect to %s, skipping update: %s\n%s" % (self.apiurl, e, traceback.format_exc(e)) return - # update branches; only those that we already have names listed in the database - whitelist_branch_names = map(lambda x: x.name, Branch.objects.all()) + # update branches; only those that we already have names listed in the Releases table + whitelist_branch_names = map(lambda x: x.branch, Release.objects.all()) branches_info = _get_json_response(apilinks['branches'] + "?filter=name:%s" % "OR".join(whitelist_branch_names)) @@ -667,7 +670,7 @@ class LayerIndexLayerSource(LayerSource): + "?filter=layerbranch:%s" % "OR".join(map(lambda x: str(x.up_id), Layer_Version.objects.filter(layer_source = self))) ) for ri in recipes_info: - ro, created = Recipe.objects.get_or_create(layer_source = self, up_id = ri['id'], layer_version = Layer_Version.objects.get(layer_source = self, up_id = mi['layerbranch'])) + ro, created = Recipe.objects.get_or_create(layer_source = self, up_id = ri['id'], layer_version = Layer_Version.objects.get(layer_source = self, up_id = ri['layerbranch'])) ro.up_date = ri['updated'] @@ -691,6 +694,9 @@ class BitbakeVersion(models.Model): branch = models.CharField(max_length=32) dirpath = models.CharField(max_length=255) + def __unicode__(self): + return "%s (%s)" % (self.name, self.branch) + class Release(models.Model): name = models.CharField(max_length=32, unique = True) @@ -734,7 +740,7 @@ class Layer(models.Model): vcs_url = GitURLField(default = None, null = True) vcs_web_file_base_url = models.URLField(null = True, default = None) - summary = models.CharField(max_length=200, help_text='One-line description of the layer', null = True, default = None) + summary = models.TextField(help_text='One-line description of the layer', null = True, default = None) description = models.TextField(null = True, default = None) def __unicode__(self): -- cgit v1.2.3-54-g00ecf