0001_initial.py 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624
  1. # Generated by Django 3.1.4 on 2020-12-01 07:12
  2. import uuid
  3. import django.contrib.postgres.search
  4. import imagekit.models.fields
  5. from django.db import migrations, models
  6. import files.models
  7. class Migration(migrations.Migration):
  8. initial = True
  9. dependencies = []
  10. operations = [
  11. migrations.CreateModel(
  12. name="Category",
  13. fields=[
  14. (
  15. "id",
  16. models.AutoField(
  17. auto_created=True,
  18. primary_key=True,
  19. serialize=False,
  20. verbose_name="ID",
  21. ),
  22. ),
  23. ("uid", models.UUIDField(default=uuid.uuid4, unique=True)),
  24. ("add_date", models.DateTimeField(auto_now_add=True)),
  25. ("title", models.CharField(db_index=True, max_length=100, unique=True)),
  26. ("description", models.TextField(blank=True)),
  27. (
  28. "is_global",
  29. models.BooleanField(default=False, help_text="global categories or user specific"),
  30. ),
  31. (
  32. "media_count",
  33. models.IntegerField(default=0, help_text="number of media"),
  34. ),
  35. (
  36. "thumbnail",
  37. imagekit.models.fields.ProcessedImageField(blank=True, upload_to=files.models.category_thumb_path),
  38. ),
  39. (
  40. "listings_thumbnail",
  41. models.CharField(
  42. blank=True,
  43. help_text="Thumbnail to show on listings",
  44. max_length=400,
  45. null=True,
  46. ),
  47. ),
  48. ],
  49. options={
  50. "verbose_name_plural": "Categories",
  51. "ordering": ["title"],
  52. },
  53. ),
  54. migrations.CreateModel(
  55. name="Comment",
  56. fields=[
  57. (
  58. "id",
  59. models.AutoField(
  60. auto_created=True,
  61. primary_key=True,
  62. serialize=False,
  63. verbose_name="ID",
  64. ),
  65. ),
  66. ("add_date", models.DateTimeField(auto_now_add=True)),
  67. ("text", models.TextField(help_text="text")),
  68. ("uid", models.UUIDField(default=uuid.uuid4, unique=True)),
  69. ("lft", models.PositiveIntegerField(editable=False)),
  70. ("rght", models.PositiveIntegerField(editable=False)),
  71. ("tree_id", models.PositiveIntegerField(db_index=True, editable=False)),
  72. ("level", models.PositiveIntegerField(editable=False)),
  73. ],
  74. options={
  75. "abstract": False,
  76. },
  77. ),
  78. migrations.CreateModel(
  79. name="EncodeProfile",
  80. fields=[
  81. (
  82. "id",
  83. models.AutoField(
  84. auto_created=True,
  85. primary_key=True,
  86. serialize=False,
  87. verbose_name="ID",
  88. ),
  89. ),
  90. ("name", models.CharField(max_length=90)),
  91. (
  92. "extension",
  93. models.CharField(
  94. choices=[("mp4", "mp4"), ("webm", "webm"), ("gif", "gif")],
  95. max_length=10,
  96. ),
  97. ),
  98. (
  99. "resolution",
  100. models.IntegerField(
  101. blank=True,
  102. choices=[
  103. (2160, "2160"),
  104. (1440, "1440"),
  105. (1080, "1080"),
  106. (720, "720"),
  107. (480, "480"),
  108. (360, "360"),
  109. (240, "240"),
  110. ],
  111. null=True,
  112. ),
  113. ),
  114. (
  115. "codec",
  116. models.CharField(
  117. blank=True,
  118. choices=[("h265", "h265"), ("h264", "h264"), ("vp9", "vp9")],
  119. max_length=10,
  120. null=True,
  121. ),
  122. ),
  123. ("description", models.TextField(blank=True, help_text="description")),
  124. ("active", models.BooleanField(default=True)),
  125. ],
  126. options={
  127. "ordering": ["resolution"],
  128. },
  129. ),
  130. migrations.CreateModel(
  131. name="Encoding",
  132. fields=[
  133. (
  134. "id",
  135. models.AutoField(
  136. auto_created=True,
  137. primary_key=True,
  138. serialize=False,
  139. verbose_name="ID",
  140. ),
  141. ),
  142. ("add_date", models.DateTimeField(auto_now_add=True)),
  143. ("commands", models.TextField(blank=True, help_text="commands run")),
  144. (
  145. "chunk",
  146. models.BooleanField(db_index=True, default=False, help_text="is chunk?"),
  147. ),
  148. ("chunk_file_path", models.CharField(blank=True, max_length=400)),
  149. ("chunks_info", models.TextField(blank=True)),
  150. ("logs", models.TextField(blank=True)),
  151. ("md5sum", models.CharField(blank=True, max_length=50, null=True)),
  152. (
  153. "media_file",
  154. models.FileField(
  155. blank=True,
  156. max_length=500,
  157. upload_to=files.models.encoding_media_file_path,
  158. verbose_name="encoding file",
  159. ),
  160. ),
  161. ("progress", models.PositiveSmallIntegerField(default=0)),
  162. ("update_date", models.DateTimeField(auto_now=True)),
  163. ("retries", models.IntegerField(default=0)),
  164. ("size", models.CharField(blank=True, max_length=20)),
  165. (
  166. "status",
  167. models.CharField(
  168. choices=[
  169. ("pending", "Pending"),
  170. ("running", "Running"),
  171. ("fail", "Fail"),
  172. ("success", "Success"),
  173. ],
  174. default="pending",
  175. max_length=20,
  176. ),
  177. ),
  178. ("temp_file", models.CharField(blank=True, max_length=400)),
  179. ("task_id", models.CharField(blank=True, max_length=100)),
  180. ("total_run_time", models.IntegerField(default=0)),
  181. ("worker", models.CharField(blank=True, max_length=100)),
  182. ],
  183. ),
  184. migrations.CreateModel(
  185. name="Language",
  186. fields=[
  187. (
  188. "id",
  189. models.AutoField(
  190. auto_created=True,
  191. primary_key=True,
  192. serialize=False,
  193. verbose_name="ID",
  194. ),
  195. ),
  196. ("code", models.CharField(help_text="language code", max_length=12)),
  197. ("title", models.CharField(help_text="language code", max_length=100)),
  198. ],
  199. options={
  200. "ordering": ["id"],
  201. },
  202. ),
  203. migrations.CreateModel(
  204. name="License",
  205. fields=[
  206. (
  207. "id",
  208. models.AutoField(
  209. auto_created=True,
  210. primary_key=True,
  211. serialize=False,
  212. verbose_name="ID",
  213. ),
  214. ),
  215. ("title", models.CharField(max_length=100, unique=True)),
  216. ("description", models.TextField(blank=True)),
  217. ],
  218. ),
  219. migrations.CreateModel(
  220. name="Media",
  221. fields=[
  222. (
  223. "id",
  224. models.AutoField(
  225. auto_created=True,
  226. primary_key=True,
  227. serialize=False,
  228. verbose_name="ID",
  229. ),
  230. ),
  231. (
  232. "add_date",
  233. models.DateTimeField(
  234. blank=True,
  235. db_index=True,
  236. null=True,
  237. verbose_name="Date produced",
  238. ),
  239. ),
  240. (
  241. "allow_download",
  242. models.BooleanField(
  243. default=True,
  244. help_text="Whether option to download media is shown",
  245. ),
  246. ),
  247. ("description", models.TextField(blank=True)),
  248. ("dislikes", models.IntegerField(default=0)),
  249. ("duration", models.IntegerField(default=0)),
  250. ("edit_date", models.DateTimeField(auto_now=True)),
  251. (
  252. "enable_comments",
  253. models.BooleanField(
  254. default=True,
  255. help_text="Whether comments will be allowed for this media",
  256. ),
  257. ),
  258. (
  259. "encoding_status",
  260. models.CharField(
  261. choices=[
  262. ("pending", "Pending"),
  263. ("running", "Running"),
  264. ("fail", "Fail"),
  265. ("success", "Success"),
  266. ],
  267. db_index=True,
  268. default="pending",
  269. max_length=20,
  270. ),
  271. ),
  272. (
  273. "featured",
  274. models.BooleanField(
  275. db_index=True,
  276. default=False,
  277. help_text="Whether media is globally featured by a MediaCMS editor",
  278. ),
  279. ),
  280. (
  281. "friendly_token",
  282. models.CharField(
  283. blank=True,
  284. db_index=True,
  285. help_text="Identifier for the Media",
  286. max_length=12,
  287. ),
  288. ),
  289. (
  290. "hls_file",
  291. models.CharField(
  292. blank=True,
  293. help_text="Path to HLS file for videos",
  294. max_length=1000,
  295. ),
  296. ),
  297. (
  298. "is_reviewed",
  299. models.BooleanField(
  300. db_index=True,
  301. default=True,
  302. help_text="Whether media is reviewed, so it can appear on public listings",
  303. ),
  304. ),
  305. ("likes", models.IntegerField(db_index=True, default=1)),
  306. (
  307. "listable",
  308. models.BooleanField(default=False, help_text="Whether it will appear on listings"),
  309. ),
  310. (
  311. "md5sum",
  312. models.CharField(
  313. blank=True,
  314. help_text="Not exposed, used internally",
  315. max_length=50,
  316. null=True,
  317. ),
  318. ),
  319. (
  320. "media_file",
  321. models.FileField(
  322. help_text="media file",
  323. max_length=500,
  324. upload_to=files.models.original_media_file_path,
  325. verbose_name="media file",
  326. ),
  327. ),
  328. (
  329. "media_info",
  330. models.TextField(blank=True, help_text="extracted media metadata info"),
  331. ),
  332. (
  333. "media_type",
  334. models.CharField(
  335. blank=True,
  336. choices=[
  337. ("video", "Video"),
  338. ("image", "Image"),
  339. ("pdf", "Pdf"),
  340. ("audio", "Audio"),
  341. ],
  342. db_index=True,
  343. default="video",
  344. max_length=20,
  345. ),
  346. ),
  347. (
  348. "password",
  349. models.CharField(
  350. blank=True,
  351. help_text="password for private media",
  352. max_length=100,
  353. ),
  354. ),
  355. (
  356. "preview_file_path",
  357. models.CharField(
  358. blank=True,
  359. help_text="preview gif for videos, path in filesystem",
  360. max_length=500,
  361. ),
  362. ),
  363. (
  364. "poster",
  365. imagekit.models.fields.ProcessedImageField(
  366. blank=True,
  367. help_text="media extracted big thumbnail, shown on media page",
  368. max_length=500,
  369. upload_to=files.models.original_thumbnail_file_path,
  370. ),
  371. ),
  372. (
  373. "reported_times",
  374. models.IntegerField(default=0, help_text="how many time a Medis is reported"),
  375. ),
  376. (
  377. "search",
  378. django.contrib.postgres.search.SearchVectorField(
  379. help_text="used to store all searchable info and metadata for a Media",
  380. null=True,
  381. ),
  382. ),
  383. (
  384. "size",
  385. models.CharField(
  386. blank=True,
  387. help_text="media size in bytes, automatically calculated",
  388. max_length=20,
  389. null=True,
  390. ),
  391. ),
  392. (
  393. "sprites",
  394. models.FileField(
  395. blank=True,
  396. help_text="sprites file, only for videos, displayed on the video player",
  397. max_length=500,
  398. upload_to=files.models.original_thumbnail_file_path,
  399. ),
  400. ),
  401. (
  402. "state",
  403. models.CharField(
  404. choices=[
  405. ("private", "Private"),
  406. ("public", "Public"),
  407. ("unlisted", "Unlisted"),
  408. ],
  409. db_index=True,
  410. default="public",
  411. help_text="state of Media",
  412. max_length=20,
  413. ),
  414. ),
  415. (
  416. "title",
  417. models.CharField(
  418. blank=True,
  419. db_index=True,
  420. help_text="media title",
  421. max_length=100,
  422. ),
  423. ),
  424. (
  425. "thumbnail",
  426. imagekit.models.fields.ProcessedImageField(
  427. blank=True,
  428. help_text="media extracted small thumbnail, shown on listings",
  429. max_length=500,
  430. upload_to=files.models.original_thumbnail_file_path,
  431. ),
  432. ),
  433. (
  434. "thumbnail_time",
  435. models.FloatField(
  436. blank=True,
  437. help_text="Time on video that a thumbnail will be taken",
  438. null=True,
  439. ),
  440. ),
  441. (
  442. "uid",
  443. models.UUIDField(
  444. default=uuid.uuid4,
  445. help_text="A unique identifier for the Media",
  446. unique=True,
  447. ),
  448. ),
  449. (
  450. "uploaded_thumbnail",
  451. imagekit.models.fields.ProcessedImageField(
  452. blank=True,
  453. help_text="thumbnail from uploaded_poster field",
  454. max_length=500,
  455. upload_to=files.models.original_thumbnail_file_path,
  456. ),
  457. ),
  458. (
  459. "uploaded_poster",
  460. imagekit.models.fields.ProcessedImageField(
  461. blank=True,
  462. help_text="This image will characterize the media",
  463. max_length=500,
  464. upload_to=files.models.original_thumbnail_file_path,
  465. verbose_name="Upload image",
  466. ),
  467. ),
  468. (
  469. "user_featured",
  470. models.BooleanField(default=False, help_text="Featured by the user"),
  471. ),
  472. ("video_height", models.IntegerField(default=1)),
  473. ("views", models.IntegerField(db_index=True, default=1)),
  474. ],
  475. options={
  476. "ordering": ["-add_date"],
  477. },
  478. ),
  479. migrations.CreateModel(
  480. name="Playlist",
  481. fields=[
  482. (
  483. "id",
  484. models.AutoField(
  485. auto_created=True,
  486. primary_key=True,
  487. serialize=False,
  488. verbose_name="ID",
  489. ),
  490. ),
  491. ("add_date", models.DateTimeField(auto_now_add=True, db_index=True)),
  492. ("description", models.TextField(blank=True, help_text="description")),
  493. (
  494. "friendly_token",
  495. models.CharField(blank=True, db_index=True, max_length=12),
  496. ),
  497. ("title", models.CharField(db_index=True, max_length=100)),
  498. ("uid", models.UUIDField(default=uuid.uuid4, unique=True)),
  499. ],
  500. ),
  501. migrations.CreateModel(
  502. name="PlaylistMedia",
  503. fields=[
  504. (
  505. "id",
  506. models.AutoField(
  507. auto_created=True,
  508. primary_key=True,
  509. serialize=False,
  510. verbose_name="ID",
  511. ),
  512. ),
  513. ("action_date", models.DateTimeField(auto_now=True)),
  514. ("ordering", models.IntegerField(default=1)),
  515. ],
  516. options={
  517. "ordering": ["ordering", "-action_date"],
  518. },
  519. ),
  520. migrations.CreateModel(
  521. name="Rating",
  522. fields=[
  523. (
  524. "id",
  525. models.AutoField(
  526. auto_created=True,
  527. primary_key=True,
  528. serialize=False,
  529. verbose_name="ID",
  530. ),
  531. ),
  532. ("add_date", models.DateTimeField(auto_now_add=True)),
  533. (
  534. "score",
  535. models.IntegerField(validators=[files.models.validate_rating]),
  536. ),
  537. ],
  538. options={
  539. "verbose_name_plural": "Ratings",
  540. },
  541. ),
  542. migrations.CreateModel(
  543. name="RatingCategory",
  544. fields=[
  545. (
  546. "id",
  547. models.AutoField(
  548. auto_created=True,
  549. primary_key=True,
  550. serialize=False,
  551. verbose_name="ID",
  552. ),
  553. ),
  554. ("description", models.TextField(blank=True)),
  555. ("enabled", models.BooleanField(default=True)),
  556. ("title", models.CharField(db_index=True, max_length=200, unique=True)),
  557. ],
  558. options={
  559. "verbose_name_plural": "Rating Categories",
  560. },
  561. ),
  562. migrations.CreateModel(
  563. name="Subtitle",
  564. fields=[
  565. (
  566. "id",
  567. models.AutoField(
  568. auto_created=True,
  569. primary_key=True,
  570. serialize=False,
  571. verbose_name="ID",
  572. ),
  573. ),
  574. (
  575. "subtitle_file",
  576. models.FileField(
  577. help_text="File has to be WebVTT format",
  578. max_length=500,
  579. upload_to=files.models.subtitles_file_path,
  580. verbose_name="Subtitle/CC file",
  581. ),
  582. ),
  583. ],
  584. ),
  585. migrations.CreateModel(
  586. name="Tag",
  587. fields=[
  588. (
  589. "id",
  590. models.AutoField(
  591. auto_created=True,
  592. primary_key=True,
  593. serialize=False,
  594. verbose_name="ID",
  595. ),
  596. ),
  597. ("title", models.CharField(db_index=True, max_length=100, unique=True)),
  598. (
  599. "media_count",
  600. models.IntegerField(default=0, help_text="number of media"),
  601. ),
  602. (
  603. "listings_thumbnail",
  604. models.CharField(
  605. blank=True,
  606. db_index=True,
  607. help_text="Thumbnail to show on listings",
  608. max_length=400,
  609. null=True,
  610. ),
  611. ),
  612. ],
  613. options={
  614. "ordering": ["title"],
  615. },
  616. ),
  617. ]