|
@ -298,6 +298,18 @@ create_modeladmin(ProblemZadanyAdmin, Problem, 'ProblemZadany', verbose_name=u'P |
|
|
|
|
|
|
|
|
### Soustredeni |
|
|
### Soustredeni |
|
|
|
|
|
|
|
|
|
|
|
def zverejnit_soustredeni(modeladmin, request, queryset): |
|
|
|
|
|
for soustredeni in queryset: |
|
|
|
|
|
soustredeni.verejne_db = True |
|
|
|
|
|
soustredeni.save() |
|
|
|
|
|
zverejnit_soustredeni.short_description = 'Zveřejnit soustředění' |
|
|
|
|
|
|
|
|
|
|
|
def skryt_soustredeni(modeladmin, request, queryset): |
|
|
|
|
|
for soustredeni in queryset: |
|
|
|
|
|
soustredeni.verejne_db = False |
|
|
|
|
|
soustredeni.save() |
|
|
|
|
|
skryt_soustredeni.short_description = 'Skrýt soustředění (Zneveřjnit)' |
|
|
|
|
|
|
|
|
class SoustredeniAdminForm(forms.ModelForm): |
|
|
class SoustredeniAdminForm(forms.ModelForm): |
|
|
text = forms.CharField(widget=CKEditorWidget(), required=False, **field_labels(Soustredeni, 'text')) |
|
|
text = forms.CharField(widget=CKEditorWidget(), required=False, **field_labels(Soustredeni, 'text')) |
|
|
class Meta: |
|
|
class Meta: |
|
@ -314,6 +326,7 @@ class SoustredeniAdmin(reversion.VersionAdmin): |
|
|
inlines = [Soustredeni_UcastniciInline] |
|
|
inlines = [Soustredeni_UcastniciInline] |
|
|
list_filter = ['rocnik'] |
|
|
list_filter = ['rocnik'] |
|
|
view_on_site = Soustredeni.verejne_url |
|
|
view_on_site = Soustredeni.verejne_url |
|
|
|
|
|
actions = [zverejnit_soustredeni, skryt_soustredeni, ] |
|
|
|
|
|
|
|
|
admin.site.register(Soustredeni, SoustredeniAdmin) |
|
|
admin.site.register(Soustredeni, SoustredeniAdmin) |
|
|
|
|
|
|
|
@ -333,7 +346,41 @@ admin.site.register(Novinky, NovinkyAdmin) |
|
|
|
|
|
|
|
|
### Organizator |
|
|
### Organizator |
|
|
|
|
|
|
|
|
|
|
|
def jmeno_organizatora(obj): |
|
|
|
|
|
''' vraci jmeno organizatora ''' |
|
|
|
|
|
jmeno = obj.user.first_name |
|
|
|
|
|
if obj.prezdivka: |
|
|
|
|
|
jmeno = jmeno + ' "' + obj.prezdivka + '"' |
|
|
|
|
|
jmeno = jmeno + ' ' + obj.user.last_name |
|
|
|
|
|
if jmeno == ' ': # zobrazeni bezejmennych orgu |
|
|
|
|
|
return 'org' |
|
|
|
|
|
return jmeno |
|
|
|
|
|
jmeno_organizatora.short_description = 'Jméno organizátora' |
|
|
|
|
|
|
|
|
|
|
|
def je_organizator_aktivni(obj): |
|
|
|
|
|
''' zjisti, zda-li je organizator aktivni ''' |
|
|
|
|
|
return obj.user.is_active |
|
|
|
|
|
je_organizator_aktivni.short_description = 'Aktivní' |
|
|
|
|
|
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,] |
|
|
|
|
|
actions = [zaktivovat_organizatory, deaktivovat_organizatory,] |
|
|
|
|
|
|
|
|