fnschool 20251013.81257.813__tar.gz → 20251013.81919.815__tar.gz

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 (114) hide show
  1. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/PKG-INFO +1 -1
  2. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/pyproject.toml +1 -1
  3. fnschool-20251013.81919.815/src/fnschoo1/__init__.py +9 -0
  4. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/canteen/templates/canteen/consumption/create.html +33 -8
  5. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/canteen/views.py +96 -93
  6. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/canteen/workbook/generate.py +4 -2
  7. fnschool-20251013.81919.815/src/fnschoo1/locale/zh_Hans/LC_MESSAGES/django.mo +0 -0
  8. fnschool-20251013.81257.813/src/fnschoo1/__init__.py → fnschool-20251013.81919.815/src/fnschoo1/manage.py +8 -3
  9. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/static/js/fnschool.js +11 -2
  10. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschool.egg-info/PKG-INFO +1 -1
  11. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschool.egg-info/SOURCES.txt +6 -1
  12. fnschool-20251013.81919.815/src/fnschool.egg-info/SOURCES.txt.py +104 -0
  13. fnschool-20251013.81919.815/src/fnschool.egg-info/dependency_links.txt.py +1 -0
  14. fnschool-20251013.81919.815/src/fnschool.egg-info/entry_points.txt +2 -0
  15. fnschool-20251013.81919.815/src/fnschool.egg-info/entry_points.txt.py +2 -0
  16. fnschool-20251013.81919.815/src/fnschool.egg-info/requires.txt.py +13 -0
  17. fnschool-20251013.81919.815/src/fnschool.egg-info/top_level.txt.py +1 -0
  18. fnschool-20251013.81257.813/src/fnschoo1/locale/zh_Hans/LC_MESSAGES/django.mo +0 -0
  19. fnschool-20251013.81257.813/src/fnschoo1/manage.py +0 -25
  20. fnschool-20251013.81257.813/src/fnschool.egg-info/entry_points.txt +0 -2
  21. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/LICENSE +0 -0
  22. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/README.md +0 -0
  23. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/setup.cfg +0 -0
  24. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/canteen/__init__.py +0 -0
  25. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/canteen/admin.py +0 -0
  26. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/canteen/apps.py +0 -0
  27. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/canteen/forms.py +0 -0
  28. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/canteen/migrations/0001_initial.py +0 -0
  29. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/canteen/migrations/0002_ingredient_is_disabled.py +0 -0
  30. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/canteen/migrations/0003_consumption_is_disabled_alter_ingredient_is_disabled.py +0 -0
  31. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/canteen/migrations/0004_alter_ingredient_name_category_and_more.py +0 -0
  32. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/canteen/migrations/0005_alter_category_created_at_alter_category_name_and_more.py +0 -0
  33. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/canteen/migrations/0006_category_is_disabled_alter_category_user_and_more.py +0 -0
  34. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/canteen/migrations/0007_alter_consumption_amount_used_and_more.py +0 -0
  35. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/canteen/migrations/0008_category_abbreviation_mealtype.py +0 -0
  36. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/canteen/migrations/0009_alter_category_abbreviation_and_more.py +0 -0
  37. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/canteen/migrations/0010_alter_consumption_options_alter_ingredient_options_and_more.py +0 -0
  38. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/canteen/migrations/0011_category_pin_to_consumptions_top.py +0 -0
  39. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/canteen/migrations/0012_alter_ingredient_storage_date.py +0 -0
  40. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/canteen/migrations/0013_alter_consumption_options_alter_ingredient_options_and_more.py +0 -0
  41. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/canteen/migrations/__init__.py +0 -0
  42. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/canteen/models.py +0 -0
  43. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/canteen/templates/canteen/category/create.html +0 -0
  44. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/canteen/templates/canteen/category/delete.html +0 -0
  45. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/canteen/templates/canteen/category/list.html +0 -0
  46. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/canteen/templates/canteen/category/update.html +0 -0
  47. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/canteen/templates/canteen/close.html +0 -0
  48. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/canteen/templates/canteen/consumption/_create.html +0 -0
  49. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/canteen/templates/canteen/ingredient/close.html +0 -0
  50. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/canteen/templates/canteen/ingredient/create.html +0 -0
  51. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/canteen/templates/canteen/ingredient/create_one.html +0 -0
  52. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/canteen/templates/canteen/ingredient/delete.html +0 -0
  53. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/canteen/templates/canteen/ingredient/list.html +0 -0
  54. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/canteen/templates/canteen/ingredient/update.html +0 -0
  55. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/canteen/templates/canteen/meal_type/create.html +0 -0
  56. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/canteen/templates/canteen/meal_type/delete.html +0 -0
  57. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/canteen/templates/canteen/meal_type/list.html +0 -0
  58. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/canteen/templates/canteen/meal_type/update.html +0 -0
  59. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/canteen/tests.py +0 -0
  60. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/canteen/urls.py +0 -0
  61. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/canteen/workbook/__init__.py +0 -0
  62. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/fnschool/__init__.py +0 -0
  63. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/fnschool/asgi.py +0 -0
  64. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/fnschool/settings.py +0 -0
  65. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/fnschool/templatetags/__init__.py +0 -0
  66. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/fnschool/templatetags/fnschool_tags.py +0 -0
  67. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/fnschool/urls.py +0 -0
  68. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/fnschool/views.py +0 -0
  69. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/fnschool/wsgi.py +0 -0
  70. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/locale/en/LC_MESSAGES/django.mo +0 -0
  71. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/profiles/__init__.py +0 -0
  72. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/profiles/admin.py +0 -0
  73. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/profiles/apps.py +0 -0
  74. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/profiles/forms.py +0 -0
  75. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/profiles/migrations/0001_initial.py +0 -0
  76. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/profiles/migrations/0002_alter_profile_bio.py +0 -0
  77. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/profiles/migrations/0003_alter_profile_options_alter_profile_address_and_more.py +0 -0
  78. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/profiles/migrations/0004_profile_gender.py +0 -0
  79. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/profiles/migrations/0005_alter_profile_gender.py +0 -0
  80. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/profiles/migrations/__init__.py +0 -0
  81. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/profiles/models.py +0 -0
  82. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/profiles/signals.py +0 -0
  83. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/profiles/templates/profiles/create.html +0 -0
  84. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/profiles/templates/profiles/detail.html +0 -0
  85. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/profiles/templates/profiles/edit.html +0 -0
  86. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/profiles/templates/profiles/log_in.html +0 -0
  87. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/profiles/templates/profiles/log_out.html +0 -0
  88. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/profiles/tests.py +0 -0
  89. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/profiles/urls.py +0 -0
  90. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/profiles/views.py +0 -0
  91. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/static/css/bootstrap.min.css +0 -0
  92. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/static/css/fnschool.css +0 -0
  93. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/static/images/favicon.ico +0 -0
  94. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/static/js/bootstrap.bundle.min.js +0 -0
  95. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/static/js/bootstrap.min.js +0 -0
  96. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/static/js/jquery.min.js +0 -0
  97. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/static/js/jquery.slim.min.js +0 -0
  98. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/static/js/popper.min.js +0 -0
  99. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/templates/base/_content.html +0 -0
  100. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/templates/base/_css.html +0 -0
  101. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/templates/base/_js.html +0 -0
  102. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/templates/base/content.html +0 -0
  103. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/templates/base/header_content_footer.html +0 -0
  104. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/templates/close.html +0 -0
  105. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/templates/home.html +0 -0
  106. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/templates/includes/_footer.html +0 -0
  107. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/templates/includes/_header.html +0 -0
  108. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/templates/includes/_navigation.html +0 -0
  109. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/templates/includes/_paginator.html +0 -0
  110. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/templates/registration/logged_out.html +0 -0
  111. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschoo1/templates/registration/login.html +0 -0
  112. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschool.egg-info/dependency_links.txt +0 -0
  113. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschool.egg-info/requires.txt +0 -0
  114. {fnschool-20251013.81257.813 → fnschool-20251013.81919.815}/src/fnschool.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fnschool
3
- Version: 20251013.81257.813
3
+ Version: 20251013.81919.815
4
4
  Summary: Just some school related scripts, without any ambition.
5
5
  Author-email: larryw3i <larryw3i@163.com>, Larry Wei <larryw3i@126.com>, Larry W3i <larryw3i@yeah.net>
6
6
  Maintainer-email: larryw3i <larryw3i@163.com>, Larry Wei <larryw3i@126.com>
@@ -41,7 +41,7 @@ gui=[]
41
41
  cli=[]
42
42
 
43
43
  [project.scripts]
44
- fnschool-cli = "fnschoo1:main"
44
+ fnschool-cli = "fnschoo1.manage:main"
45
45
 
46
46
  [build-system]
47
47
  requires = [
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env python3
2
+ """Django's command-line utility for administrative tasks."""
3
+ import os
4
+ import platform
5
+ import random
6
+ import sys
7
+ from pathlib import Path
8
+
9
+ __version__ = "20251013.81919.815"
@@ -8,8 +8,15 @@
8
8
  <hr>
9
9
  <div class="container">
10
10
  <div class="row justify-content-end">
11
- <button class="btn btn-success col-md-1 col-lg-1 col-2"
12
- onclick="list_consumptions();">{% trans "Refresh" %}</button>
11
+ <button class="btn btn-outline-success col-md-1 col-lg-1 col-2 mx-2"
12
+ onclick="list_consumptions_by_week();">{% trans "Consume by Week" %}</button>
13
+
14
+ <button class="btn btn-outline-success col-md-1 col-lg-1 col-2"
15
+ onclick="list_consumptions_rapidly();">{% trans "Rapid Consumption" %}</button>
16
+
17
+ <a class="btn btn-success col-md-1 col-lg-1 col-2 mx-2"
18
+ target="canteen_list_categories"
19
+ href="{% url "canteen:list_categories" %}">{% trans "Ingredient Categories" %}</a>
13
20
 
14
21
  <div class="col col-3 col-md-2 col-lg-2">
15
22
  <input class=" form-control"
@@ -98,6 +105,24 @@
98
105
 
99
106
  date_range = JSON.parse($("#date_range").text())
100
107
 
108
+ function list_consumptions_rapidly() {
109
+ query = {
110
+ 'by_week': 'false',
111
+ "rapidly": 'true'
112
+ }
113
+ set_cookies(query)
114
+ update_href(query)
115
+ }
116
+
117
+ function list_consumptions_by_week() {
118
+ query = {
119
+ 'by_week': 'true',
120
+ "rapidly": 'false'
121
+ }
122
+ set_cookies(query)
123
+ update_href(query)
124
+ }
125
+
101
126
  function get_previous_month_date(date = new Date()) {
102
127
  const prevMonthDate = new Date(date);
103
128
  prevMonthDate.setDate(1);
@@ -110,6 +135,12 @@
110
135
  return dayOfWeek === 0 || dayOfWeek === 6;
111
136
  }
112
137
 
138
+ $(document).ready(function() {
139
+ var td1 = $(".table tr > :nth-child(1):first")
140
+ $(".table tr > :nth-child(2)").css("left", td1.width() * 1.05)
141
+ });
142
+
143
+
113
144
  $(document).ready(function() {
114
145
  $(months).each(function(index, value) {
115
146
  $('.workbook-month-select').append(`<option>${value}</option>`)
@@ -200,12 +231,6 @@
200
231
  }
201
232
 
202
233
 
203
-
204
- $(document).ready(function() {
205
- var td1 = $(".table tr > :nth-child(1):first")
206
- $(".table tr > :nth-child(2)").css("left", td1.width() * 1.05)
207
- });
208
-
209
234
  $(document).ready(function() {
210
235
  dont_submit = true
211
236
  var progress = 0
@@ -156,113 +156,40 @@ def split_price(total_price, quantity, prec=2):
156
156
  return [[total_price0, quantity0], [total_price1, quantity1]]
157
157
 
158
158
 
159
- def get_consumption_ingredients(request):
159
+ @login_required
160
+ def create_consumptions(request, ingredient_id=None):
160
161
  date_start = request.GET.get(
161
162
  "storage_date_start", None
162
163
  ) or request.COOKIES.get("storage_date_start", None)
163
- date_end = request.GET.get("storage_date_end", None) or request.COOKIES.get(
164
- "storage_date_end", None
165
- )
166
- ingredients = Ingredient.objects
167
- queries = Q()
168
- queries = (
169
- Q(user=request.user) & Q(is_disabled=False) & Q(is_ignorable=False)
170
- )
171
- if date_start:
172
- date_start = date_parser.parse(date_start).date()
173
- queries &= Q(storage_date__gte=date_start)
174
- if date_end:
175
- date_end = date_parser.parse(date_end).date()
176
- queries &= Q(storage_date__lte=date_end)
177
-
178
- if not date_start and not date_end:
179
- queries &= Q(quantity__gt=F("total_consumed"))
180
- ingredients = ingredients.annotate(
164
+ if not date_start:
165
+ ingredients = Ingredient.objects.annotate(
181
166
  total_consumed=Coalesce(
182
167
  Sum("consumptions__amount_used"), 0, output_field=IntegerField()
183
168
  )
184
- )
185
-
186
- ingredients = ingredients.filter(queries).order_by(
187
- "name", "storage_date", "meal_type__name", "category__name"
188
- )
189
-
190
- return ingredients
191
-
192
-
193
- def get_date_range(ingredients):
194
- date_start = ingredients.order_by("storage_date").first().storage_date
195
- today = datetime.now().date()
196
- date_end = (today.replace(day=1) + relativedelta(months=2)) - relativedelta(
197
- days=1
198
- )
199
- date_range = list(pd.date_range(start=date_start, end=date_end))
200
- date_range = [d.date() for d in date_range]
201
-
202
- return date_range
203
-
204
-
205
- @login_required
206
- @require_POST
207
- def new_consumption(request, consumption_id=None):
208
- form = None
209
- if consumption_id:
210
- consumption = Consumption.objects.filter(
211
- Q(pk=consumption_id)
212
- & Q(ingredient__user=request.user)
169
+ ).filter(
170
+ Q(quantity__gt=F("total_consumed"))
213
171
  & Q(is_disabled=False)
214
- ).first()
215
- if consumption:
216
-
217
- posted_amount_used = request.POST.get("amount_used")
218
- if (
219
- posted_amount_used.replace(".", "").isnumeric()
220
- and Decimal(posted_amount_used).is_zero()
221
- ):
222
- consumption.delete()
223
- return HttpResponse("OK", status=201)
224
-
225
- form = ConsumptionForm(request.POST, instance=consumption)
226
- else:
227
- return HttpResponse("Accepted", status=202)
172
+ & Q(is_ignorable=False)
173
+ & Q(user=request.user)
174
+ )
175
+ date_start = ingredients.order_by("storage_date").first().storage_date
228
176
 
229
177
  else:
230
- ingredient = Ingredient.objects.filter(
231
- Q(user=request.user) & Q(pk=request.POST.get("ingredient"))
232
- ).first()
233
- if not ingredient:
234
- return HttpResponse("Accepted", status=202)
235
-
236
- consumption = Consumption()
237
- consumption.ingredient = ingredient
238
- form = ConsumptionForm(request.POST, instance=consumption)
239
-
240
- if form.is_valid() and not form.instance.is_disabled:
241
- consumption = form.save(commit=False)
242
- consumption.save()
243
- return HttpResponse("OK", status=201)
244
-
245
- return HttpResponse("Accepted", status=202)
246
-
247
-
248
- @login_required
249
- def create_consumptions(request, ingredient_id=None):
250
- ingredients = get_consumption_ingredients(request)
251
- date_range = None
252
- if not ingredients:
253
- return render(
254
- request,
255
- "canteen/consumption/create.html",
256
- {"ingredients": ingredients, "date_range": date_range},
257
- )
178
+ date_start = date_parser.parse(date_start).date()
258
179
 
259
- date_range = get_date_range(ingredients)
260
180
  date_end = request.GET.get("storage_date_end", None) or request.COOKIES.get(
261
181
  "storage_date_end", None
262
182
  )
263
- if date_end:
183
+ if not date_end:
184
+ today = datetime.now().date()
185
+ date_end = (
186
+ today.replace(day=1) + relativedelta(months=2)
187
+ ) - relativedelta(days=1)
188
+ else:
264
189
  date_end = date_parser.parse(date_end).date()
265
- date_range = [d for d in date_range if d <= date_end]
190
+
191
+ date_range = list(pd.date_range(start=date_start, end=date_end))
192
+ date_range = [d.date() for d in date_range]
266
193
 
267
194
  if ingredient_id:
268
195
  ingredient = get_object_or_404(Ingredient, pk=ingredient_id)
@@ -304,8 +231,41 @@ def create_consumptions(request, ingredient_id=None):
304
231
  "canteen/consumption/_create.html",
305
232
  {"form_list": form_list},
306
233
  )
234
+ by_week = (
235
+ request.GET.get("by_week", "") or request.COOKIES.get("by_week", "")
236
+ ) == "true"
237
+ rapidly = (
238
+ request.GET.get("rapidly", "") or request.COOKIES.get("rapidly", "")
239
+ ) == "true" or not by_week
240
+
241
+ queries = (
242
+ Q(storage_date__gte=date_start)
243
+ & Q(storage_date__lte=date_end)
244
+ & Q(user=request.user)
245
+ & Q(is_disabled=False)
246
+ & Q(is_ignorable=False)
247
+ )
248
+ ingredients = Ingredient.objects
249
+ print("by_week", by_week, "rapidly", rapidly)
250
+ ingredients = (
251
+ ingredients.filter(queries).order_by(
252
+ "name", "storage_date", "meal_type__name", "category__name"
253
+ )
254
+ if rapidly
255
+ else ingredients.filter(queries).order_by(
256
+ "storage_date", "meal_type__name", "name", "category__name"
257
+ )
258
+ )
307
259
 
308
260
  ingredients = ingredients.all()
261
+
262
+ if not ingredients:
263
+ return render(
264
+ request,
265
+ "canteen/consumption/create.html",
266
+ {"ingredients": ingredients, "date_range": date_range},
267
+ )
268
+
309
269
  ingredients_pinned = []
310
270
  ingredients_unpinned = []
311
271
  categories_top = Category.objects.filter(
@@ -341,6 +301,49 @@ def create_consumptions(request, ingredient_id=None):
341
301
  )
342
302
 
343
303
 
304
+ @login_required
305
+ @require_POST
306
+ def new_consumption(request, consumption_id=None):
307
+ form = None
308
+ if consumption_id:
309
+ consumption = Consumption.objects.filter(
310
+ Q(pk=consumption_id)
311
+ & Q(ingredient__user=request.user)
312
+ & Q(is_disabled=False)
313
+ ).first()
314
+ if consumption:
315
+
316
+ posted_amount_used = request.POST.get("amount_used")
317
+ if (
318
+ posted_amount_used.replace(".", "").isnumeric()
319
+ and Decimal(posted_amount_used).is_zero()
320
+ ):
321
+ consumption.delete()
322
+ return HttpResponse("OK", status=201)
323
+
324
+ form = ConsumptionForm(request.POST, instance=consumption)
325
+ else:
326
+ return HttpResponse("Accepted", status=202)
327
+
328
+ else:
329
+ ingredient = Ingredient.objects.filter(
330
+ Q(user=request.user) & Q(pk=request.POST.get("ingredient"))
331
+ ).first()
332
+ if not ingredient:
333
+ return HttpResponse("Accepted", status=202)
334
+
335
+ consumption = Consumption()
336
+ consumption.ingredient = ingredient
337
+ form = ConsumptionForm(request.POST, instance=consumption)
338
+
339
+ if form.is_valid() and not form.instance.is_disabled:
340
+ consumption = form.save(commit=False)
341
+ consumption.save()
342
+ return HttpResponse("OK", status=201)
343
+
344
+ return HttpResponse("Accepted", status=202)
345
+
346
+
344
347
  @login_required()
345
348
  def delete_ingredient(request, ingredient_id):
346
349
  ingredient = get_object_or_404(Ingredient, pk=ingredient_id)
@@ -1819,10 +1819,12 @@ class CanteenWorkBook:
1819
1819
  ingredient_name_cell.value = ingredient.name
1820
1820
  if ingredient.name:
1821
1821
  ingredient_name_cell.comment = Comment(
1822
- _("{meal_type} ({category}, Checked/Storaged at {storage_date})").format(
1822
+ _(
1823
+ "{meal_type} ({category}, Checked/Storaged at {storage_date})"
1824
+ ).format(
1823
1825
  meal_type=ingredient.meal_type,
1824
1826
  category=ingredient.category,
1825
- storage_date = ingredient.storage_date,
1827
+ storage_date=ingredient.storage_date,
1826
1828
  ),
1827
1829
  user.username,
1828
1830
  )
@@ -6,8 +6,6 @@ import random
6
6
  import sys
7
7
  from pathlib import Path
8
8
 
9
- __version__ = "20251013.81257.813"
10
-
11
9
  FNSCHOOL_PATH = Path(__file__).parent
12
10
  if FNSCHOOL_PATH.as_posix() not in sys.path:
13
11
  sys.path.insert(0, FNSCHOOL_PATH.as_posix())
@@ -37,6 +35,9 @@ def main():
37
35
  "forget to activate a virtual environment?"
38
36
  ) from exc
39
37
 
38
+ os.chdir(FNSCHOOL_PATH)
39
+ sys.argv[0] = "manage.py"
40
+
40
41
  if len(sys.argv) < 2:
41
42
  local_port = str(random.randint(8080, 65530))
42
43
  local_url = "http://127.0.0.1:" + local_port
@@ -46,8 +47,12 @@ def main():
46
47
  if is_windows:
47
48
  os.startfile(local_url)
48
49
  else:
49
- os.system("sleep 5 && open " + local_url)
50
+ os.system("open " + local_url + "&")
50
51
  except Exception as e:
51
52
  print(e)
52
53
 
53
54
  execute_from_command_line(sys.argv)
55
+
56
+
57
+ if __name__ == "__main__":
58
+ main()
@@ -9,7 +9,16 @@ function get_cookie(name) {
9
9
  return null
10
10
  }
11
11
  function delete_cookie(name) {
12
- document.cookie = name + '=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/'
12
+ document.cookie =
13
+ name +
14
+ `=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=${window.location.pathname}`
15
+ }
16
+
17
+ function set_cookies(cookies) {
18
+ cookies = new Map(Object.entries(cookies))
19
+ for (var [key, value] of cookies) {
20
+ set_simple_cookie(key, value)
21
+ }
13
22
  }
14
23
 
15
24
  function set_simple_cookie(key, value) {
@@ -19,7 +28,7 @@ function set_simple_cookie(key, value) {
19
28
  }
20
29
  const expiryDate = new Date()
21
30
  expiryDate.setFullYear(expiryDate.getFullYear() + 20)
22
- document.cookie = `${key}=${value}; expires=${expiryDate.toUTCString()}; path=/`
31
+ document.cookie = `${key}=${value}; expires=${expiryDate.toUTCString()}; path=${window.location.pathname}`
23
32
  }
24
33
  function update_href(query) {
25
34
  query = new Map(Object.entries(query))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fnschool
3
- Version: 20251013.81257.813
3
+ Version: 20251013.81919.815
4
4
  Summary: Just some school related scripts, without any ambition.
5
5
  Author-email: larryw3i <larryw3i@163.com>, Larry Wei <larryw3i@126.com>, Larry W3i <larryw3i@yeah.net>
6
6
  Maintainer-email: larryw3i <larryw3i@163.com>, Larry Wei <larryw3i@126.com>
@@ -98,7 +98,12 @@ src/fnschoo1/templates/registration/logged_out.html
98
98
  src/fnschoo1/templates/registration/login.html
99
99
  src/fnschool.egg-info/PKG-INFO
100
100
  src/fnschool.egg-info/SOURCES.txt
101
+ src/fnschool.egg-info/SOURCES.txt.py
101
102
  src/fnschool.egg-info/dependency_links.txt
103
+ src/fnschool.egg-info/dependency_links.txt.py
102
104
  src/fnschool.egg-info/entry_points.txt
105
+ src/fnschool.egg-info/entry_points.txt.py
103
106
  src/fnschool.egg-info/requires.txt
104
- src/fnschool.egg-info/top_level.txt
107
+ src/fnschool.egg-info/requires.txt.py
108
+ src/fnschool.egg-info/top_level.txt
109
+ src/fnschool.egg-info/top_level.txt.py
@@ -0,0 +1,104 @@
1
+ XXXXXXX
2
+ XXXXXXXXX
3
+ XXXXXXXXXXXXXX
4
+ XXXXXXXXXXXXXXXXXXXXXXXX
5
+ XXXXXXXXXXXXXXXXXXXXXX
6
+ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
7
+ XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
8
+ XXXXXXXXXXXXXXXXXXXXXXXXXXXX
9
+ XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
10
+ XXXXXXXXXXXXXXXXXXXXXXX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
1
+ [console_scripts]
2
+ fnschool-cli = fnschoo1.manage:main
@@ -0,0 +1,2 @@
1
+ XXXXXXXXXXXXXXXXX
2
+ XXXXXXXXXXXX X XXXXXXXXXXXXX
@@ -0,0 +1,13 @@
1
+ XXXXXX
2
+ XXXXXX
3
+ XXXXXXXXXX
4
+ XXXXX
5
+ XXXXXXXX
6
+ XXXXXXXXXXXX
7
+ XXXXXXX
8
+ XXXXXXXXXXXXXXXXXXX
9
+ XXXXXXXXXXXXXXXXX
10
+
11
+ XXXXX
12
+
13
+ XXXXX
@@ -1,25 +0,0 @@
1
- #!/usr/bin/env python3
2
- """Django's command-line utility for administrative tasks."""
3
- import os
4
- import platform
5
- import random
6
- import sys
7
-
8
-
9
- def main():
10
- """Run administrative tasks."""
11
- os.environ.setdefault("DJANGO_SETTINGS_MODULE", "fnschool.settings")
12
- try:
13
- from django.core.management import execute_from_command_line
14
- except ImportError as exc:
15
- raise ImportError(
16
- "Couldn't import Django. Are you sure it's installed and "
17
- "available on your PYTHONPATH environment variable? Did you "
18
- "forget to activate a virtual environment?"
19
- ) from exc
20
-
21
- execute_from_command_line(sys.argv)
22
-
23
-
24
- if __name__ == "__main__":
25
- main()
@@ -1,2 +0,0 @@
1
- [console_scripts]
2
- fnschool-cli = fnschoo1:main