initial commit.
This commit is contained in:
39
beer/admin.py
Normal file
39
beer/admin.py
Normal file
@ -0,0 +1,39 @@
|
||||
from django.contrib import admin
|
||||
from django.urls import reverse
|
||||
from django.utils.html import format_html
|
||||
|
||||
from beer.models import Batch, Recipe, BatchRecipe
|
||||
from yeast.models import Yeast
|
||||
|
||||
from config.extras import BREWFATHER_APP_ROOT
|
||||
|
||||
import logging
|
||||
logger = logging.getLogger('django')
|
||||
|
||||
|
||||
class SampleInline(admin.TabularInline):
|
||||
model = Yeast
|
||||
extra = 0
|
||||
|
||||
class RecipeAdmin(admin.ModelAdmin):
|
||||
list_display = ['name']
|
||||
|
||||
class BatchRecipeAdmin(admin.ModelAdmin):
|
||||
list_display = ['name']
|
||||
|
||||
class BeerBatchAdmin(admin.ModelAdmin):
|
||||
list_display = ['brewfather_id', 'batch_url']
|
||||
inlines = [
|
||||
SampleInline,
|
||||
]
|
||||
|
||||
url_string = "<a href='{root}/tabs/batches/batch/{batch_id}'>Brewfather Batch ID: {batch_id}</a>"
|
||||
|
||||
def batch_url(self, obj):
|
||||
bf_id = obj.brewfather_id
|
||||
return format_html("<a href='{root}/tabs/batches/batch/{batch_id}'>Brewfather App: {batch_id}</a>", batch_id=bf_id, root=BREWFATHER_APP_ROOT)
|
||||
|
||||
|
||||
admin.site.register(Batch, BeerBatchAdmin)
|
||||
admin.site.register(Recipe, RecipeAdmin)
|
||||
admin.site.register(BatchRecipe, BatchRecipeAdmin)
|
Reference in New Issue
Block a user