admin.py 1.72 KB
Newer Older
1 2
from django.contrib import admin

3 4
from partners.models import (Partner, PartnerEvent, PartnerImage,
                             Vacancy, VacancyCategory)
5 6
from utils.translation import TranslatedModelAdmin

7 8 9 10 11 12 13 14

class PartnerImageInline(admin.StackedInline):
    model = PartnerImage


@admin.register(Partner)
class PartnerAdmin(admin.ModelAdmin):
    prepopulated_fields = {"slug": ("name",)}
15 16
    list_display = ('name', 'is_active', 'is_main_partner',)
    inlines = (PartnerImageInline,)
17 18 19 20 21 22 23 24 25 26 27 28 29 30

    fieldsets = (
        (None, {
            'fields': (
                'is_active', 'is_main_partner', 'name', 'slug', 'link',
                'company_profile', 'logo', 'site_header'
            )
        }),
        ('Address', {
            'fields': ('address', 'zip_code', 'city')

        }),
    )

31 32 33 34 35

@admin.register(VacancyCategory)
class VacancyCategoryAdmin(TranslatedModelAdmin):
    prepopulated_fields = {"slug": ("name_en",)}
    fields = ['name', 'slug']
36 37 38 39


@admin.register(Vacancy)
class VacancyAdmin(admin.ModelAdmin):
40 41
    list_display = ('title', 'partner', 'company_name',)

42 43 44 45 46 47 48 49 50 51 52 53 54 55
    fieldsets = (
        (None, {
            'fields': ('title', 'description', 'link')
        }),
        ('Existing Partner', {
            'fields': ('partner',)
        }),
        ('Other Partner', {
            'fields': ('company_name', 'company_logo',)
        }),
        ('Categories', {
            'fields': ('categories', )
        }),
    )
56 57 58 59 60 61 62 63 64


@admin.register(PartnerEvent)
class PartnerEventAdmin(TranslatedModelAdmin):
    fields = ['partner', 'title', 'description', 'location', 'start', 'end',
              'url', 'published']
    list_display = ('title', 'start', 'end',
                    'partner', 'published')
    list_filter = ('start', 'published')