Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 1 | # |
| 2 | # SPDX-License-Identifier: GPL-2.0-only |
| 3 | # |
| 4 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 5 | from django.contrib import admin |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 6 | from orm.models import BitbakeVersion, Release, ToasterSetting, Layer_Version |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 7 | from django import forms |
| 8 | import django.db.models as models |
| 9 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10 | |
| 11 | class BitbakeVersionAdmin(admin.ModelAdmin): |
| 12 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 13 | # we override the formfield for db URLField |
| 14 | # because of broken URL validation |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 15 | |
| 16 | def formfield_for_dbfield(self, db_field, **kwargs): |
| 17 | if isinstance(db_field, models.fields.URLField): |
| 18 | return forms.fields.CharField() |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 19 | return super(BitbakeVersionAdmin, self).formfield_for_dbfield( |
| 20 | db_field, **kwargs) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 21 | |
| 22 | |
| 23 | class ReleaseAdmin(admin.ModelAdmin): |
| 24 | pass |
| 25 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 26 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 27 | class ToasterSettingAdmin(admin.ModelAdmin): |
| 28 | pass |
| 29 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 30 | |
| 31 | class LayerVersionsAdmin(admin.ModelAdmin): |
| 32 | pass |
| 33 | |
| 34 | admin.site.register(Layer_Version, LayerVersionsAdmin) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 35 | admin.site.register(BitbakeVersion, BitbakeVersionAdmin) |
| 36 | admin.site.register(Release, ReleaseAdmin) |
| 37 | admin.site.register(ToasterSetting, ToasterSettingAdmin) |