Tomas "Jethro" Pokorny
8 years ago
7 changed files with 206 additions and 34 deletions
@ -1,16 +1,59 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
from django.contrib import admin |
from django.contrib import admin |
||||
|
from django.contrib import messages |
||||
|
from django import forms |
||||
from reversion.admin import VersionAdmin |
from reversion.admin import VersionAdmin |
||||
|
from autocomplete_light import shortcuts as autocomplete_light |
||||
|
from django.db import models |
||||
|
|
||||
from models import Prednaska, Hlasovani |
from models import Prednaska, Seznam, STAV_NAVRH |
||||
|
from seminar.models import Soustredeni |
||||
|
|
||||
|
class Seznam_PrednaskaInline(admin.TabularInline): |
||||
|
# form = autocomplete_light.modelform_factory(Prednaska, autocomplete_fields=['nazev'], fields=['nazev']) |
||||
|
model = Prednaska.seznamy.through |
||||
|
# fields = ['nazev', 'org', 'obor' ] |
||||
|
# extra = 0 |
||||
|
# formfield_overrides = { |
||||
|
# models.TextField: {'widget': forms.TextInput}, |
||||
|
# } |
||||
|
|
||||
|
# def get_queryset(self, request): |
||||
|
# qs = super(Seznam_PrednaskaInline, self).get_queryset(request) |
||||
|
# return qs.select_related('seznam', 'prednaska') |
||||
|
|
||||
|
class SeznamAdmin(VersionAdmin): |
||||
|
list_display = ['soustredeni','stav'] |
||||
|
inlines = [Seznam_PrednaskaInline] |
||||
|
|
||||
|
admin.site.register(Seznam,SeznamAdmin) |
||||
|
|
||||
admin.site.register(Hlasovani) |
|
||||
|
|
||||
class PrednaskaAdmin(VersionAdmin): |
class PrednaskaAdmin(VersionAdmin): |
||||
# fieldsets = [ |
list_display = ['nazev', 'org', 'obor'] |
||||
# (None, {'fields': ['pdf', 'cas', 'stran', 'nazev', 'komentar']}), |
list_filter = ['org','obor'] |
||||
# ] |
search_fields = [] |
||||
list_display = ['nazev', 'org', 'obor'] |
|
||||
list_filter = ['org','obor'] |
actions = ['move_to_soustredeni'] |
||||
search_fields = [] |
|
||||
|
def move_to_soustredeni(self,request,queryset): |
||||
|
sous = Soustredeni.objects.first() |
||||
|
seznam = Seznam.objects.filter(soustredeni=sous,stav=STAV_NAVRH) |
||||
|
if len(seznam) == 0: |
||||
|
self.message_user(request,u"Není definován seznam pro aktuální soustředění, nic se neprovedlo",messages.ERROR) |
||||
|
return |
||||
|
seznam = seznam[0] |
||||
|
for prednaska in queryset: |
||||
|
prednaska.seznamy.add(seznam) |
||||
|
prednaska.save() |
||||
|
|
||||
|
self.message_user(request,u"Vybrané přednášky ({}) přidány jako návrhy na nejbližší soustředění".format(len(queryset))) |
||||
|
|
||||
|
move_to_soustredeni.short_description=u"Přidat přednášky do návrhu na nejbližší soustředění" |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
admin.site.register(Prednaska,PrednaskaAdmin) |
admin.site.register(Prednaska,PrednaskaAdmin) |
||||
|
@ -0,0 +1,20 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
from __future__ import unicode_literals |
||||
|
|
||||
|
from django.db import migrations, models |
||||
|
|
||||
|
|
||||
|
class Migration(migrations.Migration): |
||||
|
|
||||
|
dependencies = [ |
||||
|
('prednasky', '0005_auto_20160929_0153'), |
||||
|
] |
||||
|
|
||||
|
operations = [ |
||||
|
migrations.AddField( |
||||
|
model_name='hlasovani', |
||||
|
name='seznam', |
||||
|
field=models.ForeignKey(default=1, to='prednasky.Seznam'), |
||||
|
preserve_default=False, |
||||
|
), |
||||
|
] |
@ -0,0 +1,19 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
from __future__ import unicode_literals |
||||
|
|
||||
|
from django.db import migrations, models |
||||
|
|
||||
|
|
||||
|
class Migration(migrations.Migration): |
||||
|
|
||||
|
dependencies = [ |
||||
|
('prednasky', '0006_hlasovani_seznam'), |
||||
|
] |
||||
|
|
||||
|
operations = [ |
||||
|
migrations.AddField( |
||||
|
model_name='prednaska', |
||||
|
name='seznamy', |
||||
|
field=models.ManyToManyField(to='prednasky.Seznam'), |
||||
|
), |
||||
|
] |
@ -0,0 +1,25 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
from __future__ import unicode_literals |
||||
|
|
||||
|
from django.db import migrations, models |
||||
|
|
||||
|
|
||||
|
class Migration(migrations.Migration): |
||||
|
|
||||
|
dependencies = [ |
||||
|
('prednasky', '0007_prednaska_seznamy'), |
||||
|
] |
||||
|
|
||||
|
operations = [ |
||||
|
migrations.RemoveField( |
||||
|
model_name='prednaska_seznam', |
||||
|
name='prednaska', |
||||
|
), |
||||
|
migrations.RemoveField( |
||||
|
model_name='prednaska_seznam', |
||||
|
name='seznam', |
||||
|
), |
||||
|
migrations.DeleteModel( |
||||
|
name='Prednaska_Seznam', |
||||
|
), |
||||
|
] |
@ -0,0 +1,49 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
from __future__ import unicode_literals |
||||
|
|
||||
|
from django.db import migrations, models |
||||
|
|
||||
|
|
||||
|
class Migration(migrations.Migration): |
||||
|
|
||||
|
dependencies = [ |
||||
|
('prednasky', '0008_auto_20160929_0225'), |
||||
|
] |
||||
|
|
||||
|
operations = [ |
||||
|
migrations.AlterField( |
||||
|
model_name='prednaska', |
||||
|
name='anotace', |
||||
|
field=models.TextField(help_text='Ve\u0159ejn\xe1 anotace v hlasov\xe1n\xed', null=True, verbose_name=b'Anotace'), |
||||
|
), |
||||
|
migrations.AlterField( |
||||
|
model_name='prednaska', |
||||
|
name='klicova', |
||||
|
field=models.CharField(max_length=200, null=True, verbose_name='Kl\xed\u010dov\xe1 slova', blank=True), |
||||
|
), |
||||
|
migrations.AlterField( |
||||
|
model_name='prednaska', |
||||
|
name='nazev', |
||||
|
field=models.CharField(max_length=300, verbose_name='N\xe1zev'), |
||||
|
), |
||||
|
migrations.AlterField( |
||||
|
model_name='prednaska', |
||||
|
name='obor', |
||||
|
field=models.CharField(help_text='Podmno\u017eina MFIOB', max_length=5, verbose_name='Obor'), |
||||
|
), |
||||
|
migrations.AlterField( |
||||
|
model_name='prednaska', |
||||
|
name='obtiznost', |
||||
|
field=models.IntegerField(verbose_name='Obt\xed\u017enost', choices=[(1, b'Lehk\xc3\xa1'), (2, b'St\xc5\x99edn\xc3\xad'), (3, b'T\xc4\x9b\xc5\xbek\xc3\xa1')]), |
||||
|
), |
||||
|
migrations.AlterField( |
||||
|
model_name='prednaska', |
||||
|
name='popis', |
||||
|
field=models.TextField(help_text='Neve\u0159ejn\xfd popis pro ostatn\xed orgy', null=True, verbose_name='Popis pro orgy'), |
||||
|
), |
||||
|
migrations.AlterField( |
||||
|
model_name='seznam', |
||||
|
name='stav', |
||||
|
field=models.IntegerField(default=1, verbose_name=b'Stav', choices=[(1, b'N\xc3\xa1vrh'), (2, b'Bude')]), |
||||
|
), |
||||
|
] |
Loading…
Reference in new issue