|
@ -347,17 +347,35 @@ admin.site.register(Novinky, NovinkyAdmin) |
|
|
### Organizator |
|
|
### Organizator |
|
|
|
|
|
|
|
|
def jmeno_organizatora(obj): |
|
|
def jmeno_organizatora(obj): |
|
|
|
|
|
''' vraci jmeno organizatora ''' |
|
|
return ('%s \"%s\" %s' % |
|
|
return ('%s \"%s\" %s' % |
|
|
(obj.user.first_name, obj.prezdivka, obj.user.last_name)) |
|
|
(obj.user.first_name, obj.prezdivka, obj.user.last_name)) |
|
|
jmeno_organizatora.short_description = 'Jméno organizátora' |
|
|
jmeno_organizatora.short_description = 'Jméno organizátora' |
|
|
|
|
|
|
|
|
def je_organizator_aktivni(obj): |
|
|
def je_organizator_aktivni(obj): |
|
|
|
|
|
''' zjisti, zda-li je organizator aktivni ''' |
|
|
return obj.user.is_active |
|
|
return obj.user.is_active |
|
|
je_organizator_aktivni.short_description = 'Aktivní' |
|
|
je_organizator_aktivni.short_description = 'Aktivní' |
|
|
je_organizator_aktivni.boolean = True |
|
|
je_organizator_aktivni.boolean = True |
|
|
|
|
|
|
|
|
|
|
|
def zaktivovat_organizatory(modeladmin, request, queryset): |
|
|
|
|
|
''' vybrane organizatory oznaci jako aktivni ''' |
|
|
|
|
|
for org in queryset: |
|
|
|
|
|
org.user.is_active = True |
|
|
|
|
|
org.user.save() |
|
|
|
|
|
zaktivovat_organizatory.short_description = 'Zaktivovat organizátory' |
|
|
|
|
|
|
|
|
|
|
|
def deaktivovat_organizatory(modeladmin, request, queryset): |
|
|
|
|
|
''' deaktivuje vybrane organizatory ''' |
|
|
|
|
|
for org in queryset: |
|
|
|
|
|
org.user.is_active = False |
|
|
|
|
|
org.user.save() |
|
|
|
|
|
deaktivovat_organizatory.short_description = 'Deaktivovat organizátory' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@admin.register(Organizator) |
|
|
@admin.register(Organizator) |
|
|
class OrganizatorAdmin(admin.ModelAdmin): |
|
|
class OrganizatorAdmin(admin.ModelAdmin): |
|
|
list_filter = ['organizuje_do_roku'] |
|
|
list_filter = ['organizuje_do_roku'] |
|
|
list_display = [jmeno_organizatora, je_organizator_aktivni,] |
|
|
list_display = [jmeno_organizatora, je_organizator_aktivni,] |
|
|
|
|
|
actions = [zaktivovat_organizatory, deaktivovat_organizatory,] |
|
|
|
|
|
|
|
|