0016_author_migration.py 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518
  1. # -*- coding: utf-8 -*-
  2. import datetime
  3. from south.db import db
  4. from south.v2 import DataMigration
  5. from django.db import models
  6. class Migration(DataMigration):
  7. def forwards(self, orm):
  8. "Write your forwards methods here."
  9. # Note: Remember to use orm['appname.ModelName'] rather than "from appname.models..."
  10. for book in orm["catalog.book"].objects.all():
  11. for author in book.new_authors.all():
  12. book.authors.add(author)
  13. book.save()
  14. def backwards(self, orm):
  15. "Write your backwards methods here."
  16. models = {
  17. "auth.group": {
  18. "Meta": {"object_name": "Group"},
  19. "id": ("django.db.models.fields.AutoField", [], {"primary_key": "True"}),
  20. "name": (
  21. "django.db.models.fields.CharField",
  22. [],
  23. {"unique": "True", "max_length": "80"},
  24. ),
  25. "permissions": (
  26. "django.db.models.fields.related.ManyToManyField",
  27. [],
  28. {
  29. "to": "orm['auth.Permission']",
  30. "symmetrical": "False",
  31. "blank": "True",
  32. },
  33. ),
  34. },
  35. "auth.permission": {
  36. "Meta": {
  37. "ordering": "('content_type__app_label', 'content_type__model', 'codename')",
  38. "unique_together": "(('content_type', 'codename'),)",
  39. "object_name": "Permission",
  40. },
  41. "codename": (
  42. "django.db.models.fields.CharField",
  43. [],
  44. {"max_length": "100"},
  45. ),
  46. "content_type": (
  47. "django.db.models.fields.related.ForeignKey",
  48. [],
  49. {"to": "orm['contenttypes.ContentType']"},
  50. ),
  51. "id": ("django.db.models.fields.AutoField", [], {"primary_key": "True"}),
  52. "name": ("django.db.models.fields.CharField", [], {"max_length": "50"}),
  53. },
  54. "auth.user": {
  55. "Meta": {"object_name": "User"},
  56. "date_joined": (
  57. "django.db.models.fields.DateTimeField",
  58. [],
  59. {"default": "datetime.datetime.now"},
  60. ),
  61. "email": (
  62. "django.db.models.fields.EmailField",
  63. [],
  64. {"max_length": "75", "blank": "True"},
  65. ),
  66. "first_name": (
  67. "django.db.models.fields.CharField",
  68. [],
  69. {"max_length": "30", "blank": "True"},
  70. ),
  71. "groups": (
  72. "django.db.models.fields.related.ManyToManyField",
  73. [],
  74. {"to": "orm['auth.Group']", "symmetrical": "False", "blank": "True"},
  75. ),
  76. "id": ("django.db.models.fields.AutoField", [], {"primary_key": "True"}),
  77. "is_active": (
  78. "django.db.models.fields.BooleanField",
  79. [],
  80. {"default": "True"},
  81. ),
  82. "is_staff": (
  83. "django.db.models.fields.BooleanField",
  84. [],
  85. {"default": "False"},
  86. ),
  87. "is_superuser": (
  88. "django.db.models.fields.BooleanField",
  89. [],
  90. {"default": "False"},
  91. ),
  92. "last_login": (
  93. "django.db.models.fields.DateTimeField",
  94. [],
  95. {"default": "datetime.datetime.now"},
  96. ),
  97. "last_name": (
  98. "django.db.models.fields.CharField",
  99. [],
  100. {"max_length": "30", "blank": "True"},
  101. ),
  102. "password": (
  103. "django.db.models.fields.CharField",
  104. [],
  105. {"max_length": "128"},
  106. ),
  107. "user_permissions": (
  108. "django.db.models.fields.related.ManyToManyField",
  109. [],
  110. {
  111. "to": "orm['auth.Permission']",
  112. "symmetrical": "False",
  113. "blank": "True",
  114. },
  115. ),
  116. "username": (
  117. "django.db.models.fields.CharField",
  118. [],
  119. {"unique": "True", "max_length": "30"},
  120. ),
  121. },
  122. "catalog.book": {
  123. "Meta": {"object_name": "Book", "_ormbases": ["catalog.Item"]},
  124. "authors": (
  125. "django.db.models.fields.related.ManyToManyField",
  126. [],
  127. {
  128. "symmetrical": "False",
  129. "to": "orm['catalog.Person']",
  130. "null": "True",
  131. "blank": "True",
  132. },
  133. ),
  134. "dimensions": (
  135. "django.db.models.fields.CharField",
  136. [],
  137. {"max_length": "20", "null": "True", "blank": "True"},
  138. ),
  139. "edition": (
  140. "django.db.models.fields.CharField",
  141. [],
  142. {"max_length": "50", "null": "True", "blank": "True"},
  143. ),
  144. "editors": (
  145. "django.db.models.fields.CharField",
  146. [],
  147. {"max_length": "200", "null": "True", "blank": "True"},
  148. ),
  149. "features": (
  150. "django.db.models.fields.CharField",
  151. [],
  152. {"max_length": "100", "null": "True", "blank": "True"},
  153. ),
  154. "genre": (
  155. "django.db.models.fields.CharField",
  156. [],
  157. {"max_length": "100", "null": "True", "blank": "True"},
  158. ),
  159. "illustrator": (
  160. "django.db.models.fields.CharField",
  161. [],
  162. {"max_length": "200", "null": "True", "blank": "True"},
  163. ),
  164. "isbn": (
  165. "django.db.models.fields.CharField",
  166. [],
  167. {"max_length": "20", "null": "True", "blank": "True"},
  168. ),
  169. "item_ptr": (
  170. "django.db.models.fields.related.OneToOneField",
  171. [],
  172. {"to": "orm['catalog.Item']", "unique": "True", "primary_key": "True"},
  173. ),
  174. "library_of_congress_number": (
  175. "django.db.models.fields.CharField",
  176. [],
  177. {"max_length": "20", "null": "True", "blank": "True"},
  178. ),
  179. "new_authors": (
  180. "django.db.models.fields.related.ManyToManyField",
  181. [],
  182. {
  183. "blank": "True",
  184. "related_name": "'old_authors'",
  185. "null": "True",
  186. "symmetrical": "False",
  187. "to": "orm['catalog.Person']",
  188. },
  189. ),
  190. "pages": (
  191. "django.db.models.fields.IntegerField",
  192. [],
  193. {"null": "True", "blank": "True"},
  194. ),
  195. "printer": (
  196. "django.db.models.fields.CharField",
  197. [],
  198. {"max_length": "200", "null": "True", "blank": "True"},
  199. ),
  200. "publish_date": (
  201. "django.db.models.fields.CharField",
  202. [],
  203. {"max_length": "20", "null": "True", "blank": "True"},
  204. ),
  205. "publisher": (
  206. "django.db.models.fields.CharField",
  207. [],
  208. {"max_length": "200", "null": "True", "blank": "True"},
  209. ),
  210. "subtitle": (
  211. "django.db.models.fields.CharField",
  212. [],
  213. {"max_length": "100", "null": "True", "blank": "True"},
  214. ),
  215. },
  216. "catalog.item": {
  217. "Meta": {"object_name": "Item"},
  218. "created": (
  219. "django.db.models.fields.DateTimeField",
  220. [],
  221. {"auto_now_add": "True", "blank": "True"},
  222. ),
  223. "created_by": (
  224. "django.db.models.fields.related.ForeignKey",
  225. [],
  226. {"related_name": "'+'", "to": "orm['auth.User']"},
  227. ),
  228. "deleted": (
  229. "django.db.models.fields.BooleanField",
  230. [],
  231. {"default": "False"},
  232. ),
  233. "featured": (
  234. "django.db.models.fields.BooleanField",
  235. [],
  236. {"default": "False"},
  237. ),
  238. "id": ("django.db.models.fields.AutoField", [], {"primary_key": "True"}),
  239. "image": (
  240. "sorl.thumbnail.fields.ImageField",
  241. [],
  242. {"max_length": "100", "null": "True", "blank": "True"},
  243. ),
  244. "is_active": (
  245. "django.db.models.fields.BooleanField",
  246. [],
  247. {"default": "True"},
  248. ),
  249. "last_updated": (
  250. "django.db.models.fields.DateTimeField",
  251. [],
  252. {"auto_now": "True", "auto_now_add": "True", "blank": "True"},
  253. ),
  254. "last_updated_by": (
  255. "django.db.models.fields.related.ForeignKey",
  256. [],
  257. {"related_name": "'+'", "to": "orm['auth.User']"},
  258. ),
  259. "long_description": (
  260. "django.db.models.fields.TextField",
  261. [],
  262. {"null": "True", "blank": "True"},
  263. ),
  264. "price": (
  265. "django.db.models.fields.DecimalField",
  266. [],
  267. {"max_digits": "7", "decimal_places": "2"},
  268. ),
  269. "shipping_cost": (
  270. "django.db.models.fields.DecimalField",
  271. [],
  272. {"max_digits": "7", "decimal_places": "2"},
  273. ),
  274. "shipping_cost_multiple": (
  275. "django.db.models.fields.DecimalField",
  276. [],
  277. {"max_digits": "7", "decimal_places": "2"},
  278. ),
  279. "sku": (
  280. "django.db.models.fields.SlugField",
  281. [],
  282. {"unique": "True", "max_length": "20"},
  283. ),
  284. "subclass_type": (
  285. "django.db.models.fields.CharField",
  286. [],
  287. {"max_length": "200"},
  288. ),
  289. "synopsis": (
  290. "django.db.models.fields.CharField",
  291. [],
  292. {"max_length": "200", "null": "True", "blank": "True"},
  293. ),
  294. "tax_free": (
  295. "django.db.models.fields.BooleanField",
  296. [],
  297. {"default": "False"},
  298. ),
  299. "title": ("django.db.models.fields.CharField", [], {"max_length": "50"}),
  300. },
  301. "catalog.map": {
  302. "Meta": {"object_name": "Map", "_ormbases": ["catalog.Item"]},
  303. "dimensions": (
  304. "django.db.models.fields.CharField",
  305. [],
  306. {"max_length": "20", "null": "True", "blank": "True"},
  307. ),
  308. "item_ptr": (
  309. "django.db.models.fields.related.OneToOneField",
  310. [],
  311. {"to": "orm['catalog.Item']", "unique": "True", "primary_key": "True"},
  312. ),
  313. },
  314. "catalog.movie": {
  315. "Meta": {"object_name": "Movie", "_ormbases": ["catalog.Item"]},
  316. "captioning": (
  317. "django.db.models.fields.CharField",
  318. [],
  319. {"max_length": "50", "null": "True", "blank": "True"},
  320. ),
  321. "format": (
  322. "django.db.models.fields.CharField",
  323. [],
  324. {"max_length": "20", "null": "True", "blank": "True"},
  325. ),
  326. "genre": (
  327. "django.db.models.fields.CharField",
  328. [],
  329. {"max_length": "100", "null": "True", "blank": "True"},
  330. ),
  331. "item_ptr": (
  332. "django.db.models.fields.related.OneToOneField",
  333. [],
  334. {"to": "orm['catalog.Item']", "unique": "True", "primary_key": "True"},
  335. ),
  336. "language": (
  337. "django.db.models.fields.CharField",
  338. [],
  339. {"max_length": "50", "null": "True", "blank": "True"},
  340. ),
  341. "music": (
  342. "django.db.models.fields.CharField",
  343. [],
  344. {"max_length": "200", "null": "True", "blank": "True"},
  345. ),
  346. "producer": (
  347. "django.db.models.fields.CharField",
  348. [],
  349. {"max_length": "200", "null": "True", "blank": "True"},
  350. ),
  351. "region": (
  352. "django.db.models.fields.CharField",
  353. [],
  354. {"max_length": "50", "null": "True", "blank": "True"},
  355. ),
  356. "runtime_minutes": (
  357. "django.db.models.fields.IntegerField",
  358. [],
  359. {"null": "True", "blank": "True"},
  360. ),
  361. "sound": (
  362. "django.db.models.fields.CharField",
  363. [],
  364. {"max_length": "50", "null": "True", "blank": "True"},
  365. ),
  366. },
  367. "catalog.person": {
  368. "Meta": {"object_name": "Person"},
  369. "created": (
  370. "django.db.models.fields.DateTimeField",
  371. [],
  372. {"auto_now_add": "True", "blank": "True"},
  373. ),
  374. "created_by": (
  375. "django.db.models.fields.related.ForeignKey",
  376. [],
  377. {"related_name": "'+'", "to": "orm['auth.User']"},
  378. ),
  379. "deleted": (
  380. "django.db.models.fields.BooleanField",
  381. [],
  382. {"default": "False"},
  383. ),
  384. "description": (
  385. "django.db.models.fields.TextField",
  386. [],
  387. {"default": "''", "null": "True", "blank": "True"},
  388. ),
  389. "id": ("django.db.models.fields.AutoField", [], {"primary_key": "True"}),
  390. "image": (
  391. "sorl.thumbnail.fields.ImageField",
  392. [],
  393. {"max_length": "100", "null": "True", "blank": "True"},
  394. ),
  395. "is_active": (
  396. "django.db.models.fields.BooleanField",
  397. [],
  398. {"default": "True"},
  399. ),
  400. "last_updated": (
  401. "django.db.models.fields.DateTimeField",
  402. [],
  403. {"auto_now": "True", "auto_now_add": "True", "blank": "True"},
  404. ),
  405. "last_updated_by": (
  406. "django.db.models.fields.related.ForeignKey",
  407. [],
  408. {"related_name": "'+'", "to": "orm['auth.User']"},
  409. ),
  410. "name": ("django.db.models.fields.CharField", [], {"max_length": "60"}),
  411. "slug": (
  412. "django.db.models.fields.SlugField",
  413. [],
  414. {"unique": "True", "max_length": "60"},
  415. ),
  416. "title": (
  417. "django.db.models.fields.CharField",
  418. [],
  419. {"default": "''", "max_length": "60", "null": "True", "blank": "True"},
  420. ),
  421. },
  422. "catalog.subscription": {
  423. "Meta": {"object_name": "Subscription", "_ormbases": ["catalog.Item"]},
  424. "duration": ("django.db.models.fields.IntegerField", [], {}),
  425. "item_ptr": (
  426. "django.db.models.fields.related.OneToOneField",
  427. [],
  428. {"to": "orm['catalog.Item']", "unique": "True", "primary_key": "True"},
  429. ),
  430. "shipping_method": (
  431. "django.db.models.fields.CharField",
  432. [],
  433. {"default": "u'REGULAR'", "max_length": "20"},
  434. ),
  435. "shipping_type": (
  436. "django.db.models.fields.CharField",
  437. [],
  438. {"default": "'INSTATE'", "max_length": "10"},
  439. ),
  440. },
  441. "catalog.zipcode": {
  442. "Meta": {"object_name": "ZipCode"},
  443. "city": (
  444. "django.db.models.fields.CharField",
  445. [],
  446. {"max_length": "64", "null": "True", "blank": "True"},
  447. ),
  448. "county": (
  449. "django.db.models.fields.CharField",
  450. [],
  451. {"max_length": "64", "null": "True", "blank": "True"},
  452. ),
  453. "created": (
  454. "django.db.models.fields.DateTimeField",
  455. [],
  456. {"auto_now_add": "True", "blank": "True"},
  457. ),
  458. "created_by": (
  459. "django.db.models.fields.related.ForeignKey",
  460. [],
  461. {"related_name": "'+'", "to": "orm['auth.User']"},
  462. ),
  463. "deleted": (
  464. "django.db.models.fields.BooleanField",
  465. [],
  466. {"default": "False"},
  467. ),
  468. "id": ("django.db.models.fields.AutoField", [], {"primary_key": "True"}),
  469. "is_active": (
  470. "django.db.models.fields.BooleanField",
  471. [],
  472. {"default": "True"},
  473. ),
  474. "last_updated": (
  475. "django.db.models.fields.DateTimeField",
  476. [],
  477. {"auto_now": "True", "auto_now_add": "True", "blank": "True"},
  478. ),
  479. "last_updated_by": (
  480. "django.db.models.fields.related.ForeignKey",
  481. [],
  482. {"related_name": "'+'", "to": "orm['auth.User']"},
  483. ),
  484. "state": (
  485. "django.db.models.fields.CharField",
  486. [],
  487. {"max_length": "2", "null": "True", "blank": "True"},
  488. ),
  489. "zipcode": (
  490. "django.db.models.fields.CharField",
  491. [],
  492. {"unique": "True", "max_length": "9"},
  493. ),
  494. },
  495. "contenttypes.contenttype": {
  496. "Meta": {
  497. "ordering": "('name',)",
  498. "unique_together": "(('app_label', 'model'),)",
  499. "object_name": "ContentType",
  500. "db_table": "'django_content_type'",
  501. },
  502. "app_label": (
  503. "django.db.models.fields.CharField",
  504. [],
  505. {"max_length": "100"},
  506. ),
  507. "id": ("django.db.models.fields.AutoField", [], {"primary_key": "True"}),
  508. "model": ("django.db.models.fields.CharField", [], {"max_length": "100"}),
  509. "name": ("django.db.models.fields.CharField", [], {"max_length": "100"}),
  510. },
  511. }
  512. complete_apps = ["catalog"]
  513. symmetrical = True