fnschool 20250109.80500.803__py3-none-any.whl → 20251011.80531.840__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of fnschool might be problematic. Click here for more details.

Files changed (276) hide show
  1. fnschoo1/__init__.py +52 -0
  2. fnschoo1/canteen/admin.py +3 -0
  3. fnschoo1/canteen/apps.py +6 -0
  4. fnschoo1/canteen/forms.py +84 -0
  5. fnschoo1/canteen/migrations/0001_initial.py +119 -0
  6. fnschoo1/canteen/migrations/0002_ingredient_is_disabled.py +20 -0
  7. fnschoo1/canteen/migrations/0003_consumption_is_disabled_alter_ingredient_is_disabled.py +23 -0
  8. fnschoo1/canteen/migrations/0004_alter_ingredient_name_category_and_more.py +66 -0
  9. fnschoo1/canteen/migrations/0005_alter_category_created_at_alter_category_name_and_more.py +41 -0
  10. fnschoo1/canteen/migrations/0006_category_is_disabled_alter_category_user_and_more.py +49 -0
  11. fnschoo1/canteen/migrations/0007_alter_consumption_amount_used_and_more.py +30 -0
  12. fnschoo1/canteen/migrations/0008_category_abbreviation_mealtype.py +67 -0
  13. fnschoo1/canteen/migrations/0009_alter_category_abbreviation_and_more.py +55 -0
  14. fnschoo1/canteen/migrations/0010_alter_consumption_options_alter_ingredient_options_and_more.py +215 -0
  15. fnschoo1/canteen/migrations/0011_category_pin_to_consumptions_top.py +23 -0
  16. fnschoo1/canteen/migrations/0012_alter_ingredient_storage_date.py +18 -0
  17. fnschoo1/canteen/models.py +179 -0
  18. fnschoo1/canteen/templates/canteen/category/create.html +17 -0
  19. fnschoo1/canteen/templates/canteen/category/delete.html +61 -0
  20. fnschoo1/canteen/templates/canteen/category/list.html +63 -0
  21. fnschoo1/canteen/templates/canteen/category/update.html +23 -0
  22. fnschoo1/canteen/templates/canteen/close.html +11 -0
  23. fnschoo1/canteen/templates/canteen/consumption/_create.html +19 -0
  24. fnschoo1/canteen/templates/canteen/consumption/create.html +456 -0
  25. fnschoo1/canteen/templates/canteen/ingredient/close.html +11 -0
  26. fnschoo1/canteen/templates/canteen/ingredient/create.html +19 -0
  27. fnschoo1/canteen/templates/canteen/ingredient/create_one.html +17 -0
  28. fnschoo1/canteen/templates/canteen/ingredient/delete.html +41 -0
  29. fnschoo1/canteen/templates/canteen/ingredient/list.html +128 -0
  30. fnschoo1/canteen/templates/canteen/ingredient/update.html +23 -0
  31. fnschoo1/canteen/templates/canteen/meal_type/create.html +17 -0
  32. fnschoo1/canteen/templates/canteen/meal_type/delete.html +56 -0
  33. fnschoo1/canteen/templates/canteen/meal_type/list.html +59 -0
  34. fnschoo1/canteen/templates/canteen/meal_type/update.html +23 -0
  35. fnschoo1/canteen/tests.py +3 -0
  36. fnschoo1/canteen/urls.py +116 -0
  37. fnschoo1/canteen/views.py +814 -0
  38. fnschoo1/canteen/workbook/generate.py +2098 -0
  39. fnschoo1/db.sqlite3 +0 -0
  40. fnschoo1/fnschool/__init__.py +13 -0
  41. fnschoo1/fnschool/asgi.py +16 -0
  42. fnschoo1/fnschool/settings.py +167 -0
  43. fnschoo1/fnschool/templatetags/fnschool_tags.py +27 -0
  44. fnschoo1/fnschool/urls.py +30 -0
  45. fnschoo1/fnschool/views.py +9 -0
  46. fnschoo1/fnschool/wsgi.py +16 -0
  47. fnschoo1/locale/en/LC_MESSAGES/django.mo +0 -0
  48. fnschoo1/locale/zh_Hans/LC_MESSAGES/django.mo +0 -0
  49. fnschoo1/manage.py +25 -0
  50. fnschoo1/profiles/admin.py +27 -0
  51. fnschoo1/profiles/apps.py +12 -0
  52. fnschoo1/profiles/forms.py +67 -0
  53. fnschoo1/profiles/migrations/0001_initial.py +192 -0
  54. fnschoo1/profiles/migrations/0002_alter_profile_bio.py +20 -0
  55. fnschoo1/profiles/migrations/0003_alter_profile_options_alter_profile_address_and_more.py +67 -0
  56. fnschoo1/profiles/migrations/0004_profile_gender.py +26 -0
  57. fnschoo1/profiles/migrations/0005_alter_profile_gender.py +23 -0
  58. fnschoo1/profiles/models.py +60 -0
  59. fnschoo1/profiles/signals.py +20 -0
  60. fnschoo1/profiles/templates/profiles/create.html +16 -0
  61. fnschoo1/profiles/templates/profiles/detail.html +14 -0
  62. fnschoo1/profiles/templates/profiles/edit.html +12 -0
  63. fnschoo1/profiles/templates/profiles/log_in.html +20 -0
  64. fnschoo1/profiles/templates/profiles/log_out.html +12 -0
  65. fnschoo1/profiles/tests.py +3 -0
  66. fnschoo1/profiles/urls.py +15 -0
  67. fnschoo1/profiles/views.py +63 -0
  68. fnschoo1/static/css/bootstrap.min.css +11776 -0
  69. fnschoo1/static/css/fnschool.css +26 -0
  70. fnschoo1/static/js/bootstrap.bundle.min.js +4223 -0
  71. fnschoo1/static/js/bootstrap.min.js +2919 -0
  72. fnschoo1/static/js/fnschool.js +84 -0
  73. fnschoo1/static/js/jquery.min.js +5413 -0
  74. fnschoo1/static/js/jquery.slim.min.js +4331 -0
  75. fnschoo1/static/js/popper.min.js +1306 -0
  76. fnschoo1/static_collected/admin/css/autocomplete.css +377 -0
  77. fnschoo1/static_collected/admin/css/base.css +1224 -0
  78. fnschoo1/static_collected/admin/css/changelists.css +334 -0
  79. fnschoo1/static_collected/admin/css/dark_mode.css +136 -0
  80. fnschoo1/static_collected/admin/css/dashboard.css +30 -0
  81. fnschoo1/static_collected/admin/css/forms.css +546 -0
  82. fnschoo1/static_collected/admin/css/login.css +62 -0
  83. fnschoo1/static_collected/admin/css/nav_sidebar.css +145 -0
  84. fnschoo1/static_collected/admin/css/responsive.css +1043 -0
  85. fnschoo1/static_collected/admin/css/responsive_rtl.css +84 -0
  86. fnschoo1/static_collected/admin/css/rtl.css +311 -0
  87. fnschoo1/static_collected/admin/css/vendor/select2/select2.css +708 -0
  88. fnschoo1/static_collected/admin/css/vendor/select2/select2.min.css +1 -0
  89. fnschoo1/static_collected/admin/css/widgets.css +639 -0
  90. fnschoo1/static_collected/admin/js/SelectBox.js +128 -0
  91. fnschoo1/static_collected/admin/js/SelectFilter2.js +503 -0
  92. fnschoo1/static_collected/admin/js/actions.js +232 -0
  93. fnschoo1/static_collected/admin/js/admin/DateTimeShortcuts.js +496 -0
  94. fnschoo1/static_collected/admin/js/admin/RelatedObjectLookups.js +276 -0
  95. fnschoo1/static_collected/admin/js/autocomplete.js +33 -0
  96. fnschoo1/static_collected/admin/js/calendar.js +251 -0
  97. fnschoo1/static_collected/admin/js/cancel.js +29 -0
  98. fnschoo1/static_collected/admin/js/change_form.js +21 -0
  99. fnschoo1/static_collected/admin/js/collapse.js +43 -0
  100. fnschoo1/static_collected/admin/js/core.js +174 -0
  101. fnschoo1/static_collected/admin/js/filters.js +37 -0
  102. fnschoo1/static_collected/admin/js/inlines.js +439 -0
  103. fnschoo1/static_collected/admin/js/jquery.init.js +8 -0
  104. fnschoo1/static_collected/admin/js/nav_sidebar.js +81 -0
  105. fnschoo1/static_collected/admin/js/popup_response.js +24 -0
  106. fnschoo1/static_collected/admin/js/prepopulate.js +43 -0
  107. fnschoo1/static_collected/admin/js/prepopulate_init.js +20 -0
  108. fnschoo1/static_collected/admin/js/theme.js +57 -0
  109. fnschoo1/static_collected/admin/js/urlify.js +529 -0
  110. fnschoo1/static_collected/admin/js/vendor/jquery/jquery.js +10913 -0
  111. fnschoo1/static_collected/admin/js/vendor/jquery/jquery.min.js +2 -0
  112. fnschoo1/static_collected/admin/js/vendor/select2/i18n/af.js +43 -0
  113. fnschoo1/static_collected/admin/js/vendor/select2/i18n/ar.js +36 -0
  114. fnschoo1/static_collected/admin/js/vendor/select2/i18n/az.js +33 -0
  115. fnschoo1/static_collected/admin/js/vendor/select2/i18n/bg.js +38 -0
  116. fnschoo1/static_collected/admin/js/vendor/select2/i18n/bn.js +39 -0
  117. fnschoo1/static_collected/admin/js/vendor/select2/i18n/bs.js +48 -0
  118. fnschoo1/static_collected/admin/js/vendor/select2/i18n/ca.js +41 -0
  119. fnschoo1/static_collected/admin/js/vendor/select2/i18n/cs.js +62 -0
  120. fnschoo1/static_collected/admin/js/vendor/select2/i18n/da.js +37 -0
  121. fnschoo1/static_collected/admin/js/vendor/select2/i18n/de.js +41 -0
  122. fnschoo1/static_collected/admin/js/vendor/select2/i18n/dsb.js +51 -0
  123. fnschoo1/static_collected/admin/js/vendor/select2/i18n/el.js +43 -0
  124. fnschoo1/static_collected/admin/js/vendor/select2/i18n/en.js +41 -0
  125. fnschoo1/static_collected/admin/js/vendor/select2/i18n/es.js +41 -0
  126. fnschoo1/static_collected/admin/js/vendor/select2/i18n/et.js +38 -0
  127. fnschoo1/static_collected/admin/js/vendor/select2/i18n/eu.js +45 -0
  128. fnschoo1/static_collected/admin/js/vendor/select2/i18n/fa.js +42 -0
  129. fnschoo1/static_collected/admin/js/vendor/select2/i18n/fi.js +42 -0
  130. fnschoo1/static_collected/admin/js/vendor/select2/i18n/fr.js +43 -0
  131. fnschoo1/static_collected/admin/js/vendor/select2/i18n/gl.js +40 -0
  132. fnschoo1/static_collected/admin/js/vendor/select2/i18n/he.js +44 -0
  133. fnschoo1/static_collected/admin/js/vendor/select2/i18n/hi.js +40 -0
  134. fnschoo1/static_collected/admin/js/vendor/select2/i18n/hr.js +45 -0
  135. fnschoo1/static_collected/admin/js/vendor/select2/i18n/hsb.js +51 -0
  136. fnschoo1/static_collected/admin/js/vendor/select2/i18n/hu.js +44 -0
  137. fnschoo1/static_collected/admin/js/vendor/select2/i18n/hy.js +40 -0
  138. fnschoo1/static_collected/admin/js/vendor/select2/i18n/id.js +36 -0
  139. fnschoo1/static_collected/admin/js/vendor/select2/i18n/is.js +37 -0
  140. fnschoo1/static_collected/admin/js/vendor/select2/i18n/it.js +43 -0
  141. fnschoo1/static_collected/admin/js/vendor/select2/i18n/ja.js +40 -0
  142. fnschoo1/static_collected/admin/js/vendor/select2/i18n/ka.js +42 -0
  143. fnschoo1/static_collected/admin/js/vendor/select2/i18n/km.js +38 -0
  144. fnschoo1/static_collected/admin/js/vendor/select2/i18n/ko.js +42 -0
  145. fnschoo1/static_collected/admin/js/vendor/select2/i18n/lt.js +45 -0
  146. fnschoo1/static_collected/admin/js/vendor/select2/i18n/lv.js +41 -0
  147. fnschoo1/static_collected/admin/js/vendor/select2/i18n/mk.js +42 -0
  148. fnschoo1/static_collected/admin/js/vendor/select2/i18n/ms.js +38 -0
  149. fnschoo1/static_collected/admin/js/vendor/select2/i18n/nb.js +38 -0
  150. fnschoo1/static_collected/admin/js/vendor/select2/i18n/ne.js +44 -0
  151. fnschoo1/static_collected/admin/js/vendor/select2/i18n/nl.js +46 -0
  152. fnschoo1/static_collected/admin/js/vendor/select2/i18n/pl.js +43 -0
  153. fnschoo1/static_collected/admin/js/vendor/select2/i18n/ps.js +41 -0
  154. fnschoo1/static_collected/admin/js/vendor/select2/i18n/pt-BR.js +39 -0
  155. fnschoo1/static_collected/admin/js/vendor/select2/i18n/pt.js +41 -0
  156. fnschoo1/static_collected/admin/js/vendor/select2/i18n/ro.js +43 -0
  157. fnschoo1/static_collected/admin/js/vendor/select2/i18n/ru.js +48 -0
  158. fnschoo1/static_collected/admin/js/vendor/select2/i18n/sk.js +61 -0
  159. fnschoo1/static_collected/admin/js/vendor/select2/i18n/sl.js +41 -0
  160. fnschoo1/static_collected/admin/js/vendor/select2/i18n/sq.js +43 -0
  161. fnschoo1/static_collected/admin/js/vendor/select2/i18n/sr-Cyrl.js +48 -0
  162. fnschoo1/static_collected/admin/js/vendor/select2/i18n/sr.js +48 -0
  163. fnschoo1/static_collected/admin/js/vendor/select2/i18n/sv.js +40 -0
  164. fnschoo1/static_collected/admin/js/vendor/select2/i18n/th.js +36 -0
  165. fnschoo1/static_collected/admin/js/vendor/select2/i18n/tk.js +36 -0
  166. fnschoo1/static_collected/admin/js/vendor/select2/i18n/tr.js +40 -0
  167. fnschoo1/static_collected/admin/js/vendor/select2/i18n/uk.js +59 -0
  168. fnschoo1/static_collected/admin/js/vendor/select2/i18n/vi.js +37 -0
  169. fnschoo1/static_collected/admin/js/vendor/select2/i18n/zh-CN.js +36 -0
  170. fnschoo1/static_collected/admin/js/vendor/select2/i18n/zh-TW.js +33 -0
  171. fnschoo1/static_collected/admin/js/vendor/select2/select2.full.js +7115 -0
  172. fnschoo1/static_collected/admin/js/vendor/select2/select2.full.min.js +2 -0
  173. fnschoo1/static_collected/admin/js/vendor/xregexp/xregexp.js +4993 -0
  174. fnschoo1/static_collected/admin/js/vendor/xregexp/xregexp.min.js +160 -0
  175. fnschoo1/static_collected/css/bootstrap.min.css +11776 -0
  176. fnschoo1/static_collected/css/fnschool.css +26 -0
  177. fnschoo1/static_collected/js/bootstrap.bundle.min.js +4223 -0
  178. fnschoo1/static_collected/js/bootstrap.min.js +2919 -0
  179. fnschoo1/static_collected/js/fnschool.js +84 -0
  180. fnschoo1/static_collected/js/jquery.min.js +5413 -0
  181. fnschoo1/static_collected/js/jquery.slim.min.js +4331 -0
  182. fnschoo1/static_collected/js/popper.min.js +1306 -0
  183. fnschoo1/templates/base/_css.html +1 -0
  184. fnschoo1/templates/base/_js.html +15 -0
  185. fnschoo1/templates/base/content.html +30 -0
  186. fnschoo1/templates/base/header_content_footer.html +35 -0
  187. fnschoo1/templates/close.html +11 -0
  188. fnschoo1/templates/home.html +51 -0
  189. fnschoo1/templates/includes/_footer.html +39 -0
  190. fnschoo1/templates/includes/_header.html +77 -0
  191. fnschoo1/templates/includes/_navigation.html +0 -0
  192. fnschoo1/templates/includes/_paginator.html +27 -0
  193. fnschoo1/templates/registration/logged_out.html +0 -0
  194. fnschoo1/templates/registration/login.html +0 -0
  195. fnschool-20251011.80531.840.dist-info/METADATA +179 -0
  196. fnschool-20251011.80531.840.dist-info/RECORD +207 -0
  197. {fnschool-20250109.80500.803.dist-info → fnschool-20251011.80531.840.dist-info}/WHEEL +1 -1
  198. fnschool-20251011.80531.840.dist-info/entry_points.txt +2 -0
  199. fnschool-20251011.80531.840.dist-info/top_level.txt +1 -0
  200. fnschool/__init__.py +0 -35
  201. fnschool/__main__.py +0 -16
  202. fnschool/app.py +0 -103
  203. fnschool/canteen/__init__.py +0 -3
  204. fnschool/canteen/__main__.py +0 -3
  205. fnschool/canteen/bill.py +0 -253
  206. fnschool/canteen/canteen.py +0 -1
  207. fnschool/canteen/canteen.toml +0 -61
  208. fnschool/canteen/config.py +0 -10
  209. fnschool/canteen/consuming.py +0 -53
  210. fnschool/canteen/currency.py +0 -17
  211. fnschool/canteen/data/bill.i18n.xlsx +0 -0
  212. fnschool/canteen/data/bill.xlsx +0 -0
  213. fnschool/canteen/data/consuming.xlsx +0 -0
  214. fnschool/canteen/data/purchase_list.xlsx +0 -0
  215. fnschool/canteen/entry.py +0 -40
  216. fnschool/canteen/food.py +0 -206
  217. fnschool/canteen/food_classes.py +0 -33
  218. fnschool/canteen/food_classes.toml +0 -64
  219. fnschool/canteen/operator.py +0 -91
  220. fnschool/canteen/path.py +0 -28
  221. fnschool/canteen/spreadsheet/base.py +0 -212
  222. fnschool/canteen/spreadsheet/consuming.py +0 -310
  223. fnschool/canteen/spreadsheet/consumingsum.py +0 -76
  224. fnschool/canteen/spreadsheet/cover.py +0 -64
  225. fnschool/canteen/spreadsheet/ctspreadsheet.py +0 -351
  226. fnschool/canteen/spreadsheet/food.py +0 -680
  227. fnschool/canteen/spreadsheet/inventory.py +0 -375
  228. fnschool/canteen/spreadsheet/merging.py +0 -340
  229. fnschool/canteen/spreadsheet/preconsuming.py +0 -329
  230. fnschool/canteen/spreadsheet/purchasing.py +0 -885
  231. fnschool/canteen/spreadsheet/purchasingsum.py +0 -110
  232. fnschool/canteen/spreadsheet/spreadsheet.py +0 -363
  233. fnschool/canteen/spreadsheet/translating.py +0 -12
  234. fnschool/canteen/spreadsheet/unwarehousing.py +0 -178
  235. fnschool/canteen/spreadsheet/unwarehousingsum.py +0 -11
  236. fnschool/canteen/spreadsheet/warehousing.py +0 -360
  237. fnschool/canteen/spreadsheet/workbook.py +0 -17
  238. fnschool/canteen/test.py +0 -97
  239. fnschool/config.py +0 -48
  240. fnschool/entry.py +0 -67
  241. fnschool/exam/__init__.py +0 -8
  242. fnschool/exam/data/parental_emails.xlsx +0 -0
  243. fnschool/exam/data/score.xlsx +0 -0
  244. fnschool/exam/email.py +0 -349
  245. fnschool/exam/entry.py +0 -36
  246. fnschool/exam/language.py +0 -19
  247. fnschool/exam/path.py +0 -24
  248. fnschool/exam/score.py +0 -1191
  249. fnschool/exam/subject.py +0 -20
  250. fnschool/exam/teacher.py +0 -54
  251. fnschool/external.py +0 -89
  252. fnschool/games/__init__.py +0 -1
  253. fnschool/games/__main__.py +0 -1
  254. fnschool/games/games.py +0 -1
  255. fnschool/inoutput.py +0 -97
  256. fnschool/language.py +0 -40
  257. fnschool/locales/en_US/LC_MESSAGES/fnschool.mo +0 -0
  258. fnschool/locales/zh_CN/LC_MESSAGES/fnschool.mo +0 -0
  259. fnschool/locales/zh_HK/LC_MESSAGES/fnschool.mo +0 -0
  260. fnschool/locales/zh_SG/LC_MESSAGES/fnschool.mo +0 -0
  261. fnschool/locales/zh_TW/LC_MESSAGES/fnschool.mo +0 -0
  262. fnschool/path.py +0 -45
  263. fnschool/test.py +0 -24
  264. fnschool/user.py +0 -262
  265. fnschool-20250109.80500.803.dist-info/METADATA +0 -342
  266. fnschool-20250109.80500.803.dist-info/RECORD +0 -78
  267. fnschool-20250109.80500.803.dist-info/entry_points.txt +0 -5
  268. fnschool-20250109.80500.803.dist-info/top_level.txt +0 -1
  269. /fnschool/canteen/consume.py → /fnschoo1/canteen/__init__.py +0 -0
  270. /fnschool/canteen/food_recount.toml → /fnschoo1/canteen/migrations/__init__.py +0 -0
  271. {fnschool/canteen/spreadsheet → fnschoo1/canteen/workbook}/__init__.py +0 -0
  272. /fnschool/exam/__main__.py → /fnschoo1/fnschool/templatetags/__init__.py +0 -0
  273. /fnschool/canteen/food_recounts.toml → /fnschoo1/profiles/__init__.py +0 -0
  274. /fnschool/canteen/warehouse.py → /fnschoo1/profiles/migrations/__init__.py +0 -0
  275. /fnschool/canteen/workbook.toml → /fnschoo1/templates/base/_content.html +0 -0
  276. {fnschool-20250109.80500.803.dist-info → fnschool-20251011.80531.840.dist-info/licenses}/LICENSE +0 -0
@@ -0,0 +1,174 @@
1
+ // Core JavaScript helper functions
2
+ 'use strict'
3
+
4
+ // quickElement(tagType, parentReference [, textInChildNode, attribute, attributeValue ...]);
5
+ function quickElement() {
6
+ const obj = document.createElement(arguments[0])
7
+ if (arguments[2]) {
8
+ const textNode = document.createTextNode(arguments[2])
9
+ obj.appendChild(textNode)
10
+ }
11
+ const len = arguments.length
12
+ for (let i = 3; i < len; i += 2) {
13
+ obj.setAttribute(arguments[i], arguments[i + 1])
14
+ }
15
+ arguments[1].appendChild(obj)
16
+ return obj
17
+ }
18
+
19
+ // "a" is reference to an object
20
+ function removeChildren(a) {
21
+ while (a.hasChildNodes()) {
22
+ a.removeChild(a.lastChild)
23
+ }
24
+ }
25
+
26
+ // ----------------------------------------------------------------------------
27
+ // Find-position functions by PPK
28
+ // See https://www.quirksmode.org/js/findpos.html
29
+ // ----------------------------------------------------------------------------
30
+ function findPosX(obj) {
31
+ let curleft = 0
32
+ if (obj.offsetParent) {
33
+ while (obj.offsetParent) {
34
+ curleft += obj.offsetLeft - obj.scrollLeft
35
+ obj = obj.offsetParent
36
+ }
37
+ } else if (obj.x) {
38
+ curleft += obj.x
39
+ }
40
+ return curleft
41
+ }
42
+
43
+ function findPosY(obj) {
44
+ let curtop = 0
45
+ if (obj.offsetParent) {
46
+ while (obj.offsetParent) {
47
+ curtop += obj.offsetTop - obj.scrollTop
48
+ obj = obj.offsetParent
49
+ }
50
+ } else if (obj.y) {
51
+ curtop += obj.y
52
+ }
53
+ return curtop
54
+ }
55
+
56
+ //-----------------------------------------------------------------------------
57
+ // Date object extensions
58
+ // ----------------------------------------------------------------------------
59
+ {
60
+ Date.prototype.getTwelveHours = function () {
61
+ return this.getHours() % 12 || 12
62
+ }
63
+
64
+ Date.prototype.getTwoDigitMonth = function () {
65
+ return this.getMonth() < 9
66
+ ? '0' + (this.getMonth() + 1)
67
+ : this.getMonth() + 1
68
+ }
69
+
70
+ Date.prototype.getTwoDigitDate = function () {
71
+ return this.getDate() < 10 ? '0' + this.getDate() : this.getDate()
72
+ }
73
+
74
+ Date.prototype.getTwoDigitTwelveHour = function () {
75
+ return this.getTwelveHours() < 10
76
+ ? '0' + this.getTwelveHours()
77
+ : this.getTwelveHours()
78
+ }
79
+
80
+ Date.prototype.getTwoDigitHour = function () {
81
+ return this.getHours() < 10 ? '0' + this.getHours() : this.getHours()
82
+ }
83
+
84
+ Date.prototype.getTwoDigitMinute = function () {
85
+ return this.getMinutes() < 10 ? '0' + this.getMinutes() : this.getMinutes()
86
+ }
87
+
88
+ Date.prototype.getTwoDigitSecond = function () {
89
+ return this.getSeconds() < 10 ? '0' + this.getSeconds() : this.getSeconds()
90
+ }
91
+
92
+ Date.prototype.getAbbrevMonthName = function () {
93
+ return typeof window.CalendarNamespace === 'undefined'
94
+ ? this.getTwoDigitMonth()
95
+ : window.CalendarNamespace.monthsOfYearAbbrev[this.getMonth()]
96
+ }
97
+
98
+ Date.prototype.getFullMonthName = function () {
99
+ return typeof window.CalendarNamespace === 'undefined'
100
+ ? this.getTwoDigitMonth()
101
+ : window.CalendarNamespace.monthsOfYear[this.getMonth()]
102
+ }
103
+
104
+ Date.prototype.strftime = function (format) {
105
+ const fields = {
106
+ b: this.getAbbrevMonthName(),
107
+ B: this.getFullMonthName(),
108
+ c: this.toString(),
109
+ d: this.getTwoDigitDate(),
110
+ H: this.getTwoDigitHour(),
111
+ I: this.getTwoDigitTwelveHour(),
112
+ m: this.getTwoDigitMonth(),
113
+ M: this.getTwoDigitMinute(),
114
+ p: this.getHours() >= 12 ? 'PM' : 'AM',
115
+ S: this.getTwoDigitSecond(),
116
+ w: '0' + this.getDay(),
117
+ x: this.toLocaleDateString(),
118
+ X: this.toLocaleTimeString(),
119
+ y: ('' + this.getFullYear()).substr(2, 4),
120
+ Y: '' + this.getFullYear(),
121
+ '%': '%',
122
+ }
123
+ let result = '',
124
+ i = 0
125
+ while (i < format.length) {
126
+ if (format.charAt(i) === '%') {
127
+ result += fields[format.charAt(i + 1)]
128
+ ++i
129
+ } else {
130
+ result += format.charAt(i)
131
+ }
132
+ ++i
133
+ }
134
+ return result
135
+ }
136
+
137
+ // ----------------------------------------------------------------------------
138
+ // String object extensions
139
+ // ----------------------------------------------------------------------------
140
+ String.prototype.strptime = function (format) {
141
+ const split_format = format.split(/[.\-/]/)
142
+ const date = this.split(/[.\-/]/)
143
+ let i = 0
144
+ let day, month, year
145
+ while (i < split_format.length) {
146
+ switch (split_format[i]) {
147
+ case '%d':
148
+ day = date[i]
149
+ break
150
+ case '%m':
151
+ month = date[i] - 1
152
+ break
153
+ case '%Y':
154
+ year = date[i]
155
+ break
156
+ case '%y':
157
+ // A %y value in the range of [00, 68] is in the current
158
+ // century, while [69, 99] is in the previous century,
159
+ // according to the Open Group Specification.
160
+ if (parseInt(date[i], 10) >= 69) {
161
+ year = date[i]
162
+ } else {
163
+ year = new Date(Date.UTC(date[i], 0)).getUTCFullYear() + 100
164
+ }
165
+ break
166
+ }
167
+ ++i
168
+ }
169
+ // Create Date object from UTC since the parsed value is supposed to be
170
+ // in UTC, not local time. Also, the calendar uses UTC functions for
171
+ // date extraction.
172
+ return new Date(Date.UTC(year, month, day))
173
+ }
174
+ }
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Persist changelist filters state (collapsed/expanded).
3
+ */
4
+ 'use strict'
5
+ {
6
+ // Init filters.
7
+ let filters = JSON.parse(sessionStorage.getItem('django.admin.filtersState'))
8
+
9
+ if (!filters) {
10
+ filters = {}
11
+ }
12
+
13
+ Object.entries(filters).forEach(([key, value]) => {
14
+ const detailElement = document.querySelector(
15
+ `[data-filter-title='${CSS.escape(key)}']`
16
+ )
17
+
18
+ // Check if the filter is present, it could be from other view.
19
+ if (detailElement) {
20
+ value
21
+ ? detailElement.setAttribute('open', '')
22
+ : detailElement.removeAttribute('open')
23
+ }
24
+ })
25
+
26
+ // Save filter state when clicks.
27
+ const details = document.querySelectorAll('details')
28
+ details.forEach((detail) => {
29
+ detail.addEventListener('toggle', (event) => {
30
+ filters[`${event.target.dataset.filterTitle}`] = detail.open
31
+ sessionStorage.setItem(
32
+ 'django.admin.filtersState',
33
+ JSON.stringify(filters)
34
+ )
35
+ })
36
+ })
37
+ }
@@ -0,0 +1,439 @@
1
+ /*global DateTimeShortcuts, SelectFilter*/
2
+ /**
3
+ * Django admin inlines
4
+ *
5
+ * Based on jQuery Formset 1.1
6
+ * @author Stanislaus Madueke (stan DOT madueke AT gmail DOT com)
7
+ * @requires jQuery 1.2.6 or later
8
+ *
9
+ * Copyright (c) 2009, Stanislaus Madueke
10
+ * All rights reserved.
11
+ *
12
+ * Spiced up with Code from Zain Memon's GSoC project 2009
13
+ * and modified for Django by Jannis Leidel, Travis Swicegood and Julien Phalip.
14
+ *
15
+ * Licensed under the New BSD License
16
+ * See: https://opensource.org/licenses/bsd-license.php
17
+ */
18
+ 'use strict'
19
+ {
20
+ const $ = django.jQuery
21
+ $.fn.formset = function (opts) {
22
+ const options = $.extend({}, $.fn.formset.defaults, opts)
23
+ const $this = $(this)
24
+ const $parent = $this.parent()
25
+ const updateElementIndex = function (el, prefix, ndx) {
26
+ const id_regex = new RegExp('(' + prefix + '-(\\d+|__prefix__))')
27
+ const replacement = prefix + '-' + ndx
28
+ if ($(el).prop('for')) {
29
+ $(el).prop('for', $(el).prop('for').replace(id_regex, replacement))
30
+ }
31
+ if (el.id) {
32
+ el.id = el.id.replace(id_regex, replacement)
33
+ }
34
+ if (el.name) {
35
+ el.name = el.name.replace(id_regex, replacement)
36
+ }
37
+ }
38
+ const totalForms = $('#id_' + options.prefix + '-TOTAL_FORMS').prop(
39
+ 'autocomplete',
40
+ 'off'
41
+ )
42
+ let nextIndex = parseInt(totalForms.val(), 10)
43
+ const maxForms = $('#id_' + options.prefix + '-MAX_NUM_FORMS').prop(
44
+ 'autocomplete',
45
+ 'off'
46
+ )
47
+ const minForms = $('#id_' + options.prefix + '-MIN_NUM_FORMS').prop(
48
+ 'autocomplete',
49
+ 'off'
50
+ )
51
+ let addButton
52
+
53
+ /**
54
+ * The "Add another MyModel" button below the inline forms.
55
+ */
56
+ const addInlineAddButton = function () {
57
+ if (addButton === null) {
58
+ if ($this.prop('tagName') === 'TR') {
59
+ // If forms are laid out as table rows, insert the
60
+ // "add" button in a new table row:
61
+ const numCols = $this.eq(-1).children().length
62
+ $parent.append(
63
+ '<tr class="' +
64
+ options.addCssClass +
65
+ '"><td colspan="' +
66
+ numCols +
67
+ '"><a href="#">' +
68
+ options.addText +
69
+ '</a></tr>'
70
+ )
71
+ addButton = $parent.find('tr:last a')
72
+ } else {
73
+ // Otherwise, insert it immediately after the last form:
74
+ $this
75
+ .filter(':last')
76
+ .after(
77
+ '<div class="' +
78
+ options.addCssClass +
79
+ '"><a href="#">' +
80
+ options.addText +
81
+ '</a></div>'
82
+ )
83
+ addButton = $this.filter(':last').next().find('a')
84
+ }
85
+ }
86
+ addButton.on('click', addInlineClickHandler)
87
+ }
88
+
89
+ const addInlineClickHandler = function (e) {
90
+ e.preventDefault()
91
+ const template = $('#' + options.prefix + '-empty')
92
+ const row = template.clone(true)
93
+ row
94
+ .removeClass(options.emptyCssClass)
95
+ .addClass(options.formCssClass)
96
+ .attr('id', options.prefix + '-' + nextIndex)
97
+ addInlineDeleteButton(row)
98
+ row.find('*').each(function () {
99
+ updateElementIndex(this, options.prefix, totalForms.val())
100
+ })
101
+ // Insert the new form when it has been fully edited.
102
+ row.insertBefore($(template))
103
+ // Update number of total forms.
104
+ $(totalForms).val(parseInt(totalForms.val(), 10) + 1)
105
+ nextIndex += 1
106
+ // Hide the add button if there's a limit and it's been reached.
107
+ if (maxForms.val() !== '' && maxForms.val() - totalForms.val() <= 0) {
108
+ addButton.parent().hide()
109
+ }
110
+ // Show the remove buttons if there are more than min_num.
111
+ toggleDeleteButtonVisibility(row.closest('.inline-group'))
112
+
113
+ // Pass the new form to the post-add callback, if provided.
114
+ if (options.added) {
115
+ options.added(row)
116
+ }
117
+ row.get(0).dispatchEvent(
118
+ new CustomEvent('formset:added', {
119
+ bubbles: true,
120
+ detail: {
121
+ formsetName: options.prefix,
122
+ },
123
+ })
124
+ )
125
+ }
126
+
127
+ /**
128
+ * The "X" button that is part of every unsaved inline.
129
+ * (When saved, it is replaced with a "Delete" checkbox.)
130
+ */
131
+ const addInlineDeleteButton = function (row) {
132
+ if (row.is('tr')) {
133
+ // If the forms are laid out in table rows, insert
134
+ // the remove button into the last table cell:
135
+ row
136
+ .children(':last')
137
+ .append(
138
+ '<div><a class="' +
139
+ options.deleteCssClass +
140
+ '" href="#">' +
141
+ options.deleteText +
142
+ '</a></div>'
143
+ )
144
+ } else if (row.is('ul') || row.is('ol')) {
145
+ // If they're laid out as an ordered/unordered list,
146
+ // insert an <li> after the last list item:
147
+ row.append(
148
+ '<li><a class="' +
149
+ options.deleteCssClass +
150
+ '" href="#">' +
151
+ options.deleteText +
152
+ '</a></li>'
153
+ )
154
+ } else {
155
+ // Otherwise, just insert the remove button as the
156
+ // last child element of the form's container:
157
+ row
158
+ .children(':first')
159
+ .append(
160
+ '<span><a class="' +
161
+ options.deleteCssClass +
162
+ '" href="#">' +
163
+ options.deleteText +
164
+ '</a></span>'
165
+ )
166
+ }
167
+ // Add delete handler for each row.
168
+ row
169
+ .find('a.' + options.deleteCssClass)
170
+ .on('click', inlineDeleteHandler.bind(this))
171
+ }
172
+
173
+ const inlineDeleteHandler = function (e1) {
174
+ e1.preventDefault()
175
+ const deleteButton = $(e1.target)
176
+ const row = deleteButton.closest('.' + options.formCssClass)
177
+ const inlineGroup = row.closest('.inline-group')
178
+ // Remove the parent form containing this button,
179
+ // and also remove the relevant row with non-field errors:
180
+ const prevRow = row.prev()
181
+ if (prevRow.length && prevRow.hasClass('row-form-errors')) {
182
+ prevRow.remove()
183
+ }
184
+ row.remove()
185
+ nextIndex -= 1
186
+ // Pass the deleted form to the post-delete callback, if provided.
187
+ if (options.removed) {
188
+ options.removed(row)
189
+ }
190
+ document.dispatchEvent(
191
+ new CustomEvent('formset:removed', {
192
+ detail: {
193
+ formsetName: options.prefix,
194
+ },
195
+ })
196
+ )
197
+ // Update the TOTAL_FORMS form count.
198
+ const forms = $('.' + options.formCssClass)
199
+ $('#id_' + options.prefix + '-TOTAL_FORMS').val(forms.length)
200
+ // Show add button again once below maximum number.
201
+ if (maxForms.val() === '' || maxForms.val() - forms.length > 0) {
202
+ addButton.parent().show()
203
+ }
204
+ // Hide the remove buttons if at min_num.
205
+ toggleDeleteButtonVisibility(inlineGroup)
206
+ // Also, update names and ids for all remaining form controls so
207
+ // they remain in sequence:
208
+ let i, formCount
209
+ const updateElementCallback = function () {
210
+ updateElementIndex(this, options.prefix, i)
211
+ }
212
+ for (i = 0, formCount = forms.length; i < formCount; i++) {
213
+ updateElementIndex($(forms).get(i), options.prefix, i)
214
+ $(forms.get(i)).find('*').each(updateElementCallback)
215
+ }
216
+ }
217
+
218
+ const toggleDeleteButtonVisibility = function (inlineGroup) {
219
+ if (minForms.val() !== '' && minForms.val() - totalForms.val() >= 0) {
220
+ inlineGroup.find('.inline-deletelink').hide()
221
+ } else {
222
+ inlineGroup.find('.inline-deletelink').show()
223
+ }
224
+ }
225
+
226
+ $this.each(function (i) {
227
+ $(this)
228
+ .not('.' + options.emptyCssClass)
229
+ .addClass(options.formCssClass)
230
+ })
231
+
232
+ // Create the delete buttons for all unsaved inlines:
233
+ $this
234
+ .filter(
235
+ '.' +
236
+ options.formCssClass +
237
+ ':not(.has_original):not(.' +
238
+ options.emptyCssClass +
239
+ ')'
240
+ )
241
+ .each(function () {
242
+ addInlineDeleteButton($(this))
243
+ })
244
+ toggleDeleteButtonVisibility($this)
245
+
246
+ // Create the add button, initially hidden.
247
+ addButton = options.addButton
248
+ addInlineAddButton()
249
+
250
+ // Show the add button if allowed to add more items.
251
+ // Note that max_num = None translates to a blank string.
252
+ const showAddButton =
253
+ maxForms.val() === '' || maxForms.val() - totalForms.val() > 0
254
+ if ($this.length && showAddButton) {
255
+ addButton.parent().show()
256
+ } else {
257
+ addButton.parent().hide()
258
+ }
259
+
260
+ return this
261
+ }
262
+
263
+ /* Setup plugin defaults */
264
+ $.fn.formset.defaults = {
265
+ prefix: 'form', // The form prefix for your django formset
266
+ addText: 'add another', // Text for the add link
267
+ deleteText: 'remove', // Text for the delete link
268
+ addCssClass: 'add-row', // CSS class applied to the add link
269
+ deleteCssClass: 'delete-row', // CSS class applied to the delete link
270
+ emptyCssClass: 'empty-row', // CSS class applied to the empty row
271
+ formCssClass: 'dynamic-form', // CSS class applied to each form in a formset
272
+ added: null, // Function called each time a new form is added
273
+ removed: null, // Function called each time a form is deleted
274
+ addButton: null, // Existing add button to use
275
+ }
276
+
277
+ // Tabular inlines ---------------------------------------------------------
278
+ $.fn.tabularFormset = function (selector, options) {
279
+ const $rows = $(this)
280
+
281
+ const reinitDateTimeShortCuts = function () {
282
+ // Reinitialize the calendar and clock widgets by force
283
+ if (typeof DateTimeShortcuts !== 'undefined') {
284
+ $('.datetimeshortcuts').remove()
285
+ DateTimeShortcuts.init()
286
+ }
287
+ }
288
+
289
+ const updateSelectFilter = function () {
290
+ // If any SelectFilter widgets are a part of the new form,
291
+ // instantiate a new SelectFilter instance for it.
292
+ if (typeof SelectFilter !== 'undefined') {
293
+ $('.selectfilter').each(function (index, value) {
294
+ SelectFilter.init(value.id, this.dataset.fieldName, false)
295
+ })
296
+ $('.selectfilterstacked').each(function (index, value) {
297
+ SelectFilter.init(value.id, this.dataset.fieldName, true)
298
+ })
299
+ }
300
+ }
301
+
302
+ const initPrepopulatedFields = function (row) {
303
+ row.find('.prepopulated_field').each(function () {
304
+ const field = $(this),
305
+ input = field.find('input, select, textarea'),
306
+ dependency_list = input.data('dependency_list') || [],
307
+ dependencies = []
308
+ $.each(dependency_list, function (i, field_name) {
309
+ dependencies.push(
310
+ '#' +
311
+ row
312
+ .find('.field-' + field_name)
313
+ .find('input, select, textarea')
314
+ .attr('id')
315
+ )
316
+ })
317
+ if (dependencies.length) {
318
+ input.prepopulate(dependencies, input.attr('maxlength'))
319
+ }
320
+ })
321
+ }
322
+
323
+ $rows.formset({
324
+ prefix: options.prefix,
325
+ addText: options.addText,
326
+ formCssClass: 'dynamic-' + options.prefix,
327
+ deleteCssClass: 'inline-deletelink',
328
+ deleteText: options.deleteText,
329
+ emptyCssClass: 'empty-form',
330
+ added: function (row) {
331
+ initPrepopulatedFields(row)
332
+ reinitDateTimeShortCuts()
333
+ updateSelectFilter()
334
+ },
335
+ addButton: options.addButton,
336
+ })
337
+
338
+ return $rows
339
+ }
340
+
341
+ // Stacked inlines ---------------------------------------------------------
342
+ $.fn.stackedFormset = function (selector, options) {
343
+ const $rows = $(this)
344
+ const updateInlineLabel = function (row) {
345
+ $(selector)
346
+ .find('.inline_label')
347
+ .each(function (i) {
348
+ const count = i + 1
349
+ $(this).html(
350
+ $(this)
351
+ .html()
352
+ .replace(/(#\d+)/g, '#' + count)
353
+ )
354
+ })
355
+ }
356
+
357
+ const reinitDateTimeShortCuts = function () {
358
+ // Reinitialize the calendar and clock widgets by force, yuck.
359
+ if (typeof DateTimeShortcuts !== 'undefined') {
360
+ $('.datetimeshortcuts').remove()
361
+ DateTimeShortcuts.init()
362
+ }
363
+ }
364
+
365
+ const updateSelectFilter = function () {
366
+ // If any SelectFilter widgets were added, instantiate a new instance.
367
+ if (typeof SelectFilter !== 'undefined') {
368
+ $('.selectfilter').each(function (index, value) {
369
+ SelectFilter.init(value.id, this.dataset.fieldName, false)
370
+ })
371
+ $('.selectfilterstacked').each(function (index, value) {
372
+ SelectFilter.init(value.id, this.dataset.fieldName, true)
373
+ })
374
+ }
375
+ }
376
+
377
+ const initPrepopulatedFields = function (row) {
378
+ row.find('.prepopulated_field').each(function () {
379
+ const field = $(this),
380
+ input = field.find('input, select, textarea'),
381
+ dependency_list = input.data('dependency_list') || [],
382
+ dependencies = []
383
+ $.each(dependency_list, function (i, field_name) {
384
+ // Dependency in a fieldset.
385
+ let field_element = row.find('.form-row .field-' + field_name)
386
+ // Dependency without a fieldset.
387
+ if (!field_element.length) {
388
+ field_element = row.find('.form-row.field-' + field_name)
389
+ }
390
+ dependencies.push(
391
+ '#' + field_element.find('input, select, textarea').attr('id')
392
+ )
393
+ })
394
+ if (dependencies.length) {
395
+ input.prepopulate(dependencies, input.attr('maxlength'))
396
+ }
397
+ })
398
+ }
399
+
400
+ $rows.formset({
401
+ prefix: options.prefix,
402
+ addText: options.addText,
403
+ formCssClass: 'dynamic-' + options.prefix,
404
+ deleteCssClass: 'inline-deletelink',
405
+ deleteText: options.deleteText,
406
+ emptyCssClass: 'empty-form',
407
+ removed: updateInlineLabel,
408
+ added: function (row) {
409
+ initPrepopulatedFields(row)
410
+ reinitDateTimeShortCuts()
411
+ updateSelectFilter()
412
+ updateInlineLabel(row)
413
+ },
414
+ addButton: options.addButton,
415
+ })
416
+
417
+ return $rows
418
+ }
419
+
420
+ $(document).ready(function () {
421
+ $('.js-inline-admin-formset').each(function () {
422
+ const data = $(this).data(),
423
+ inlineOptions = data.inlineFormset
424
+ let selector
425
+ switch (data.inlineType) {
426
+ case 'stacked':
427
+ selector = inlineOptions.name + '-group .inline-related'
428
+ $(selector).stackedFormset(selector, inlineOptions.options)
429
+ break
430
+ case 'tabular':
431
+ selector =
432
+ inlineOptions.name +
433
+ '-group .tabular.inline-related tbody:first > tr.form-row'
434
+ $(selector).tabularFormset(selector, inlineOptions.options)
435
+ break
436
+ }
437
+ })
438
+ })
439
+ }
@@ -0,0 +1,8 @@
1
+ /*global jQuery:false*/
2
+ 'use strict'
3
+ /* Puts the included jQuery into our own namespace using noConflict and passing
4
+ * it 'true'. This ensures that the included jQuery doesn't pollute the global
5
+ * namespace (i.e. this preserves pre-existing values for both window.$ and
6
+ * window.jQuery).
7
+ */
8
+ window.django = { jQuery: jQuery.noConflict(true) }