fnschool 20250109.80531.837__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.
- fnschoo1/__init__.py +52 -0
- fnschoo1/canteen/admin.py +3 -0
- fnschoo1/canteen/apps.py +6 -0
- fnschoo1/canteen/forms.py +84 -0
- fnschoo1/canteen/migrations/0001_initial.py +119 -0
- fnschoo1/canteen/migrations/0002_ingredient_is_disabled.py +20 -0
- fnschoo1/canteen/migrations/0003_consumption_is_disabled_alter_ingredient_is_disabled.py +23 -0
- fnschoo1/canteen/migrations/0004_alter_ingredient_name_category_and_more.py +66 -0
- fnschoo1/canteen/migrations/0005_alter_category_created_at_alter_category_name_and_more.py +41 -0
- fnschoo1/canteen/migrations/0006_category_is_disabled_alter_category_user_and_more.py +49 -0
- fnschoo1/canteen/migrations/0007_alter_consumption_amount_used_and_more.py +30 -0
- fnschoo1/canteen/migrations/0008_category_abbreviation_mealtype.py +67 -0
- fnschoo1/canteen/migrations/0009_alter_category_abbreviation_and_more.py +55 -0
- fnschoo1/canteen/migrations/0010_alter_consumption_options_alter_ingredient_options_and_more.py +215 -0
- fnschoo1/canteen/migrations/0011_category_pin_to_consumptions_top.py +23 -0
- fnschoo1/canteen/migrations/0012_alter_ingredient_storage_date.py +18 -0
- fnschoo1/canteen/models.py +179 -0
- fnschoo1/canteen/templates/canteen/category/create.html +17 -0
- fnschoo1/canteen/templates/canteen/category/delete.html +61 -0
- fnschoo1/canteen/templates/canteen/category/list.html +63 -0
- fnschoo1/canteen/templates/canteen/category/update.html +23 -0
- fnschoo1/canteen/templates/canteen/close.html +11 -0
- fnschoo1/canteen/templates/canteen/consumption/_create.html +19 -0
- fnschoo1/canteen/templates/canteen/consumption/create.html +456 -0
- fnschoo1/canteen/templates/canteen/ingredient/close.html +11 -0
- fnschoo1/canteen/templates/canteen/ingredient/create.html +19 -0
- fnschoo1/canteen/templates/canteen/ingredient/create_one.html +17 -0
- fnschoo1/canteen/templates/canteen/ingredient/delete.html +41 -0
- fnschoo1/canteen/templates/canteen/ingredient/list.html +128 -0
- fnschoo1/canteen/templates/canteen/ingredient/update.html +23 -0
- fnschoo1/canteen/templates/canteen/meal_type/create.html +17 -0
- fnschoo1/canteen/templates/canteen/meal_type/delete.html +56 -0
- fnschoo1/canteen/templates/canteen/meal_type/list.html +59 -0
- fnschoo1/canteen/templates/canteen/meal_type/update.html +23 -0
- fnschoo1/canteen/tests.py +3 -0
- fnschoo1/canteen/urls.py +116 -0
- fnschoo1/canteen/views.py +814 -0
- fnschoo1/canteen/workbook/generate.py +2098 -0
- fnschoo1/db.sqlite3 +0 -0
- fnschoo1/fnschool/__init__.py +13 -0
- fnschoo1/fnschool/asgi.py +16 -0
- fnschoo1/fnschool/settings.py +167 -0
- fnschoo1/fnschool/templatetags/fnschool_tags.py +27 -0
- fnschoo1/fnschool/urls.py +30 -0
- fnschoo1/fnschool/views.py +9 -0
- fnschoo1/fnschool/wsgi.py +16 -0
- fnschoo1/locale/en/LC_MESSAGES/django.mo +0 -0
- fnschoo1/locale/zh_Hans/LC_MESSAGES/django.mo +0 -0
- fnschoo1/manage.py +25 -0
- fnschoo1/profiles/admin.py +27 -0
- fnschoo1/profiles/apps.py +12 -0
- fnschoo1/profiles/forms.py +67 -0
- fnschoo1/profiles/migrations/0001_initial.py +192 -0
- fnschoo1/profiles/migrations/0002_alter_profile_bio.py +20 -0
- fnschoo1/profiles/migrations/0003_alter_profile_options_alter_profile_address_and_more.py +67 -0
- fnschoo1/profiles/migrations/0004_profile_gender.py +26 -0
- fnschoo1/profiles/migrations/0005_alter_profile_gender.py +23 -0
- fnschoo1/profiles/models.py +60 -0
- fnschoo1/profiles/signals.py +20 -0
- fnschoo1/profiles/templates/profiles/create.html +16 -0
- fnschoo1/profiles/templates/profiles/detail.html +14 -0
- fnschoo1/profiles/templates/profiles/edit.html +12 -0
- fnschoo1/profiles/templates/profiles/log_in.html +20 -0
- fnschoo1/profiles/templates/profiles/log_out.html +12 -0
- fnschoo1/profiles/tests.py +3 -0
- fnschoo1/profiles/urls.py +15 -0
- fnschoo1/profiles/views.py +63 -0
- fnschoo1/static/css/bootstrap.min.css +11776 -0
- fnschoo1/static/css/fnschool.css +26 -0
- fnschoo1/static/js/bootstrap.bundle.min.js +4223 -0
- fnschoo1/static/js/bootstrap.min.js +2919 -0
- fnschoo1/static/js/fnschool.js +84 -0
- fnschoo1/static/js/jquery.min.js +5413 -0
- fnschoo1/static/js/jquery.slim.min.js +4331 -0
- fnschoo1/static/js/popper.min.js +1306 -0
- fnschoo1/static_collected/admin/css/autocomplete.css +377 -0
- fnschoo1/static_collected/admin/css/base.css +1224 -0
- fnschoo1/static_collected/admin/css/changelists.css +334 -0
- fnschoo1/static_collected/admin/css/dark_mode.css +136 -0
- fnschoo1/static_collected/admin/css/dashboard.css +30 -0
- fnschoo1/static_collected/admin/css/forms.css +546 -0
- fnschoo1/static_collected/admin/css/login.css +62 -0
- fnschoo1/static_collected/admin/css/nav_sidebar.css +145 -0
- fnschoo1/static_collected/admin/css/responsive.css +1043 -0
- fnschoo1/static_collected/admin/css/responsive_rtl.css +84 -0
- fnschoo1/static_collected/admin/css/rtl.css +311 -0
- fnschoo1/static_collected/admin/css/vendor/select2/select2.css +708 -0
- fnschoo1/static_collected/admin/css/vendor/select2/select2.min.css +1 -0
- fnschoo1/static_collected/admin/css/widgets.css +639 -0
- fnschoo1/static_collected/admin/js/SelectBox.js +128 -0
- fnschoo1/static_collected/admin/js/SelectFilter2.js +503 -0
- fnschoo1/static_collected/admin/js/actions.js +232 -0
- fnschoo1/static_collected/admin/js/admin/DateTimeShortcuts.js +496 -0
- fnschoo1/static_collected/admin/js/admin/RelatedObjectLookups.js +276 -0
- fnschoo1/static_collected/admin/js/autocomplete.js +33 -0
- fnschoo1/static_collected/admin/js/calendar.js +251 -0
- fnschoo1/static_collected/admin/js/cancel.js +29 -0
- fnschoo1/static_collected/admin/js/change_form.js +21 -0
- fnschoo1/static_collected/admin/js/collapse.js +43 -0
- fnschoo1/static_collected/admin/js/core.js +174 -0
- fnschoo1/static_collected/admin/js/filters.js +37 -0
- fnschoo1/static_collected/admin/js/inlines.js +439 -0
- fnschoo1/static_collected/admin/js/jquery.init.js +8 -0
- fnschoo1/static_collected/admin/js/nav_sidebar.js +81 -0
- fnschoo1/static_collected/admin/js/popup_response.js +24 -0
- fnschoo1/static_collected/admin/js/prepopulate.js +43 -0
- fnschoo1/static_collected/admin/js/prepopulate_init.js +20 -0
- fnschoo1/static_collected/admin/js/theme.js +57 -0
- fnschoo1/static_collected/admin/js/urlify.js +529 -0
- fnschoo1/static_collected/admin/js/vendor/jquery/jquery.js +10913 -0
- fnschoo1/static_collected/admin/js/vendor/jquery/jquery.min.js +2 -0
- fnschoo1/static_collected/admin/js/vendor/select2/i18n/af.js +43 -0
- fnschoo1/static_collected/admin/js/vendor/select2/i18n/ar.js +36 -0
- fnschoo1/static_collected/admin/js/vendor/select2/i18n/az.js +33 -0
- fnschoo1/static_collected/admin/js/vendor/select2/i18n/bg.js +38 -0
- fnschoo1/static_collected/admin/js/vendor/select2/i18n/bn.js +39 -0
- fnschoo1/static_collected/admin/js/vendor/select2/i18n/bs.js +48 -0
- fnschoo1/static_collected/admin/js/vendor/select2/i18n/ca.js +41 -0
- fnschoo1/static_collected/admin/js/vendor/select2/i18n/cs.js +62 -0
- fnschoo1/static_collected/admin/js/vendor/select2/i18n/da.js +37 -0
- fnschoo1/static_collected/admin/js/vendor/select2/i18n/de.js +41 -0
- fnschoo1/static_collected/admin/js/vendor/select2/i18n/dsb.js +51 -0
- fnschoo1/static_collected/admin/js/vendor/select2/i18n/el.js +43 -0
- fnschoo1/static_collected/admin/js/vendor/select2/i18n/en.js +41 -0
- fnschoo1/static_collected/admin/js/vendor/select2/i18n/es.js +41 -0
- fnschoo1/static_collected/admin/js/vendor/select2/i18n/et.js +38 -0
- fnschoo1/static_collected/admin/js/vendor/select2/i18n/eu.js +45 -0
- fnschoo1/static_collected/admin/js/vendor/select2/i18n/fa.js +42 -0
- fnschoo1/static_collected/admin/js/vendor/select2/i18n/fi.js +42 -0
- fnschoo1/static_collected/admin/js/vendor/select2/i18n/fr.js +43 -0
- fnschoo1/static_collected/admin/js/vendor/select2/i18n/gl.js +40 -0
- fnschoo1/static_collected/admin/js/vendor/select2/i18n/he.js +44 -0
- fnschoo1/static_collected/admin/js/vendor/select2/i18n/hi.js +40 -0
- fnschoo1/static_collected/admin/js/vendor/select2/i18n/hr.js +45 -0
- fnschoo1/static_collected/admin/js/vendor/select2/i18n/hsb.js +51 -0
- fnschoo1/static_collected/admin/js/vendor/select2/i18n/hu.js +44 -0
- fnschoo1/static_collected/admin/js/vendor/select2/i18n/hy.js +40 -0
- fnschoo1/static_collected/admin/js/vendor/select2/i18n/id.js +36 -0
- fnschoo1/static_collected/admin/js/vendor/select2/i18n/is.js +37 -0
- fnschoo1/static_collected/admin/js/vendor/select2/i18n/it.js +43 -0
- fnschoo1/static_collected/admin/js/vendor/select2/i18n/ja.js +40 -0
- fnschoo1/static_collected/admin/js/vendor/select2/i18n/ka.js +42 -0
- fnschoo1/static_collected/admin/js/vendor/select2/i18n/km.js +38 -0
- fnschoo1/static_collected/admin/js/vendor/select2/i18n/ko.js +42 -0
- fnschoo1/static_collected/admin/js/vendor/select2/i18n/lt.js +45 -0
- fnschoo1/static_collected/admin/js/vendor/select2/i18n/lv.js +41 -0
- fnschoo1/static_collected/admin/js/vendor/select2/i18n/mk.js +42 -0
- fnschoo1/static_collected/admin/js/vendor/select2/i18n/ms.js +38 -0
- fnschoo1/static_collected/admin/js/vendor/select2/i18n/nb.js +38 -0
- fnschoo1/static_collected/admin/js/vendor/select2/i18n/ne.js +44 -0
- fnschoo1/static_collected/admin/js/vendor/select2/i18n/nl.js +46 -0
- fnschoo1/static_collected/admin/js/vendor/select2/i18n/pl.js +43 -0
- fnschoo1/static_collected/admin/js/vendor/select2/i18n/ps.js +41 -0
- fnschoo1/static_collected/admin/js/vendor/select2/i18n/pt-BR.js +39 -0
- fnschoo1/static_collected/admin/js/vendor/select2/i18n/pt.js +41 -0
- fnschoo1/static_collected/admin/js/vendor/select2/i18n/ro.js +43 -0
- fnschoo1/static_collected/admin/js/vendor/select2/i18n/ru.js +48 -0
- fnschoo1/static_collected/admin/js/vendor/select2/i18n/sk.js +61 -0
- fnschoo1/static_collected/admin/js/vendor/select2/i18n/sl.js +41 -0
- fnschoo1/static_collected/admin/js/vendor/select2/i18n/sq.js +43 -0
- fnschoo1/static_collected/admin/js/vendor/select2/i18n/sr-Cyrl.js +48 -0
- fnschoo1/static_collected/admin/js/vendor/select2/i18n/sr.js +48 -0
- fnschoo1/static_collected/admin/js/vendor/select2/i18n/sv.js +40 -0
- fnschoo1/static_collected/admin/js/vendor/select2/i18n/th.js +36 -0
- fnschoo1/static_collected/admin/js/vendor/select2/i18n/tk.js +36 -0
- fnschoo1/static_collected/admin/js/vendor/select2/i18n/tr.js +40 -0
- fnschoo1/static_collected/admin/js/vendor/select2/i18n/uk.js +59 -0
- fnschoo1/static_collected/admin/js/vendor/select2/i18n/vi.js +37 -0
- fnschoo1/static_collected/admin/js/vendor/select2/i18n/zh-CN.js +36 -0
- fnschoo1/static_collected/admin/js/vendor/select2/i18n/zh-TW.js +33 -0
- fnschoo1/static_collected/admin/js/vendor/select2/select2.full.js +7115 -0
- fnschoo1/static_collected/admin/js/vendor/select2/select2.full.min.js +2 -0
- fnschoo1/static_collected/admin/js/vendor/xregexp/xregexp.js +4993 -0
- fnschoo1/static_collected/admin/js/vendor/xregexp/xregexp.min.js +160 -0
- fnschoo1/static_collected/css/bootstrap.min.css +11776 -0
- fnschoo1/static_collected/css/fnschool.css +26 -0
- fnschoo1/static_collected/js/bootstrap.bundle.min.js +4223 -0
- fnschoo1/static_collected/js/bootstrap.min.js +2919 -0
- fnschoo1/static_collected/js/fnschool.js +84 -0
- fnschoo1/static_collected/js/jquery.min.js +5413 -0
- fnschoo1/static_collected/js/jquery.slim.min.js +4331 -0
- fnschoo1/static_collected/js/popper.min.js +1306 -0
- fnschoo1/templates/base/_css.html +1 -0
- fnschoo1/templates/base/_js.html +15 -0
- fnschoo1/templates/base/content.html +30 -0
- fnschoo1/templates/base/header_content_footer.html +35 -0
- fnschoo1/templates/close.html +11 -0
- fnschoo1/templates/home.html +51 -0
- fnschoo1/templates/includes/_footer.html +39 -0
- fnschoo1/templates/includes/_header.html +77 -0
- fnschoo1/templates/includes/_navigation.html +0 -0
- fnschoo1/templates/includes/_paginator.html +27 -0
- fnschoo1/templates/registration/logged_out.html +0 -0
- fnschoo1/templates/registration/login.html +0 -0
- fnschool-20251011.80531.840.dist-info/METADATA +179 -0
- fnschool-20251011.80531.840.dist-info/RECORD +207 -0
- {fnschool-20250109.80531.837.dist-info → fnschool-20251011.80531.840.dist-info}/WHEEL +1 -1
- fnschool-20251011.80531.840.dist-info/entry_points.txt +2 -0
- fnschool-20251011.80531.840.dist-info/top_level.txt +1 -0
- fnschool/__init__.py +0 -35
- fnschool/__main__.py +0 -16
- fnschool/app.py +0 -103
- fnschool/canteen/__init__.py +0 -3
- fnschool/canteen/__main__.py +0 -3
- fnschool/canteen/bill.py +0 -253
- fnschool/canteen/canteen.py +0 -1
- fnschool/canteen/canteen.toml +0 -61
- fnschool/canteen/config.py +0 -10
- fnschool/canteen/consuming.py +0 -53
- fnschool/canteen/currency.py +0 -17
- fnschool/canteen/data/bill.i18n.xlsx +0 -0
- fnschool/canteen/data/bill.xlsx +0 -0
- fnschool/canteen/data/consuming.xlsx +0 -0
- fnschool/canteen/data/purchase_list.xlsx +0 -0
- fnschool/canteen/entry.py +0 -40
- fnschool/canteen/food.py +0 -206
- fnschool/canteen/food_classes.py +0 -33
- fnschool/canteen/food_classes.toml +0 -64
- fnschool/canteen/operator.py +0 -91
- fnschool/canteen/path.py +0 -28
- fnschool/canteen/spreadsheet/base.py +0 -213
- fnschool/canteen/spreadsheet/consuming.py +0 -310
- fnschool/canteen/spreadsheet/consumingsum.py +0 -76
- fnschool/canteen/spreadsheet/cover.py +0 -64
- fnschool/canteen/spreadsheet/ctspreadsheet.py +0 -351
- fnschool/canteen/spreadsheet/food.py +0 -680
- fnschool/canteen/spreadsheet/inventory.py +0 -375
- fnschool/canteen/spreadsheet/merging.py +0 -340
- fnschool/canteen/spreadsheet/preconsuming.py +0 -329
- fnschool/canteen/spreadsheet/purchasing.py +0 -885
- fnschool/canteen/spreadsheet/purchasingsum.py +0 -110
- fnschool/canteen/spreadsheet/spreadsheet.py +0 -363
- fnschool/canteen/spreadsheet/translating.py +0 -12
- fnschool/canteen/spreadsheet/unwarehousing.py +0 -178
- fnschool/canteen/spreadsheet/unwarehousingsum.py +0 -11
- fnschool/canteen/spreadsheet/warehousing.py +0 -360
- fnschool/canteen/spreadsheet/workbook.py +0 -17
- fnschool/canteen/test.py +0 -97
- fnschool/config.py +0 -48
- fnschool/entry.py +0 -67
- fnschool/exam/__init__.py +0 -8
- fnschool/exam/data/parental_emails.xlsx +0 -0
- fnschool/exam/data/score.xlsx +0 -0
- fnschool/exam/email.py +0 -349
- fnschool/exam/entry.py +0 -36
- fnschool/exam/language.py +0 -19
- fnschool/exam/path.py +0 -24
- fnschool/exam/score.py +0 -1191
- fnschool/exam/subject.py +0 -20
- fnschool/exam/teacher.py +0 -54
- fnschool/external.py +0 -89
- fnschool/games/__init__.py +0 -1
- fnschool/games/__main__.py +0 -1
- fnschool/games/games.py +0 -1
- fnschool/inoutput.py +0 -97
- fnschool/language.py +0 -40
- fnschool/locales/en_US/LC_MESSAGES/fnschool.mo +0 -0
- fnschool/locales/zh_CN/LC_MESSAGES/fnschool.mo +0 -0
- fnschool/locales/zh_HK/LC_MESSAGES/fnschool.mo +0 -0
- fnschool/locales/zh_SG/LC_MESSAGES/fnschool.mo +0 -0
- fnschool/locales/zh_TW/LC_MESSAGES/fnschool.mo +0 -0
- fnschool/path.py +0 -45
- fnschool/test.py +0 -24
- fnschool/user.py +0 -262
- fnschool-20250109.80531.837.dist-info/METADATA +0 -342
- fnschool-20250109.80531.837.dist-info/RECORD +0 -78
- fnschool-20250109.80531.837.dist-info/entry_points.txt +0 -5
- fnschool-20250109.80531.837.dist-info/top_level.txt +0 -1
- /fnschool/canteen/consume.py → /fnschoo1/canteen/__init__.py +0 -0
- /fnschool/canteen/food_recount.toml → /fnschoo1/canteen/migrations/__init__.py +0 -0
- {fnschool/canteen/spreadsheet → fnschoo1/canteen/workbook}/__init__.py +0 -0
- /fnschool/exam/__main__.py → /fnschoo1/fnschool/templatetags/__init__.py +0 -0
- /fnschool/canteen/food_recounts.toml → /fnschoo1/profiles/__init__.py +0 -0
- /fnschool/canteen/warehouse.py → /fnschoo1/profiles/migrations/__init__.py +0 -0
- /fnschool/canteen/workbook.toml → /fnschoo1/templates/base/_content.html +0 -0
- {fnschool-20250109.80531.837.dist-info → fnschool-20251011.80531.840.dist-info/licenses}/LICENSE +0 -0
|
@@ -0,0 +1,496 @@
|
|
|
1
|
+
/*global Calendar, findPosX, findPosY, get_format, gettext, gettext_noop, interpolate, ngettext, quickElement*/
|
|
2
|
+
// Inserts shortcut buttons after all of the following:
|
|
3
|
+
// <input type="text" class="vDateField">
|
|
4
|
+
// <input type="text" class="vTimeField">
|
|
5
|
+
'use strict'
|
|
6
|
+
{
|
|
7
|
+
const DateTimeShortcuts = {
|
|
8
|
+
calendars: [],
|
|
9
|
+
calendarInputs: [],
|
|
10
|
+
clockInputs: [],
|
|
11
|
+
clockHours: {
|
|
12
|
+
default_: [
|
|
13
|
+
[gettext_noop('Now'), -1],
|
|
14
|
+
[gettext_noop('Midnight'), 0],
|
|
15
|
+
[gettext_noop('6 a.m.'), 6],
|
|
16
|
+
[gettext_noop('Noon'), 12],
|
|
17
|
+
[gettext_noop('6 p.m.'), 18],
|
|
18
|
+
],
|
|
19
|
+
},
|
|
20
|
+
dismissClockFunc: [],
|
|
21
|
+
dismissCalendarFunc: [],
|
|
22
|
+
calendarDivName1: 'calendarbox', // name of calendar <div> that gets toggled
|
|
23
|
+
calendarDivName2: 'calendarin', // name of <div> that contains calendar
|
|
24
|
+
calendarLinkName: 'calendarlink', // name of the link that is used to toggle
|
|
25
|
+
clockDivName: 'clockbox', // name of clock <div> that gets toggled
|
|
26
|
+
clockLinkName: 'clocklink', // name of the link that is used to toggle
|
|
27
|
+
shortCutsClass: 'datetimeshortcuts', // class of the clock and cal shortcuts
|
|
28
|
+
timezoneWarningClass: 'timezonewarning', // class of the warning for timezone mismatch
|
|
29
|
+
timezoneOffset: 0,
|
|
30
|
+
init: function () {
|
|
31
|
+
const serverOffset = document.body.dataset.adminUtcOffset
|
|
32
|
+
if (serverOffset) {
|
|
33
|
+
const localOffset = new Date().getTimezoneOffset() * -60
|
|
34
|
+
DateTimeShortcuts.timezoneOffset = localOffset - serverOffset
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
for (const inp of document.getElementsByTagName('input')) {
|
|
38
|
+
if (inp.type === 'text' && inp.classList.contains('vTimeField')) {
|
|
39
|
+
DateTimeShortcuts.addClock(inp)
|
|
40
|
+
DateTimeShortcuts.addTimezoneWarning(inp)
|
|
41
|
+
} else if (
|
|
42
|
+
inp.type === 'text' &&
|
|
43
|
+
inp.classList.contains('vDateField')
|
|
44
|
+
) {
|
|
45
|
+
DateTimeShortcuts.addCalendar(inp)
|
|
46
|
+
DateTimeShortcuts.addTimezoneWarning(inp)
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
// Return the current time while accounting for the server timezone.
|
|
51
|
+
now: function () {
|
|
52
|
+
const serverOffset = document.body.dataset.adminUtcOffset
|
|
53
|
+
if (serverOffset) {
|
|
54
|
+
const localNow = new Date()
|
|
55
|
+
const localOffset = localNow.getTimezoneOffset() * -60
|
|
56
|
+
localNow.setTime(
|
|
57
|
+
localNow.getTime() + 1000 * (serverOffset - localOffset)
|
|
58
|
+
)
|
|
59
|
+
return localNow
|
|
60
|
+
} else {
|
|
61
|
+
return new Date()
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
// Add a warning when the time zone in the browser and backend do not match.
|
|
65
|
+
addTimezoneWarning: function (inp) {
|
|
66
|
+
const warningClass = DateTimeShortcuts.timezoneWarningClass
|
|
67
|
+
let timezoneOffset = DateTimeShortcuts.timezoneOffset / 3600
|
|
68
|
+
|
|
69
|
+
// Only warn if there is a time zone mismatch.
|
|
70
|
+
if (!timezoneOffset) {
|
|
71
|
+
return
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Check if warning is already there.
|
|
75
|
+
if (inp.parentNode.querySelectorAll('.' + warningClass).length) {
|
|
76
|
+
return
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
let message
|
|
80
|
+
if (timezoneOffset > 0) {
|
|
81
|
+
message = ngettext(
|
|
82
|
+
'Note: You are %s hour ahead of server time.',
|
|
83
|
+
'Note: You are %s hours ahead of server time.',
|
|
84
|
+
timezoneOffset
|
|
85
|
+
)
|
|
86
|
+
} else {
|
|
87
|
+
timezoneOffset *= -1
|
|
88
|
+
message = ngettext(
|
|
89
|
+
'Note: You are %s hour behind server time.',
|
|
90
|
+
'Note: You are %s hours behind server time.',
|
|
91
|
+
timezoneOffset
|
|
92
|
+
)
|
|
93
|
+
}
|
|
94
|
+
message = interpolate(message, [timezoneOffset])
|
|
95
|
+
|
|
96
|
+
const warning = document.createElement('div')
|
|
97
|
+
warning.classList.add('help', warningClass)
|
|
98
|
+
warning.textContent = message
|
|
99
|
+
inp.parentNode.appendChild(warning)
|
|
100
|
+
},
|
|
101
|
+
// Add clock widget to a given field
|
|
102
|
+
addClock: function (inp) {
|
|
103
|
+
const num = DateTimeShortcuts.clockInputs.length
|
|
104
|
+
DateTimeShortcuts.clockInputs[num] = inp
|
|
105
|
+
DateTimeShortcuts.dismissClockFunc[num] = function () {
|
|
106
|
+
DateTimeShortcuts.dismissClock(num)
|
|
107
|
+
return true
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Shortcut links (clock icon and "Now" link)
|
|
111
|
+
const shortcuts_span = document.createElement('span')
|
|
112
|
+
shortcuts_span.className = DateTimeShortcuts.shortCutsClass
|
|
113
|
+
inp.parentNode.insertBefore(shortcuts_span, inp.nextSibling)
|
|
114
|
+
const now_link = document.createElement('a')
|
|
115
|
+
now_link.href = '#'
|
|
116
|
+
now_link.textContent = gettext('Now')
|
|
117
|
+
now_link.addEventListener('click', function (e) {
|
|
118
|
+
e.preventDefault()
|
|
119
|
+
DateTimeShortcuts.handleClockQuicklink(num, -1)
|
|
120
|
+
})
|
|
121
|
+
const clock_link = document.createElement('a')
|
|
122
|
+
clock_link.href = '#'
|
|
123
|
+
clock_link.id = DateTimeShortcuts.clockLinkName + num
|
|
124
|
+
clock_link.addEventListener('click', function (e) {
|
|
125
|
+
e.preventDefault()
|
|
126
|
+
// avoid triggering the document click handler to dismiss the clock
|
|
127
|
+
e.stopPropagation()
|
|
128
|
+
DateTimeShortcuts.openClock(num)
|
|
129
|
+
})
|
|
130
|
+
|
|
131
|
+
quickElement(
|
|
132
|
+
'span',
|
|
133
|
+
clock_link,
|
|
134
|
+
'',
|
|
135
|
+
'class',
|
|
136
|
+
'clock-icon',
|
|
137
|
+
'title',
|
|
138
|
+
gettext('Choose a Time')
|
|
139
|
+
)
|
|
140
|
+
shortcuts_span.appendChild(document.createTextNode('\u00A0'))
|
|
141
|
+
shortcuts_span.appendChild(now_link)
|
|
142
|
+
shortcuts_span.appendChild(document.createTextNode('\u00A0|\u00A0'))
|
|
143
|
+
shortcuts_span.appendChild(clock_link)
|
|
144
|
+
|
|
145
|
+
// Create clock link div
|
|
146
|
+
//
|
|
147
|
+
// Markup looks like:
|
|
148
|
+
// <div id="clockbox1" class="clockbox module">
|
|
149
|
+
// <h2>Choose a time</h2>
|
|
150
|
+
// <ul class="timelist">
|
|
151
|
+
// <li><a href="#">Now</a></li>
|
|
152
|
+
// <li><a href="#">Midnight</a></li>
|
|
153
|
+
// <li><a href="#">6 a.m.</a></li>
|
|
154
|
+
// <li><a href="#">Noon</a></li>
|
|
155
|
+
// <li><a href="#">6 p.m.</a></li>
|
|
156
|
+
// </ul>
|
|
157
|
+
// <p class="calendar-cancel"><a href="#">Cancel</a></p>
|
|
158
|
+
// </div>
|
|
159
|
+
|
|
160
|
+
const clock_box = document.createElement('div')
|
|
161
|
+
clock_box.style.display = 'none'
|
|
162
|
+
clock_box.style.position = 'absolute'
|
|
163
|
+
clock_box.className = 'clockbox module'
|
|
164
|
+
clock_box.id = DateTimeShortcuts.clockDivName + num
|
|
165
|
+
document.body.appendChild(clock_box)
|
|
166
|
+
clock_box.addEventListener('click', function (e) {
|
|
167
|
+
e.stopPropagation()
|
|
168
|
+
})
|
|
169
|
+
|
|
170
|
+
quickElement('h2', clock_box, gettext('Choose a time'))
|
|
171
|
+
const time_list = quickElement('ul', clock_box)
|
|
172
|
+
time_list.className = 'timelist'
|
|
173
|
+
// The list of choices can be overridden in JavaScript like this:
|
|
174
|
+
// DateTimeShortcuts.clockHours.name = [['3 a.m.', 3]];
|
|
175
|
+
// where name is the name attribute of the <input>.
|
|
176
|
+
const name =
|
|
177
|
+
typeof DateTimeShortcuts.clockHours[inp.name] === 'undefined'
|
|
178
|
+
? 'default_'
|
|
179
|
+
: inp.name
|
|
180
|
+
DateTimeShortcuts.clockHours[name].forEach(function (element) {
|
|
181
|
+
const time_link = quickElement(
|
|
182
|
+
'a',
|
|
183
|
+
quickElement('li', time_list),
|
|
184
|
+
gettext(element[0]),
|
|
185
|
+
'href',
|
|
186
|
+
'#'
|
|
187
|
+
)
|
|
188
|
+
time_link.addEventListener('click', function (e) {
|
|
189
|
+
e.preventDefault()
|
|
190
|
+
DateTimeShortcuts.handleClockQuicklink(num, element[1])
|
|
191
|
+
})
|
|
192
|
+
})
|
|
193
|
+
|
|
194
|
+
const cancel_p = quickElement('p', clock_box)
|
|
195
|
+
cancel_p.className = 'calendar-cancel'
|
|
196
|
+
const cancel_link = quickElement(
|
|
197
|
+
'a',
|
|
198
|
+
cancel_p,
|
|
199
|
+
gettext('Cancel'),
|
|
200
|
+
'href',
|
|
201
|
+
'#'
|
|
202
|
+
)
|
|
203
|
+
cancel_link.addEventListener('click', function (e) {
|
|
204
|
+
e.preventDefault()
|
|
205
|
+
DateTimeShortcuts.dismissClock(num)
|
|
206
|
+
})
|
|
207
|
+
|
|
208
|
+
document.addEventListener('keyup', function (event) {
|
|
209
|
+
if (event.which === 27) {
|
|
210
|
+
// ESC key closes popup
|
|
211
|
+
DateTimeShortcuts.dismissClock(num)
|
|
212
|
+
event.preventDefault()
|
|
213
|
+
}
|
|
214
|
+
})
|
|
215
|
+
},
|
|
216
|
+
openClock: function (num) {
|
|
217
|
+
const clock_box = document.getElementById(
|
|
218
|
+
DateTimeShortcuts.clockDivName + num
|
|
219
|
+
)
|
|
220
|
+
const clock_link = document.getElementById(
|
|
221
|
+
DateTimeShortcuts.clockLinkName + num
|
|
222
|
+
)
|
|
223
|
+
|
|
224
|
+
// Recalculate the clockbox position
|
|
225
|
+
// is it left-to-right or right-to-left layout ?
|
|
226
|
+
if (window.getComputedStyle(document.body).direction !== 'rtl') {
|
|
227
|
+
clock_box.style.left = findPosX(clock_link) + 17 + 'px'
|
|
228
|
+
} else {
|
|
229
|
+
// since style's width is in em, it'd be tough to calculate
|
|
230
|
+
// px value of it. let's use an estimated px for now
|
|
231
|
+
clock_box.style.left = findPosX(clock_link) - 110 + 'px'
|
|
232
|
+
}
|
|
233
|
+
clock_box.style.top = Math.max(0, findPosY(clock_link) - 30) + 'px'
|
|
234
|
+
|
|
235
|
+
// Show the clock box
|
|
236
|
+
clock_box.style.display = 'block'
|
|
237
|
+
document.addEventListener(
|
|
238
|
+
'click',
|
|
239
|
+
DateTimeShortcuts.dismissClockFunc[num]
|
|
240
|
+
)
|
|
241
|
+
},
|
|
242
|
+
dismissClock: function (num) {
|
|
243
|
+
document.getElementById(
|
|
244
|
+
DateTimeShortcuts.clockDivName + num
|
|
245
|
+
).style.display = 'none'
|
|
246
|
+
document.removeEventListener(
|
|
247
|
+
'click',
|
|
248
|
+
DateTimeShortcuts.dismissClockFunc[num]
|
|
249
|
+
)
|
|
250
|
+
},
|
|
251
|
+
handleClockQuicklink: function (num, val) {
|
|
252
|
+
let d
|
|
253
|
+
if (val === -1) {
|
|
254
|
+
d = DateTimeShortcuts.now()
|
|
255
|
+
} else {
|
|
256
|
+
d = new Date(1970, 1, 1, val, 0, 0, 0)
|
|
257
|
+
}
|
|
258
|
+
DateTimeShortcuts.clockInputs[num].value = d.strftime(
|
|
259
|
+
get_format('TIME_INPUT_FORMATS')[0]
|
|
260
|
+
)
|
|
261
|
+
DateTimeShortcuts.clockInputs[num].focus()
|
|
262
|
+
DateTimeShortcuts.dismissClock(num)
|
|
263
|
+
},
|
|
264
|
+
// Add calendar widget to a given field.
|
|
265
|
+
addCalendar: function (inp) {
|
|
266
|
+
const num = DateTimeShortcuts.calendars.length
|
|
267
|
+
|
|
268
|
+
DateTimeShortcuts.calendarInputs[num] = inp
|
|
269
|
+
DateTimeShortcuts.dismissCalendarFunc[num] = function () {
|
|
270
|
+
DateTimeShortcuts.dismissCalendar(num)
|
|
271
|
+
return true
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
// Shortcut links (calendar icon and "Today" link)
|
|
275
|
+
const shortcuts_span = document.createElement('span')
|
|
276
|
+
shortcuts_span.className = DateTimeShortcuts.shortCutsClass
|
|
277
|
+
inp.parentNode.insertBefore(shortcuts_span, inp.nextSibling)
|
|
278
|
+
const today_link = document.createElement('a')
|
|
279
|
+
today_link.href = '#'
|
|
280
|
+
today_link.appendChild(document.createTextNode(gettext('Today')))
|
|
281
|
+
today_link.addEventListener('click', function (e) {
|
|
282
|
+
e.preventDefault()
|
|
283
|
+
DateTimeShortcuts.handleCalendarQuickLink(num, 0)
|
|
284
|
+
})
|
|
285
|
+
const cal_link = document.createElement('a')
|
|
286
|
+
cal_link.href = '#'
|
|
287
|
+
cal_link.id = DateTimeShortcuts.calendarLinkName + num
|
|
288
|
+
cal_link.addEventListener('click', function (e) {
|
|
289
|
+
e.preventDefault()
|
|
290
|
+
// avoid triggering the document click handler to dismiss the calendar
|
|
291
|
+
e.stopPropagation()
|
|
292
|
+
DateTimeShortcuts.openCalendar(num)
|
|
293
|
+
})
|
|
294
|
+
quickElement(
|
|
295
|
+
'span',
|
|
296
|
+
cal_link,
|
|
297
|
+
'',
|
|
298
|
+
'class',
|
|
299
|
+
'date-icon',
|
|
300
|
+
'title',
|
|
301
|
+
gettext('Choose a Date')
|
|
302
|
+
)
|
|
303
|
+
shortcuts_span.appendChild(document.createTextNode('\u00A0'))
|
|
304
|
+
shortcuts_span.appendChild(today_link)
|
|
305
|
+
shortcuts_span.appendChild(document.createTextNode('\u00A0|\u00A0'))
|
|
306
|
+
shortcuts_span.appendChild(cal_link)
|
|
307
|
+
|
|
308
|
+
// Create calendarbox div.
|
|
309
|
+
//
|
|
310
|
+
// Markup looks like:
|
|
311
|
+
//
|
|
312
|
+
// <div id="calendarbox3" class="calendarbox module">
|
|
313
|
+
// <h2>
|
|
314
|
+
// <a href="#" class="link-previous">‹</a>
|
|
315
|
+
// <a href="#" class="link-next">›</a> February 2003
|
|
316
|
+
// </h2>
|
|
317
|
+
// <div class="calendar" id="calendarin3">
|
|
318
|
+
// <!-- (cal) -->
|
|
319
|
+
// </div>
|
|
320
|
+
// <div class="calendar-shortcuts">
|
|
321
|
+
// <a href="#">Yesterday</a> | <a href="#">Today</a> | <a href="#">Tomorrow</a>
|
|
322
|
+
// </div>
|
|
323
|
+
// <p class="calendar-cancel"><a href="#">Cancel</a></p>
|
|
324
|
+
// </div>
|
|
325
|
+
const cal_box = document.createElement('div')
|
|
326
|
+
cal_box.style.display = 'none'
|
|
327
|
+
cal_box.style.position = 'absolute'
|
|
328
|
+
cal_box.className = 'calendarbox module'
|
|
329
|
+
cal_box.id = DateTimeShortcuts.calendarDivName1 + num
|
|
330
|
+
document.body.appendChild(cal_box)
|
|
331
|
+
cal_box.addEventListener('click', function (e) {
|
|
332
|
+
e.stopPropagation()
|
|
333
|
+
})
|
|
334
|
+
|
|
335
|
+
// next-prev links
|
|
336
|
+
const cal_nav = quickElement('div', cal_box)
|
|
337
|
+
const cal_nav_prev = quickElement('a', cal_nav, '<', 'href', '#')
|
|
338
|
+
cal_nav_prev.className = 'calendarnav-previous'
|
|
339
|
+
cal_nav_prev.addEventListener('click', function (e) {
|
|
340
|
+
e.preventDefault()
|
|
341
|
+
DateTimeShortcuts.drawPrev(num)
|
|
342
|
+
})
|
|
343
|
+
|
|
344
|
+
const cal_nav_next = quickElement('a', cal_nav, '>', 'href', '#')
|
|
345
|
+
cal_nav_next.className = 'calendarnav-next'
|
|
346
|
+
cal_nav_next.addEventListener('click', function (e) {
|
|
347
|
+
e.preventDefault()
|
|
348
|
+
DateTimeShortcuts.drawNext(num)
|
|
349
|
+
})
|
|
350
|
+
|
|
351
|
+
// main box
|
|
352
|
+
const cal_main = quickElement(
|
|
353
|
+
'div',
|
|
354
|
+
cal_box,
|
|
355
|
+
'',
|
|
356
|
+
'id',
|
|
357
|
+
DateTimeShortcuts.calendarDivName2 + num
|
|
358
|
+
)
|
|
359
|
+
cal_main.className = 'calendar'
|
|
360
|
+
DateTimeShortcuts.calendars[num] = new Calendar(
|
|
361
|
+
DateTimeShortcuts.calendarDivName2 + num,
|
|
362
|
+
DateTimeShortcuts.handleCalendarCallback(num)
|
|
363
|
+
)
|
|
364
|
+
DateTimeShortcuts.calendars[num].drawCurrent()
|
|
365
|
+
|
|
366
|
+
// calendar shortcuts
|
|
367
|
+
const shortcuts = quickElement('div', cal_box)
|
|
368
|
+
shortcuts.className = 'calendar-shortcuts'
|
|
369
|
+
let day_link = quickElement(
|
|
370
|
+
'a',
|
|
371
|
+
shortcuts,
|
|
372
|
+
gettext('Yesterday'),
|
|
373
|
+
'href',
|
|
374
|
+
'#'
|
|
375
|
+
)
|
|
376
|
+
day_link.addEventListener('click', function (e) {
|
|
377
|
+
e.preventDefault()
|
|
378
|
+
DateTimeShortcuts.handleCalendarQuickLink(num, -1)
|
|
379
|
+
})
|
|
380
|
+
shortcuts.appendChild(document.createTextNode('\u00A0|\u00A0'))
|
|
381
|
+
day_link = quickElement('a', shortcuts, gettext('Today'), 'href', '#')
|
|
382
|
+
day_link.addEventListener('click', function (e) {
|
|
383
|
+
e.preventDefault()
|
|
384
|
+
DateTimeShortcuts.handleCalendarQuickLink(num, 0)
|
|
385
|
+
})
|
|
386
|
+
shortcuts.appendChild(document.createTextNode('\u00A0|\u00A0'))
|
|
387
|
+
day_link = quickElement('a', shortcuts, gettext('Tomorrow'), 'href', '#')
|
|
388
|
+
day_link.addEventListener('click', function (e) {
|
|
389
|
+
e.preventDefault()
|
|
390
|
+
DateTimeShortcuts.handleCalendarQuickLink(num, +1)
|
|
391
|
+
})
|
|
392
|
+
|
|
393
|
+
// cancel bar
|
|
394
|
+
const cancel_p = quickElement('p', cal_box)
|
|
395
|
+
cancel_p.className = 'calendar-cancel'
|
|
396
|
+
const cancel_link = quickElement(
|
|
397
|
+
'a',
|
|
398
|
+
cancel_p,
|
|
399
|
+
gettext('Cancel'),
|
|
400
|
+
'href',
|
|
401
|
+
'#'
|
|
402
|
+
)
|
|
403
|
+
cancel_link.addEventListener('click', function (e) {
|
|
404
|
+
e.preventDefault()
|
|
405
|
+
DateTimeShortcuts.dismissCalendar(num)
|
|
406
|
+
})
|
|
407
|
+
document.addEventListener('keyup', function (event) {
|
|
408
|
+
if (event.which === 27) {
|
|
409
|
+
// ESC key closes popup
|
|
410
|
+
DateTimeShortcuts.dismissCalendar(num)
|
|
411
|
+
event.preventDefault()
|
|
412
|
+
}
|
|
413
|
+
})
|
|
414
|
+
},
|
|
415
|
+
openCalendar: function (num) {
|
|
416
|
+
const cal_box = document.getElementById(
|
|
417
|
+
DateTimeShortcuts.calendarDivName1 + num
|
|
418
|
+
)
|
|
419
|
+
const cal_link = document.getElementById(
|
|
420
|
+
DateTimeShortcuts.calendarLinkName + num
|
|
421
|
+
)
|
|
422
|
+
const inp = DateTimeShortcuts.calendarInputs[num]
|
|
423
|
+
|
|
424
|
+
// Determine if the current value in the input has a valid date.
|
|
425
|
+
// If so, draw the calendar with that date's year and month.
|
|
426
|
+
if (inp.value) {
|
|
427
|
+
const format = get_format('DATE_INPUT_FORMATS')[0]
|
|
428
|
+
const selected = inp.value.strptime(format)
|
|
429
|
+
const year = selected.getUTCFullYear()
|
|
430
|
+
const month = selected.getUTCMonth() + 1
|
|
431
|
+
const re = /\d{4}/
|
|
432
|
+
if (re.test(year.toString()) && month >= 1 && month <= 12) {
|
|
433
|
+
DateTimeShortcuts.calendars[num].drawDate(month, year, selected)
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
// Recalculate the clockbox position
|
|
438
|
+
// is it left-to-right or right-to-left layout ?
|
|
439
|
+
if (window.getComputedStyle(document.body).direction !== 'rtl') {
|
|
440
|
+
cal_box.style.left = findPosX(cal_link) + 17 + 'px'
|
|
441
|
+
} else {
|
|
442
|
+
// since style's width is in em, it'd be tough to calculate
|
|
443
|
+
// px value of it. let's use an estimated px for now
|
|
444
|
+
cal_box.style.left = findPosX(cal_link) - 180 + 'px'
|
|
445
|
+
}
|
|
446
|
+
cal_box.style.top = Math.max(0, findPosY(cal_link) - 75) + 'px'
|
|
447
|
+
|
|
448
|
+
cal_box.style.display = 'block'
|
|
449
|
+
document.addEventListener(
|
|
450
|
+
'click',
|
|
451
|
+
DateTimeShortcuts.dismissCalendarFunc[num]
|
|
452
|
+
)
|
|
453
|
+
},
|
|
454
|
+
dismissCalendar: function (num) {
|
|
455
|
+
document.getElementById(
|
|
456
|
+
DateTimeShortcuts.calendarDivName1 + num
|
|
457
|
+
).style.display = 'none'
|
|
458
|
+
document.removeEventListener(
|
|
459
|
+
'click',
|
|
460
|
+
DateTimeShortcuts.dismissCalendarFunc[num]
|
|
461
|
+
)
|
|
462
|
+
},
|
|
463
|
+
drawPrev: function (num) {
|
|
464
|
+
DateTimeShortcuts.calendars[num].drawPreviousMonth()
|
|
465
|
+
},
|
|
466
|
+
drawNext: function (num) {
|
|
467
|
+
DateTimeShortcuts.calendars[num].drawNextMonth()
|
|
468
|
+
},
|
|
469
|
+
handleCalendarCallback: function (num) {
|
|
470
|
+
const format = get_format('DATE_INPUT_FORMATS')[0]
|
|
471
|
+
return function (y, m, d) {
|
|
472
|
+
DateTimeShortcuts.calendarInputs[num].value = new Date(
|
|
473
|
+
y,
|
|
474
|
+
m - 1,
|
|
475
|
+
d
|
|
476
|
+
).strftime(format)
|
|
477
|
+
DateTimeShortcuts.calendarInputs[num].focus()
|
|
478
|
+
document.getElementById(
|
|
479
|
+
DateTimeShortcuts.calendarDivName1 + num
|
|
480
|
+
).style.display = 'none'
|
|
481
|
+
}
|
|
482
|
+
},
|
|
483
|
+
handleCalendarQuickLink: function (num, offset) {
|
|
484
|
+
const d = DateTimeShortcuts.now()
|
|
485
|
+
d.setDate(d.getDate() + offset)
|
|
486
|
+
DateTimeShortcuts.calendarInputs[num].value = d.strftime(
|
|
487
|
+
get_format('DATE_INPUT_FORMATS')[0]
|
|
488
|
+
)
|
|
489
|
+
DateTimeShortcuts.calendarInputs[num].focus()
|
|
490
|
+
DateTimeShortcuts.dismissCalendar(num)
|
|
491
|
+
},
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
window.addEventListener('load', DateTimeShortcuts.init)
|
|
495
|
+
window.DateTimeShortcuts = DateTimeShortcuts
|
|
496
|
+
}
|