Migrace 0084 nemá padat, ale logovat.
This commit is contained in:
		
							parent
							
								
									f67aed8a5a
								
							
						
					
					
						commit
						3330fd5a9f
					
				
					 2 changed files with 9 additions and 1 deletions
				
			
		|  | @ -6,3 +6,5 @@ Jak zvládnout migrace na nový model: | |||
| 	- 2130: Definice čísel (23.6 vs 23.7) | ||||
| 	- 2143: Gravitace ve Flatlandu (23.4 vs 23.6) | ||||
| 	- 1954: Chceme vodu (nepublikováno) (21.3 vs 21.6) | ||||
| 
 | ||||
| - V mojí verzi databáze mají úlohy-Problémy typ "b'uloha'" | ||||
|  |  | |||
|  | @ -4,6 +4,9 @@ from django.db import migrations, models | |||
| import django.db.models.deletion | ||||
| from seminar.treelib import get_parent | ||||
| 
 | ||||
| import logging | ||||
| logger = logging.getLogger(__name__) | ||||
| 
 | ||||
| def najdi_cislo(apps, schema_editor): | ||||
| 	Clanek = apps.get_model('seminar', 'Clanek') | ||||
| 	Hodnoceni = apps.get_model('seminar', 'Hodnoceni') | ||||
|  | @ -15,7 +18,10 @@ def najdi_cislo(apps, schema_editor): | |||
| 	for c in Clanek.objects.all(): | ||||
| 		reseni = c.reseni_set | ||||
| 		if (reseni.count() != 1):	# Pozor, reseni_set je Manager, takže se na něj musí trošku jinak | ||||
| 			raise ValueError("Článek k sobě má nejedno řešení!") | ||||
| 			logger.warn(f"Více než jedno řešení pro článek {c}") | ||||
| 			c.cislo = None | ||||
| 			c.save() | ||||
| 			continue | ||||
| 		r = reseni.first() | ||||
| 		aktualniNode = r.text_cely # Hlavní ReseniNode pro řešení | ||||
| 		while aktualniNode is not None: | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue
	
	 Pavel "LEdoian" Turinsky
						Pavel "LEdoian" Turinsky