Browse Source

Admin: změna způsobu zobrazování celého jména

nepadá, ale nepředvyplňuje se
remotes/origin/Float_novinky
Matěj Kocián 9 years ago
parent
commit
1166c88648
  1. 14
      seminar/admin.py

14
seminar/admin.py

@ -8,13 +8,18 @@ from solo.admin import SingletonModelAdmin
from ckeditor.widgets import CKEditorWidget
from django.db.models import Count
from django.db import models
from django.contrib.auth.models import User
from seminar.models import Skola, Resitel, Rocnik, Cislo, Problem, Reseni, PrilohaReseni, Nastaveni, Soustredeni, Soustredeni_Ucastnici, Novinky, Organizator
import autocomplete_light
uzivatele = [(user, u"{} ({})".format(user.get_full_name(), user)) for user in User.objects.filter(is_staff=True)]
uzivatele = [(user, u"{} ()".format(1)) for user in User.objects.filter(is_staff=True)]
print(uzivatele)
class UserModelChoiceField(forms.ModelChoiceField):
def label_from_instance(self, obj):
return u"{} ({})".format(obj.get_full_name(), obj.username)
def predvypln_prihlaseneho(*pole):
u"""Dekorátor pro Adminy. Předvyplní do *polí přihlášeného uživatele.
@ -297,8 +302,8 @@ class ProblemAdminForm(forms.ModelForm):
text_reseni = forms.CharField(widget=CKEditorWidget(), required=False, **field_labels(Problem, 'text_reseni'))
text_org = forms.CharField(widget=CKEditorWidget(), required=False, **field_labels(Problem, 'text_org'))
zamereni = TaggitField(widget=TaggitWidget('TagAutocomplete'), required=False)
autor = forms.ChoiceField(choices=uzivatele)
opravovatel = forms.ChoiceField(choices=uzivatele)
autor = UserModelChoiceField(User.objects.filter(is_staff=True))
opravovatel = UserModelChoiceField(User.objects.filter(is_staff=True))
class Meta:
model = Problem
exclude = []
@ -379,7 +384,8 @@ admin.site.register(Soustredeni, SoustredeniAdmin)
class NovinkyAdminForm(forms.ModelForm):
text = forms.CharField(widget=CKEditorWidget(), required=False,
**field_labels(Novinky, 'text'))
autor = forms.ChoiceField(choices=uzivatele)
autor = UserModelChoiceField(User.objects.filter(is_staff=True))
class Meta:
model = Novinky
exclude = []

Loading…
Cancel
Save