Merge branch 'master' into stable
This commit is contained in:
		
						commit
						d443c8887b
					
				
					 12 changed files with 411 additions and 18 deletions
				
			
		|  | @ -3,4 +3,20 @@ | ||||||
| # Git hook script to verify what is about to be committed. | # Git hook script to verify what is about to be committed. | ||||||
| # Checks that the changes don't introduce new flake8 errors. | # Checks that the changes don't introduce new flake8 errors. | ||||||
| 
 | 
 | ||||||
| git diff --unified=1 --cached HEAD -- '*py' | flake8 --diff | TMPDIFF=`tempfile` | ||||||
|  | FLAKE8="`git rev-parse --show-toplevel`/bin/flake8" | ||||||
|  | 
 | ||||||
|  | status=0 | ||||||
|  | 
 | ||||||
|  | git diff --unified=1 --cached HEAD -- '*py' > $TMPDIFF | ||||||
|  | 
 | ||||||
|  | # only do the check when there are some changes to be commited | ||||||
|  | # otherwise flake8 would hang waiting for input | ||||||
|  | if [ -s $TMPDIFF ] ; then | ||||||
|  |     cat $TMPDIFF | $FLAKE8 --diff | ||||||
|  |     status=$? | ||||||
|  | fi | ||||||
|  | 
 | ||||||
|  | rm -f $TMPDIFF | ||||||
|  | 
 | ||||||
|  | exit $status | ||||||
|  |  | ||||||
|  | @ -1,7 +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 autocomplete_light import shortcuts as autocomplete_light | ||||||
|  | from django.db import models | ||||||
| 
 | 
 | ||||||
| from models import Prednaska, Seznam, Hlasovani | from models import Prednaska, Seznam, STAV_NAVRH | ||||||
|  | from seminar.models import Soustredeni | ||||||
| 
 | 
 | ||||||
| admin.site.register(Seznam) | class Seznam_PrednaskaInline(admin.TabularInline): | ||||||
| admin.site.register(Prednaska) | #    form = autocomplete_light.modelform_factory(Prednaska, autocomplete_fields=['nazev'], fields=['nazev']) | ||||||
| admin.site.register(Hlasovani) |     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) | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | class PrednaskaAdmin(VersionAdmin): | ||||||
|  |     list_display = ['nazev', 'org', 'obor'] | ||||||
|  |     list_filter = ['org','obor'] | ||||||
|  |     search_fields = [] | ||||||
|  |      | ||||||
|  |     actions = ['move_to_soustredeni'] | ||||||
|  | 
 | ||||||
|  |     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) | ||||||
|  |  | ||||||
							
								
								
									
										64
									
								
								prednasky/migrations/0003_auto_20160929_0117.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										64
									
								
								prednasky/migrations/0003_auto_20160929_0117.py
									
									
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,64 @@ | ||||||
|  | # -*- coding: utf-8 -*- | ||||||
|  | from __future__ import unicode_literals | ||||||
|  | 
 | ||||||
|  | from django.db import migrations, models | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | class Migration(migrations.Migration): | ||||||
|  | 
 | ||||||
|  |     dependencies = [ | ||||||
|  |         ('prednasky', '0002_auto_20160417_2347'), | ||||||
|  |     ] | ||||||
|  | 
 | ||||||
|  |     operations = [ | ||||||
|  |         migrations.RenameModel( | ||||||
|  |             old_name='Seznam', | ||||||
|  |             new_name='Seznam_old', | ||||||
|  |         ), | ||||||
|  |         migrations.AlterModelOptions( | ||||||
|  |             name='hlasovani', | ||||||
|  |             options={'ordering': ['ucastnik', 'prednaska'], 'verbose_name': 'Hlasov\xe1n\xed', 'verbose_name_plural': 'Hlasov\xe1n\xed'}, | ||||||
|  |         ), | ||||||
|  |         migrations.AlterModelOptions( | ||||||
|  |             name='prednaska', | ||||||
|  |             options={'ordering': ['org', 'nazev'], 'verbose_name': 'P\u0159edn\xe1\u0161ka', 'verbose_name_plural': 'P\u0159edn\xe1\u0161ky'}, | ||||||
|  |         ), | ||||||
|  |         migrations.AddField( | ||||||
|  |             model_name='prednaska', | ||||||
|  |             name='popis', | ||||||
|  |             field=models.TextField(help_text=b'Neve\xc5\x99ejn\xc3\xbd popis pro ostatn\xc3\xad orgy', null=True, verbose_name=b'Popis pro orgy'), | ||||||
|  |         ), | ||||||
|  |         migrations.AlterField( | ||||||
|  |             model_name='hlasovani', | ||||||
|  |             name='id', | ||||||
|  |             field=models.AutoField(serialize=False, primary_key=True), | ||||||
|  |         ), | ||||||
|  |         migrations.AlterField( | ||||||
|  |             model_name='prednaska', | ||||||
|  |             name='anotace', | ||||||
|  |             field=models.TextField(help_text=b'Ve\xc5\x99ejn\xc3\xa1 anotace v hlasov\xc3\xa1n\xc3\xad', null=True, verbose_name=b'Anotace'), | ||||||
|  |         ), | ||||||
|  |         migrations.AlterField( | ||||||
|  |             model_name='prednaska', | ||||||
|  |             name='id', | ||||||
|  |             field=models.AutoField(serialize=False, primary_key=True), | ||||||
|  |         ), | ||||||
|  |         migrations.AlterField( | ||||||
|  |             model_name='prednaska', | ||||||
|  |             name='obor', | ||||||
|  |             field=models.CharField(help_text=b'Podmno\xc5\xbeina MFIOB', max_length=5, verbose_name=b'Obor'), | ||||||
|  |         ), | ||||||
|  |         migrations.AlterField( | ||||||
|  |             model_name='prednaska', | ||||||
|  |             name='seznam', | ||||||
|  |             field=models.ForeignKey(to='prednasky.Seznam_old'), | ||||||
|  |         ), | ||||||
|  |         migrations.AlterModelTable( | ||||||
|  |             name='hlasovani', | ||||||
|  |             table='prednasky_hlasovani', | ||||||
|  |         ), | ||||||
|  |         migrations.AlterModelTable( | ||||||
|  |             name='prednaska', | ||||||
|  |             table='prednasky_prednaska', | ||||||
|  |         ), | ||||||
|  |     ] | ||||||
							
								
								
									
										18
									
								
								prednasky/migrations/0004_remove_prednaska_seznam.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								prednasky/migrations/0004_remove_prednaska_seznam.py
									
									
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,18 @@ | ||||||
|  | # -*- coding: utf-8 -*- | ||||||
|  | from __future__ import unicode_literals | ||||||
|  | 
 | ||||||
|  | from django.db import migrations, models | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | class Migration(migrations.Migration): | ||||||
|  | 
 | ||||||
|  |     dependencies = [ | ||||||
|  |         ('prednasky', '0003_auto_20160929_0117'), | ||||||
|  |     ] | ||||||
|  | 
 | ||||||
|  |     operations = [ | ||||||
|  |         migrations.RemoveField( | ||||||
|  |             model_name='prednaska', | ||||||
|  |             name='seznam', | ||||||
|  |         ), | ||||||
|  |     ] | ||||||
							
								
								
									
										49
									
								
								prednasky/migrations/0005_auto_20160929_0153.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										49
									
								
								prednasky/migrations/0005_auto_20160929_0153.py
									
									
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,49 @@ | ||||||
|  | # -*- coding: utf-8 -*- | ||||||
|  | from __future__ import unicode_literals | ||||||
|  | 
 | ||||||
|  | from django.db import migrations, models | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | class Migration(migrations.Migration): | ||||||
|  | 
 | ||||||
|  |     dependencies = [ | ||||||
|  |         ('seminar', '0041_konfery'), | ||||||
|  |         ('prednasky', '0004_remove_prednaska_seznam'), | ||||||
|  |     ] | ||||||
|  | 
 | ||||||
|  |     operations = [ | ||||||
|  |         migrations.CreateModel( | ||||||
|  |             name='Prednaska_Seznam', | ||||||
|  |             fields=[ | ||||||
|  |                 ('id', models.AutoField(serialize=False, primary_key=True)), | ||||||
|  |                 ('prednaska', models.ForeignKey(to='prednasky.Prednaska')), | ||||||
|  |             ], | ||||||
|  |             options={ | ||||||
|  |                 'db_table': 'prednasky_prednaska_seznam', | ||||||
|  |                 'verbose_name': 'P\u0159edn\xe1\u0161ka v seznamu', | ||||||
|  |                 'verbose_name_plural': 'P\u0159edn\xe1\u0161ky v seznamech', | ||||||
|  |             }, | ||||||
|  |         ), | ||||||
|  |         migrations.CreateModel( | ||||||
|  |             name='Seznam', | ||||||
|  |             fields=[ | ||||||
|  |                 ('id', models.AutoField(serialize=False, primary_key=True)), | ||||||
|  |                 ('stav', models.IntegerField(default=2, verbose_name=b'Stav', choices=[(1, b'N\xc3\xa1vrh'), (2, b'Bude')])), | ||||||
|  |                 ('soustredeni', models.ForeignKey(default=None, to='seminar.Soustredeni', null=True)), | ||||||
|  |             ], | ||||||
|  |             options={ | ||||||
|  |                 'ordering': ['soustredeni', 'stav'], | ||||||
|  |                 'db_table': 'prednasky_seznam', | ||||||
|  |                 'verbose_name': 'Seznam p\u0159edn\xe1\u0161ek', | ||||||
|  |                 'verbose_name_plural': 'Seznamy p\u0159edn\xe1\u0161ek', | ||||||
|  |             }, | ||||||
|  |         ), | ||||||
|  |         migrations.DeleteModel( | ||||||
|  |             name='Seznam_old', | ||||||
|  |         ), | ||||||
|  |         migrations.AddField( | ||||||
|  |             model_name='prednaska_seznam', | ||||||
|  |             name='seznam', | ||||||
|  |             field=models.ForeignKey(to='prednasky.Seznam'), | ||||||
|  |         ), | ||||||
|  |     ] | ||||||
							
								
								
									
										20
									
								
								prednasky/migrations/0006_hlasovani_seznam.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								prednasky/migrations/0006_hlasovani_seznam.py
									
									
									
									
									
										Normal file
									
								
							|  | @ -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, | ||||||
|  |         ), | ||||||
|  |     ] | ||||||
							
								
								
									
										19
									
								
								prednasky/migrations/0007_prednaska_seznamy.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								prednasky/migrations/0007_prednaska_seznamy.py
									
									
									
									
									
										Normal file
									
								
							|  | @ -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'), | ||||||
|  |         ), | ||||||
|  |     ] | ||||||
							
								
								
									
										25
									
								
								prednasky/migrations/0008_auto_20160929_0225.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								prednasky/migrations/0008_auto_20160929_0225.py
									
									
									
									
									
										Normal file
									
								
							|  | @ -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', | ||||||
|  |         ), | ||||||
|  |     ] | ||||||
							
								
								
									
										49
									
								
								prednasky/migrations/0009_auto_20160929_0354.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										49
									
								
								prednasky/migrations/0009_auto_20160929_0354.py
									
									
									
									
									
										Normal file
									
								
							|  | @ -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')]), | ||||||
|  |         ), | ||||||
|  |     ] | ||||||
							
								
								
									
										24
									
								
								prednasky/migrations/0010_auto_20160929_0508.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								prednasky/migrations/0010_auto_20160929_0508.py
									
									
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,24 @@ | ||||||
|  | # -*- coding: utf-8 -*- | ||||||
|  | from __future__ import unicode_literals | ||||||
|  | 
 | ||||||
|  | from django.db import migrations, models | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | class Migration(migrations.Migration): | ||||||
|  | 
 | ||||||
|  |     dependencies = [ | ||||||
|  |         ('prednasky', '0009_auto_20160929_0354'), | ||||||
|  |     ] | ||||||
|  | 
 | ||||||
|  |     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', blank=True), | ||||||
|  |         ), | ||||||
|  |         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', blank=True), | ||||||
|  |         ), | ||||||
|  |     ] | ||||||
|  | @ -1,10 +1,36 @@ | ||||||
| # -*- coding: utf-8 -*- | # -*- coding: utf-8 -*- | ||||||
| 
 | 
 | ||||||
| from django.db import models | from django.db import models | ||||||
| from seminar.models import Organizator | from django.utils.encoding import python_2_unicode_compatible | ||||||
|  | from django.utils.encoding import force_unicode | ||||||
| 
 | 
 | ||||||
|  | from seminar.models import Organizator,Soustredeni | ||||||
|  | 
 | ||||||
|  | STAV_NAVRH = 1 | ||||||
|  | STAV_BUDE = 2 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | STAV_CHOICES = ( | ||||||
|  | (STAV_NAVRH, 'Návrh'), | ||||||
|  | (STAV_BUDE, 'Bude') | ||||||
|  | ) | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | @python_2_unicode_compatible | ||||||
| class Seznam(models.Model): | class Seznam(models.Model): | ||||||
|     pass |     class Meta: | ||||||
|  |         db_table = 'prednasky_seznam' | ||||||
|  |         verbose_name = u'Seznam přednášek' | ||||||
|  |         verbose_name_plural = u'Seznamy přednášek' | ||||||
|  |         ordering = ['soustredeni', 'stav'] | ||||||
|  | 
 | ||||||
|  |     id = models.AutoField(primary_key = True)  | ||||||
|  |     soustredeni = models.ForeignKey(Soustredeni,null = True, default = None) | ||||||
|  |     stav = models.IntegerField('Stav',choices=STAV_CHOICES,default = STAV_NAVRH) | ||||||
|  | 
 | ||||||
|  |     def __str__(self): | ||||||
|  | 	return force_unicode(u"Seznam {}přednášek na {}".format(u"návrhů " if self.stav == STAV_NAVRH else "",self.soustredeni)) | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
| CHOICES_OBTIZNOST = ( | CHOICES_OBTIZNOST = ( | ||||||
| (1, 'Lehká'), | (1, 'Lehká'), | ||||||
|  | @ -18,17 +44,41 @@ CHOICES_BODY = ( | ||||||
|         (1, '1'), |         (1, '1'), | ||||||
|         ) |         ) | ||||||
| 
 | 
 | ||||||
|  | @python_2_unicode_compatible | ||||||
| class Prednaska(models.Model): | class Prednaska(models.Model): | ||||||
|     nazev = models.CharField('Název', max_length = 300) |     class Meta: | ||||||
|     org = models.ForeignKey(Organizator)  |         db_table = 'prednasky_prednaska' | ||||||
|     anotace = models.TextField('Anotace') |         verbose_name = u'Přednáška' | ||||||
|     obtiznost = models.IntegerField('Obtížnost', choices=CHOICES_OBTIZNOST) |         verbose_name_plural = u'Přednášky' | ||||||
|     obor = models.CharField('Obor', max_length = 5) |         ordering = ['org', 'nazev'] | ||||||
|     klicova = models.CharField('Klíčová slova', max_length = 200, null = True, blank = True) |  | ||||||
|     seznam = models.ForeignKey(Seznam, blank = True, default = None) |  | ||||||
| 
 | 
 | ||||||
|  |     id = models.AutoField(primary_key = True)  | ||||||
|  |     nazev = models.CharField(u'Název', max_length = 300) | ||||||
|  |     org = models.ForeignKey(Organizator)  | ||||||
|  |     popis = models.TextField(u'Popis pro orgy',null = True, blank = True,help_text = u'Neveřejný popis pro ostatní orgy') | ||||||
|  |     anotace = models.TextField('Anotace',null = True, blank = True, help_text = u'Veřejná anotace v hlasování') | ||||||
|  |     obtiznost = models.IntegerField(u'Obtížnost', choices=CHOICES_OBTIZNOST) | ||||||
|  |     obor = models.CharField(u'Obor', max_length = 5, help_text = u'Podmnožina MFIOB') | ||||||
|  |     klicova = models.CharField(u'Klíčová slova', max_length = 200, null = True, blank = True) | ||||||
|  |     seznamy = models.ManyToManyField(Seznam) | ||||||
|  | 
 | ||||||
|  |     def __str__(self): | ||||||
|  |     	return force_unicode(u"{} ({})".format(self.nazev,self.org)) | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | @python_2_unicode_compatible | ||||||
| class Hlasovani(models.Model): | class Hlasovani(models.Model): | ||||||
|  |     class Meta: | ||||||
|  |         db_table = 'prednasky_hlasovani' | ||||||
|  |         verbose_name = u'Hlasování' | ||||||
|  |         verbose_name_plural = u'Hlasování' | ||||||
|  |         ordering = ['ucastnik', 'prednaska'] | ||||||
|  |     id = models.AutoField(primary_key = True)  | ||||||
|     prednaska = models.ForeignKey(Prednaska) |     prednaska = models.ForeignKey(Prednaska) | ||||||
|     body = models.IntegerField('Body', default = 0, choices = CHOICES_BODY) |     body = models.IntegerField('Body', default = 0, choices = CHOICES_BODY) | ||||||
|     ucastnik = models.CharField('Účastník', max_length = 100) |     ucastnik = models.CharField('Účastník', max_length = 100) | ||||||
|  |     seznam = models.ForeignKey(Seznam) | ||||||
|  | 
 | ||||||
|  |     def __str__(self): | ||||||
|  |     	return force_unicode(u"{} dal {} bodů {} v seznamu {}".format(self.ucastnik, self.body, self.prednaska,self.seznam)) | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -3,10 +3,16 @@ from prednasky.forms import NewPrednaskyForm | ||||||
| from prednasky.models import Seznam, Hlasovani, Prednaska | from prednasky.models import Seznam, Hlasovani, Prednaska | ||||||
| from django.shortcuts import HttpResponseRedirect | from django.shortcuts import HttpResponseRedirect | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
|  | from models import Prednaska, Seznam, STAV_NAVRH | ||||||
|  | from seminar.models import Soustredeni | ||||||
|  | 
 | ||||||
| def newPrednaska(request): | def newPrednaska(request): | ||||||
|     # zjistime k jakemu soustredeni se vaze nove vytvarena galerie |     # hlasovani se vztahuje k nejnovejsimu soustredeni | ||||||
|     prednasky = Seznam.objects.first() |     sous = Soustredeni.objects.first() | ||||||
|     # obsluha formulare umoznujiciho multiple nahravani fotek |     seznam = Seznam.objects.filter(soustredeni = sous, stav = STAV_NAVRH).first() | ||||||
|  |     print seznam | ||||||
|  |     # obsluha formulare | ||||||
|     if request.method == 'POST': |     if request.method == 'POST': | ||||||
|         form = NewPrednaskyForm(request.POST, request.FILES) |         form = NewPrednaskyForm(request.POST, request.FILES) | ||||||
|         if form.is_valid(): |         if form.is_valid(): | ||||||
|  | @ -18,6 +24,7 @@ def newPrednaska(request): | ||||||
|                 hlasovani.prednaska = Prednaska.objects.filter(pk = int(i[1:]))[0] |                 hlasovani.prednaska = Prednaska.objects.filter(pk = int(i[1:]))[0] | ||||||
|                 hlasovani.body = int(request.POST[i]) |                 hlasovani.body = int(request.POST[i]) | ||||||
|                 hlasovani.ucastnik = jmeno |                 hlasovani.ucastnik = jmeno | ||||||
|  | 		hlasovani.seznam = seznam | ||||||
|                 hlasovani.save() |                 hlasovani.save() | ||||||
| 
 | 
 | ||||||
|             # presmerovani na prave vzniklou galerii |             # presmerovani na prave vzniklou galerii | ||||||
|  | @ -28,7 +35,7 @@ def newPrednaska(request): | ||||||
|      |      | ||||||
|     return render(request, 'prednasky/Base.html', |     return render(request, 'prednasky/Base.html', | ||||||
|           { 'form' : form, |           { 'form' : form, | ||||||
|             'prednasky' : prednasky, |             'prednasky' : seznam, | ||||||
|           }) |           }) | ||||||
| 
 | 
 | ||||||
| def Prednaska_hotovo(request): | def Prednaska_hotovo(request): | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue
	
	 Bc. Petr Pecha
						Bc. Petr Pecha