Zmena jmena rocniku na integer
This commit is contained in:
		
							parent
							
								
									010580648a
								
							
						
					
					
						commit
						ff532b2f59
					
				
					 2 changed files with 34 additions and 5 deletions
				
			
		
							
								
								
									
										32
									
								
								seminar/migrations/0019_rocnik_ciselne.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								seminar/migrations/0019_rocnik_ciselne.py
									
									
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,32 @@ | |||
| # -*- coding: utf-8 -*- | ||||
| from __future__ import unicode_literals | ||||
| 
 | ||||
| from django.db import models, migrations | ||||
| 
 | ||||
| 
 | ||||
| class Migration(migrations.Migration): | ||||
| 
 | ||||
|     dependencies = [ | ||||
|         ('seminar', '0018_problemnavrh_problemzadany'), | ||||
|     ] | ||||
| 
 | ||||
|     operations = [ | ||||
|         migrations.AddField( | ||||
|             model_name='rocnik', | ||||
|             name='rocnik_n', | ||||
|             field=models.IntegerField(default=0, verbose_name='\u010d\xedslo ro\u010dn\xedku'), | ||||
|             preserve_default=False, | ||||
|         ), | ||||
|         migrations.RunSQL( | ||||
|             sql="update seminar_rocniky set rocnik_n = cast (rocnik as integer)" | ||||
|         ), | ||||
|         migrations.RemoveField( | ||||
|             model_name='rocnik', | ||||
|             name='rocnik', | ||||
|         ), | ||||
|         migrations.RenameField( | ||||
|             model_name='rocnik', | ||||
|             old_name='rocnik_n', | ||||
|             new_name='rocnik', | ||||
|         ), | ||||
|     ] | ||||
|  | @ -204,16 +204,13 @@ class Rocnik(SeminarModelBase): | |||
| 
 | ||||
|     prvni_rok = models.IntegerField(u'první rok') | ||||
| 
 | ||||
|     rocnik = models.CharField(u'číslo ročníku', max_length=16) | ||||
|     rocnik = models.IntegerField(u'číslo ročníku') | ||||
| 
 | ||||
|     def __str__(self): | ||||
|         return force_unicode(u'%s (%d/%d)' % (self.rocnik, self.prvni_rok, self.prvni_rok+1)) | ||||
| 
 | ||||
|     def roman(self): | ||||
|         if self.rocnik.isdigit(): | ||||
|             return force_unicode(roman(int(self.rocnik))) | ||||
|         else: | ||||
|             return force_unicode(self.rocnik) | ||||
|         return force_unicode(roman(int(self.rocnik))) | ||||
| 
 | ||||
|     def verejne(self): | ||||
|         return len(self.verejna_cisla()) > 0 | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue
	
	 Tomas Gavenciak
						Tomas Gavenciak