|
@ -8,13 +8,18 @@ from solo.admin import SingletonModelAdmin |
|
|
from ckeditor.widgets import CKEditorWidget |
|
|
from ckeditor.widgets import CKEditorWidget |
|
|
from django.db.models import Count |
|
|
from django.db.models import Count |
|
|
from django.db import models |
|
|
from django.db import models |
|
|
|
|
|
|
|
|
from django.contrib.auth.models import User |
|
|
from django.contrib.auth.models import User |
|
|
|
|
|
|
|
|
from seminar.models import Skola, Resitel, Rocnik, Cislo, Problem, Reseni, PrilohaReseni, Nastaveni, Soustredeni, Soustredeni_Ucastnici, Novinky, Organizator |
|
|
from seminar.models import Skola, Resitel, Rocnik, Cislo, Problem, Reseni, PrilohaReseni, Nastaveni, Soustredeni, Soustredeni_Ucastnici, Novinky, Organizator |
|
|
import autocomplete_light |
|
|
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): |
|
|
def predvypln_prihlaseneho(*pole): |
|
|
u"""Dekorátor pro Adminy. Předvyplní do *polí přihlášeného uživatele. |
|
|
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_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')) |
|
|
text_org = forms.CharField(widget=CKEditorWidget(), required=False, **field_labels(Problem, 'text_org')) |
|
|
zamereni = TaggitField(widget=TaggitWidget('TagAutocomplete'), required=False) |
|
|
zamereni = TaggitField(widget=TaggitWidget('TagAutocomplete'), required=False) |
|
|
autor = forms.ChoiceField(choices=uzivatele) |
|
|
autor = UserModelChoiceField(User.objects.filter(is_staff=True)) |
|
|
opravovatel = forms.ChoiceField(choices=uzivatele) |
|
|
opravovatel = UserModelChoiceField(User.objects.filter(is_staff=True)) |
|
|
class Meta: |
|
|
class Meta: |
|
|
model = Problem |
|
|
model = Problem |
|
|
exclude = [] |
|
|
exclude = [] |
|
@ -379,7 +384,8 @@ admin.site.register(Soustredeni, SoustredeniAdmin) |
|
|
class NovinkyAdminForm(forms.ModelForm): |
|
|
class NovinkyAdminForm(forms.ModelForm): |
|
|
text = forms.CharField(widget=CKEditorWidget(), required=False, |
|
|
text = forms.CharField(widget=CKEditorWidget(), required=False, |
|
|
**field_labels(Novinky, 'text')) |
|
|
**field_labels(Novinky, 'text')) |
|
|
autor = forms.ChoiceField(choices=uzivatele) |
|
|
autor = UserModelChoiceField(User.objects.filter(is_staff=True)) |
|
|
|
|
|
|
|
|
class Meta: |
|
|
class Meta: |
|
|
model = Novinky |
|
|
model = Novinky |
|
|
exclude = [] |
|
|
exclude = [] |
|
|