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