from django.contrib import admin

from us_ignite.apps.models import (Application, ApplicationURL,
                                   ApplicationImage, Domain, Feature)


class ApplicationURLInline(admin.TabularInline):
    model = ApplicationURL


class ApplicationImageInline(admin.TabularInline):
    model = ApplicationImage


class ApplicationAdmin(admin.ModelAdmin):
    list_display = ('name', 'slug', 'stage', 'status')
    search_fields = ['name', 'slug', 'short_description', 'description']
    list_filter = ['stage', 'status', 'created']
    date_hierarchy = 'created'
    inlines = [ApplicationURLInline, ApplicationImageInline]


class DomainAdmin(admin.ModelAdmin):
    list_display = ('name', 'slug')


class FeatureAdmin(admin. ModelAdmin):
    list_display = ('name', 'slug')

admin.site.register(Application, ApplicationAdmin)
admin.site.register(Domain, DomainAdmin)
admin.site.register(Feature, FeatureAdmin)

from django.contrib import admin

from us_ignite.apps.models import (Application, ApplicationURL,
                                   ApplicationImage, Domain, Feature,
                                   Page, PageApplication)


class ApplicationURLInline(admin.TabularInline):
    model = ApplicationURL


class ApplicationImageInline(admin.TabularInline):
    model = ApplicationImage


class ApplicationAdmin(admin.ModelAdmin):
    list_display = ('name', 'slug', 'stage', 'status')
    search_fields = ['name', 'slug', 'short_description', 'description']
    list_filter = ['stage', 'status', 'created']
    date_hierarchy = 'created'
    inlines = [ApplicationURLInline, ApplicationImageInline]


class DomainAdmin(admin.ModelAdmin):
    list_display = ('name', 'slug')


class FeatureAdmin(admin.ModelAdmin):
    list_display = ('name', 'slug')


class PageApplicationInline(admin.TabularInline):
    raw_id_fields = ('application', )
    model = PageApplication


class PageAdmin(admin.ModelAdmin):
    list_display = ('name', 'slug', 'status', 'created', )
    list_filter = ('status', 'created', )
    date_hierarchy = 'created'
    inlines = [PageApplicationInline]

admin.site.register(Application, ApplicationAdmin)
admin.site.register(Domain, DomainAdmin)
admin.site.register(Feature, FeatureAdmin)
admin.site.register(Page, PageAdmin)

Add admi to add Applications to the Pages.
Add admi to add Applications to the Pages.

https://github.com/madewithbytes/us_ignite/issues/79

The applications can be added to a page and ordered
in the admin.

  from django.contrib import admin
  
  from us_ignite.apps.models import (Application, ApplicationURL,
-                                    ApplicationImage, Domain, Feature)
+                                    ApplicationImage, Domain, Feature,
+                                    Page, PageApplication)
  
  
  class ApplicationURLInline(admin.TabularInline):
      model = ApplicationURL
  
  
  class ApplicationImageInline(admin.TabularInline):
      model = ApplicationImage
  
  
  class ApplicationAdmin(admin.ModelAdmin):
      list_display = ('name', 'slug', 'stage', 'status')
      search_fields = ['name', 'slug', 'short_description', 'description']
      list_filter = ['stage', 'status', 'created']
      date_hierarchy = 'created'
      inlines = [ApplicationURLInline, ApplicationImageInline]
  
  
  class DomainAdmin(admin.ModelAdmin):
      list_display = ('name', 'slug')
  
  
- class FeatureAdmin(admin. ModelAdmin):
+ class FeatureAdmin(admin.ModelAdmin):
      list_display = ('name', 'slug')
+ 
+ 
+ class PageApplicationInline(admin.TabularInline):
+     raw_id_fields = ('application', )
+     model = PageApplication
+ 
+ 
+ class PageAdmin(admin.ModelAdmin):
+     list_display = ('name', 'slug', 'status', 'created', )
+     list_filter = ('status', 'created', )
+     date_hierarchy = 'created'
+     inlines = [PageApplicationInline]
  
  admin.site.register(Application, ApplicationAdmin)
  admin.site.register(Domain, DomainAdmin)
  admin.site.register(Feature, FeatureAdmin)
+ admin.site.register(Page, PageAdmin)
  
Add admi to add Applications to the Pages.
## Code Before:
from django.contrib import admin

from us_ignite.apps.models import (Application, ApplicationURL,
                                   ApplicationImage, Domain, Feature)


class ApplicationURLInline(admin.TabularInline):
    model = ApplicationURL


class ApplicationImageInline(admin.TabularInline):
    model = ApplicationImage


class ApplicationAdmin(admin.ModelAdmin):
    list_display = ('name', 'slug', 'stage', 'status')
    search_fields = ['name', 'slug', 'short_description', 'description']
    list_filter = ['stage', 'status', 'created']
    date_hierarchy = 'created'
    inlines = [ApplicationURLInline, ApplicationImageInline]


class DomainAdmin(admin.ModelAdmin):
    list_display = ('name', 'slug')


class FeatureAdmin(admin. ModelAdmin):
    list_display = ('name', 'slug')

admin.site.register(Application, ApplicationAdmin)
admin.site.register(Domain, DomainAdmin)
admin.site.register(Feature, FeatureAdmin)

## Instruction:
Add admi to add Applications to the Pages.
## Code After:
from django.contrib import admin

from us_ignite.apps.models import (Application, ApplicationURL,
                                   ApplicationImage, Domain, Feature,
                                   Page, PageApplication)


class ApplicationURLInline(admin.TabularInline):
    model = ApplicationURL


class ApplicationImageInline(admin.TabularInline):
    model = ApplicationImage


class ApplicationAdmin(admin.ModelAdmin):
    list_display = ('name', 'slug', 'stage', 'status')
    search_fields = ['name', 'slug', 'short_description', 'description']
    list_filter = ['stage', 'status', 'created']
    date_hierarchy = 'created'
    inlines = [ApplicationURLInline, ApplicationImageInline]


class DomainAdmin(admin.ModelAdmin):
    list_display = ('name', 'slug')


class FeatureAdmin(admin.ModelAdmin):
    list_display = ('name', 'slug')


class PageApplicationInline(admin.TabularInline):
    raw_id_fields = ('application', )
    model = PageApplication


class PageAdmin(admin.ModelAdmin):
    list_display = ('name', 'slug', 'status', 'created', )
    list_filter = ('status', 'created', )
    date_hierarchy = 'created'
    inlines = [PageApplicationInline]

admin.site.register(Application, ApplicationAdmin)
admin.site.register(Domain, DomainAdmin)
admin.site.register(Feature, FeatureAdmin)
admin.site.register(Page, PageAdmin)
