Coupure prévue mardi 3 Août au matin pour maintenance du serveur. Nous faisons au mieux pour que celle-ci soit la plus brève possible.

admin.py 1.89 KB
Newer Older
Janez K's avatar
Janez K committed
1
2
3
4
5
6
7
from workflows.models import Category, AbstractWidget, AbstractInput, AbstractOutput, AbstractOption, Workflow
from django.contrib import admin
from django.forms import TextInput, Textarea
from django.db import models

from orderable_inlines import OrderableTabularInline

8
9
10
11
admin.ModelAdmin.save_as = True; #adds "Save as new" button to all admin interfaces
admin.ModelAdmin.save_on_top = True; #adds admin buttons also on the top of the page
admin.ModelAdmin.search_fields = ['name'] #adds search button on top of admin lists (allways searches by name)

12
class OrderableTabularInlineStyled(OrderableTabularInline):
Janez K's avatar
Janez K committed
13
14
15
    formfield_overrides = {
        models.CharField: {'widget': TextInput(attrs={'size':10})},
        models.TextField: {'widget': Textarea(attrs={'rows':1, 'cols':20})},
16
        }
Janez K's avatar
Janez K committed
17
    orderable_field = 'order'
18
19

class InputInline(OrderableTabularInlineStyled):
Janez K's avatar
Janez K committed
20
21
    model = AbstractInput

22
23
24
25
class CategoryInline(OrderableTabularInlineStyled):
    model = Category

class OutputInline(OrderableTabularInlineStyled):
Janez K's avatar
Janez K committed
26
27
    model = AbstractOutput

28
class AbstractWidgetInline(OrderableTabularInlineStyled):
Janez K's avatar
Janez K committed
29
    model = AbstractWidget
30

Janez K's avatar
Janez K committed
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
class WidgetAdmin(admin.ModelAdmin):
    inlines = [
        InputInline,
        OutputInline,
    ]
    list_display = ('name','category','user')
    
class OptionInline(admin.StackedInline):
    model = AbstractOption
    
class InputAdmin(admin.ModelAdmin):
    inlines = [ OptionInline ]
    
class WorkflowAdmin(admin.ModelAdmin):
    list_display = ('name','user','public')
    
class CategoryAdmin(admin.ModelAdmin):
    list_display = ('name','user')
49
50
51
52
    inlines = [
        AbstractWidgetInline,
        CategoryInline
    ]
Janez K's avatar
Janez K committed
53
54
55
56
57
58
59

#admin.site.register(UserProfile)
admin.site.register(Category,CategoryAdmin)
admin.site.register(AbstractWidget,WidgetAdmin)
admin.site.register(AbstractInput,InputAdmin)
admin.site.register(Workflow, WorkflowAdmin)
#admin.site.register(AbstractOutput)