fnschool 20251016.81833.820__py3-none-any.whl → 20251018.80430.821__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.
- fnschoo1/__init__.py +1 -1
- fnschoo1/canteen/models.py +4 -0
- fnschoo1/canteen/templates/canteen/category/create.html +3 -1
- fnschoo1/canteen/templates/canteen/category/delete.html +3 -1
- fnschoo1/canteen/templates/canteen/category/update.html +3 -1
- fnschoo1/canteen/templates/canteen/consumption/create.html +46 -32
- fnschoo1/canteen/templates/canteen/ingredient/create.html +6 -2
- fnschoo1/canteen/templates/canteen/ingredient/create_one.html +3 -1
- fnschoo1/canteen/templates/canteen/ingredient/delete.html +3 -1
- fnschoo1/canteen/templates/canteen/ingredient/list.html +3 -1
- fnschoo1/canteen/templates/canteen/ingredient/update.html +3 -1
- fnschoo1/canteen/templates/canteen/meal_type/create.html +3 -1
- fnschoo1/canteen/templates/canteen/meal_type/delete.html +3 -1
- fnschoo1/canteen/templates/canteen/meal_type/update.html +3 -1
- fnschoo1/canteen/views.py +11 -2
- fnschoo1/canteen/workbook/generate.py +546 -22
- fnschoo1/locale/zh_Hans/LC_MESSAGES/django.mo +0 -0
- fnschoo1/profiles/templates/profiles/create.html +3 -1
- fnschoo1/profiles/templates/profiles/detail.html +3 -1
- fnschoo1/profiles/templates/profiles/edit.html +3 -1
- fnschoo1/profiles/templates/profiles/log_in.html +3 -1
- fnschoo1/templates/includes/_footer.html +12 -4
- fnschoo1/templates/includes/_paginator.html +3 -1
- {fnschool-20251016.81833.820.dist-info → fnschool-20251018.80430.821.dist-info}/METADATA +1 -1
- {fnschool-20251016.81833.820.dist-info → fnschool-20251018.80430.821.dist-info}/RECORD +34 -34
- {fnschool-20251016.81833.820.dist-info → fnschool-20251018.80430.821.dist-info}/SOURCES.txt.py +0 -0
- {fnschool-20251016.81833.820.dist-info → fnschool-20251018.80430.821.dist-info}/WHEEL +0 -0
- {fnschool-20251016.81833.820.dist-info → fnschool-20251018.80430.821.dist-info}/dependency_links.txt.py +0 -0
- {fnschool-20251016.81833.820.dist-info → fnschool-20251018.80430.821.dist-info}/entry_points.txt +0 -0
- {fnschool-20251016.81833.820.dist-info → fnschool-20251018.80430.821.dist-info}/entry_points.txt.py +0 -0
- {fnschool-20251016.81833.820.dist-info → fnschool-20251018.80430.821.dist-info}/licenses/LICENSE +0 -0
- {fnschool-20251016.81833.820.dist-info → fnschool-20251018.80430.821.dist-info}/requires.txt.py +0 -0
- {fnschool-20251016.81833.820.dist-info → fnschool-20251018.80430.821.dist-info}/top_level.txt +0 -0
- {fnschool-20251016.81833.820.dist-info → fnschool-20251018.80430.821.dist-info}/top_level.txt.py +0 -0
fnschoo1/__init__.py
CHANGED
fnschoo1/canteen/models.py
CHANGED
|
@@ -113,6 +113,10 @@ class Ingredient(models.Model):
|
|
|
113
113
|
default=False, verbose_name=_("Is Ingredient Disabled")
|
|
114
114
|
)
|
|
115
115
|
|
|
116
|
+
def __init__(self, *args, **kwargs):
|
|
117
|
+
super().__init__(*args, **kwargs)
|
|
118
|
+
self.quantity_used = Decimal("0")
|
|
119
|
+
|
|
116
120
|
@property
|
|
117
121
|
def unit_price(self):
|
|
118
122
|
if self.quantity > 0:
|
|
@@ -11,7 +11,9 @@
|
|
|
11
11
|
{{ form|crispy }}
|
|
12
12
|
<div class="py-3 fixed-bottom text-end bg-dark">
|
|
13
13
|
<button type="submit" class="btn btn-primary">{% trans "Save" %}</button>
|
|
14
|
-
<button type="button" class="btn btn-danger" onclick="window.close();">
|
|
14
|
+
<button type="button" class="btn btn-danger" onclick="window.close();">
|
|
15
|
+
{% trans "Cancel" %}
|
|
16
|
+
</button>
|
|
15
17
|
</div>
|
|
16
18
|
</form>
|
|
17
19
|
{% endblock %}
|
|
@@ -55,7 +55,9 @@
|
|
|
55
55
|
style="display: inline">
|
|
56
56
|
{% csrf_token %}
|
|
57
57
|
<button type="submit" class="btn btn-danger">{% trans 'Delete' %}</button>
|
|
58
|
-
<button type="button" class="btn btn-primary" onclick="window.close();">
|
|
58
|
+
<button type="button" class="btn btn-primary" onclick="window.close();">
|
|
59
|
+
{% trans "Cancel" %}
|
|
60
|
+
</button>
|
|
59
61
|
</form>
|
|
60
62
|
</div>
|
|
61
63
|
<script>
|
|
@@ -17,7 +17,9 @@
|
|
|
17
17
|
{% csrf_token %} {{ form|crispy }}
|
|
18
18
|
<div class="py-3 fixed-bottom text-end bg-dark">
|
|
19
19
|
<button type="submit" class="btn btn-primary">{% trans "Save" %}</button>
|
|
20
|
-
<button type="button" class="btn btn-danger" onclick="window.close();">
|
|
20
|
+
<button type="button" class="btn btn-danger" onclick="window.close();">
|
|
21
|
+
{% trans "Cancel" %}
|
|
22
|
+
</button>
|
|
21
23
|
</div>
|
|
22
24
|
</form>
|
|
23
25
|
{% endblock %}
|
|
@@ -9,10 +9,14 @@
|
|
|
9
9
|
<div class="container">
|
|
10
10
|
<div class="row justify-content-end">
|
|
11
11
|
<button class="btn btn-outline-success col-md-1 col-lg-1 col-2 mx-2"
|
|
12
|
-
onclick="list_consumptions_by_week();">
|
|
12
|
+
onclick="list_consumptions_by_week();">
|
|
13
|
+
{% trans "Consume by Week" %}
|
|
14
|
+
</button>
|
|
13
15
|
|
|
14
16
|
<button class="btn btn-outline-success col-md-1 col-lg-1 col-2"
|
|
15
|
-
onclick="list_consumptions_rapidly();">
|
|
17
|
+
onclick="list_consumptions_rapidly();">
|
|
18
|
+
{% trans "Rapid Consumption" %}
|
|
19
|
+
</button>
|
|
16
20
|
|
|
17
21
|
<a class="btn btn-success col-md-1 col-lg-1 col-2 mx-2"
|
|
18
22
|
target="canteen_list_categories"
|
|
@@ -65,6 +69,9 @@
|
|
|
65
69
|
data-ingredient_id="{{ ingredient.id }}"
|
|
66
70
|
data-ingredient_name="{{ ingredient.name }}"
|
|
67
71
|
data-ingredient_quantity="{{ ingredient.quantity }}"
|
|
72
|
+
data-ingredient_quantity_used="{{ ingredient.quantity_used }}"
|
|
73
|
+
data-ingredient_remaining_quantity="{{ ingredient.remaining_quantity }}"
|
|
74
|
+
data-ingredient_consuming_quantity="{{ ingredient.consuming_quantity }}"
|
|
68
75
|
data-ingredient_total_price="{{ ingredient.total_price }}"
|
|
69
76
|
data-ingredient_meal_type="{{ ingredient.meal_type }}"
|
|
70
77
|
data-ingredient_quantity_unit_name="{{ ingredient.quantity_unit_name }}"
|
|
@@ -73,16 +80,15 @@
|
|
|
73
80
|
<td title="{% blocktrans with storage_date=ingredient.storage_date %}Storaged on {{ storage_date }} .{% endblocktrans %}"
|
|
74
81
|
class="">
|
|
75
82
|
<div class='ingredient-progress'
|
|
76
|
-
style="width:{% widthratio ingredient.remaining_quantity ingredient.quantity 100 %}%"
|
|
83
|
+
style="width:{% widthratio ingredient.remaining_quantity ingredient.quantity 100 %}%">
|
|
84
|
+
</div>
|
|
77
85
|
{{ ingredient.name }}
|
|
78
86
|
{% if ingredient.meal_type != meal_type_name_0 %}
|
|
79
87
|
<br />
|
|
80
88
|
({{ ingredient.meal_type }})
|
|
81
89
|
{% endif %}
|
|
82
90
|
</td>
|
|
83
|
-
<td name="remaining_{{ ingredient.id }}">
|
|
84
|
-
{{ ingredient.quantity }}-{{ ingredient.consuming_quantity }}={{ ingredient.remaining_quantity }}
|
|
85
|
-
</td>
|
|
91
|
+
<td name="remaining_{{ ingredient.id }}"></td>
|
|
86
92
|
</tr>
|
|
87
93
|
{% empty %}
|
|
88
94
|
<tr>{% trans "No ingredient found." %}</tr>
|
|
@@ -91,13 +97,21 @@
|
|
|
91
97
|
</table>
|
|
92
98
|
</div>
|
|
93
99
|
<div class="">
|
|
94
|
-
<button id="body_mp0_trigger"
|
|
95
|
-
onclick="set_body_to_mp0();"
|
|
96
|
-
class="btn btn-submit-consumptions btn-success float-end">||</button>
|
|
97
100
|
<button onclick="generate_spreadsheet();"
|
|
98
|
-
class="btn btn-submit-consumptions btn-success float-end">
|
|
101
|
+
class="btn btn-submit-consumptions btn-success float-end">
|
|
102
|
+
{% trans "Generate Spreadsheet" %}
|
|
103
|
+
</button>
|
|
99
104
|
<select class="workbook-month-select form-select float-end mx-2"
|
|
100
105
|
style="width:118px"></select>
|
|
106
|
+
<div class="form-check float-end mx-1 pt-2">
|
|
107
|
+
<label class="form-check-label" for="include_food_sheets">
|
|
108
|
+
{% trans 'Ingredient Sheets are also included.' %}
|
|
109
|
+
</label>
|
|
110
|
+
<input class="form-check-input"
|
|
111
|
+
type="checkbox"
|
|
112
|
+
value=""
|
|
113
|
+
id="include_food_sheets">
|
|
114
|
+
</div>
|
|
101
115
|
</div>
|
|
102
116
|
{{ ingredient_ids|json_script:'ingredient_ids' }}
|
|
103
117
|
{{ months|json_script:'months' }}
|
|
@@ -110,31 +124,24 @@
|
|
|
110
124
|
var months = JSON.parse($("#months").text())
|
|
111
125
|
var meal_types = JSON.parse($("#meal_types").text())
|
|
112
126
|
var date_range = JSON.parse($("#date_range").text())
|
|
113
|
-
|
|
114
127
|
var storage_date_start = $('#storage_date_start').text().replace(new RegExp('"', 'g'), "")
|
|
115
128
|
|
|
116
129
|
var dont_submit = false
|
|
117
130
|
|
|
118
131
|
$(document).ready(function() {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
$(
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
132
|
+
$(ingredient_ids).each(function(index, ingredient_id) {
|
|
133
|
+
var td = $(`td[name='remaining_${ingredient_id}']`)
|
|
134
|
+
var tr = $(td.closest("tr"))
|
|
135
|
+
var ingredient_quantity = parseInt(tr.data("ingredient_quantity")) || 0
|
|
136
|
+
var ingredient_quantity_used = parseInt(tr.data("ingredient_quantity_used")) || 0
|
|
137
|
+
var ingredient_consuming_quantity = parseInt(tr.data("ingredient_consuming_quantity")) || 0
|
|
138
|
+
var ingredient_remaining_quantity = parseInt(tr.data("ingredient_remaining_quantity")) || 0
|
|
139
|
+
td.text(
|
|
140
|
+
`${ingredient_quantity-ingredient_quantity_used}-${ingredient_consuming_quantity-ingredient_quantity_used}=${ingredient_remaining_quantity}`
|
|
141
|
+
)
|
|
142
|
+
});
|
|
126
143
|
|
|
127
|
-
|
|
128
|
-
if ($('body').hasClass("m-0")) {
|
|
129
|
-
set_simple_cookie("body_mp0", "")
|
|
130
|
-
$("#body_mp0_trigger").html(">")
|
|
131
|
-
$('body').removeClass("m-0 p-0");
|
|
132
|
-
} else {
|
|
133
|
-
set_simple_cookie("body_mp0", "1")
|
|
134
|
-
$('#body_mp0_trigger').html("<")
|
|
135
|
-
$('body').addClass("m-0 p-0");
|
|
136
|
-
}
|
|
137
|
-
}
|
|
144
|
+
});
|
|
138
145
|
|
|
139
146
|
function list_consumptions_rapidly() {
|
|
140
147
|
query = {
|
|
@@ -239,8 +246,10 @@
|
|
|
239
246
|
|
|
240
247
|
function amount_used_input_blur(element) {
|
|
241
248
|
element = $(element)
|
|
242
|
-
var ingredient_quantity = element.closest('tr').data("ingredient_quantity")
|
|
243
|
-
|
|
249
|
+
var ingredient_quantity = parseInt(element.closest('tr').data("ingredient_quantity")) || 0
|
|
250
|
+
var ingredient_quantity_used = parseInt(element.closest("tr").data("ingredient_quantity_used")) || 0
|
|
251
|
+
ingredient_quantity = ingredient_quantity - ingredient_quantity_used
|
|
252
|
+
|
|
244
253
|
var $consumption_form = element.closest("form")
|
|
245
254
|
var amount_used = parseInt($consumption_form.data("amount_used")) || 0
|
|
246
255
|
var new_amount_used = parseInt($.trim(element.val())) || 0
|
|
@@ -386,8 +395,13 @@
|
|
|
386
395
|
});
|
|
387
396
|
|
|
388
397
|
function generate_spreadsheet() {
|
|
398
|
+
var include_food_sheets = $("#include_food_sheets").is(':checked')
|
|
389
399
|
var month = $(".workbook-month-select").val()
|
|
390
|
-
|
|
400
|
+
if (include_food_sheets) {
|
|
401
|
+
window.open(`/canteen/generate_spreadsheet/${month}?include_food_sheets=true`, 'generate_spreadsheet');
|
|
402
|
+
} else {
|
|
403
|
+
window.open(`/canteen/generate_spreadsheet/${month}`, 'generate_spreadsheet');
|
|
404
|
+
}
|
|
391
405
|
}
|
|
392
406
|
|
|
393
407
|
function set_consumptions_table_size() {
|
|
@@ -12,8 +12,12 @@
|
|
|
12
12
|
<form method="post" enctype="multipart/form-data">
|
|
13
13
|
{% csrf_token %} {{ form|crispy }}
|
|
14
14
|
<div class="py-3 fixed-bottom text-end bg-dark">
|
|
15
|
-
<button type="submit button" class="btn btn-outline-primary">
|
|
16
|
-
|
|
15
|
+
<button type="submit button" class="btn btn-outline-primary">
|
|
16
|
+
{% trans "Upload" %}
|
|
17
|
+
</button>
|
|
18
|
+
<button type="button" class="btn btn-danger" onclick="window.close();">
|
|
19
|
+
{% trans "Cancel" %}
|
|
20
|
+
</button>
|
|
17
21
|
</div>
|
|
18
22
|
</form>
|
|
19
23
|
{% endblock %}
|
|
@@ -11,7 +11,9 @@
|
|
|
11
11
|
{{ form|crispy }}
|
|
12
12
|
<div class="py-3 fixed-bottom text-end bg-dark">
|
|
13
13
|
<button type="submit" class="btn btn-primary">{% trans "Save" %}</button>
|
|
14
|
-
<button type="button" class="btn btn-danger" onclick="window.close();">
|
|
14
|
+
<button type="button" class="btn btn-danger" onclick="window.close();">
|
|
15
|
+
{% trans "Cancel" %}
|
|
16
|
+
</button>
|
|
15
17
|
</div>
|
|
16
18
|
</form>
|
|
17
19
|
{% endblock %}
|
|
@@ -32,7 +32,9 @@
|
|
|
32
32
|
style="display: inline">
|
|
33
33
|
{% csrf_token %}
|
|
34
34
|
<button type="submit" class="btn btn-danger">{% trans 'Delete' %}</button>
|
|
35
|
-
<button type="button" class="btn btn-primary" onclick="window.close();">
|
|
35
|
+
<button type="button" class="btn btn-primary" onclick="window.close();">
|
|
36
|
+
{% trans "Cancel" %}
|
|
37
|
+
</button>
|
|
36
38
|
</form>
|
|
37
39
|
</div>
|
|
38
40
|
<script>
|
|
@@ -63,7 +63,9 @@
|
|
|
63
63
|
class="form-check-input"
|
|
64
64
|
id="ingredient_free_nark_{{ ingredient.id }}" />
|
|
65
65
|
<label class="form-check-label"
|
|
66
|
-
for="ingredient_free_nark_{{ ingredient.id }}">
|
|
66
|
+
for="ingredient_free_nark_{{ ingredient.id }}">
|
|
67
|
+
{{ forloop.counter }}
|
|
68
|
+
</label>
|
|
67
69
|
</div>
|
|
68
70
|
</th>
|
|
69
71
|
<td>{{ ingredient.storage_date }}</td>
|
|
@@ -17,7 +17,9 @@
|
|
|
17
17
|
{% csrf_token %} {{ form|crispy }}
|
|
18
18
|
<div class="py-3 fixed-bottom text-end bg-dark">
|
|
19
19
|
<button type="submit" class="btn btn-primary">{% trans "Save" %}</button>
|
|
20
|
-
<button type="button" class="btn btn-danger" onclick="window.close();">
|
|
20
|
+
<button type="button" class="btn btn-danger" onclick="window.close();">
|
|
21
|
+
{% trans "Cancel" %}
|
|
22
|
+
</button>
|
|
21
23
|
</div>
|
|
22
24
|
</form>
|
|
23
25
|
{% endblock %}
|
|
@@ -11,7 +11,9 @@
|
|
|
11
11
|
{{ form|crispy }}
|
|
12
12
|
<div class="py-3 fixed-bottom text-end bg-dark">
|
|
13
13
|
<button type="submit" class="btn btn-primary">{% trans "Save" %}</button>
|
|
14
|
-
<button type="button" class="btn btn-danger" onclick="window.close();">
|
|
14
|
+
<button type="button" class="btn btn-danger" onclick="window.close();">
|
|
15
|
+
{% trans "Cancel" %}
|
|
16
|
+
</button>
|
|
15
17
|
</div>
|
|
16
18
|
</form>
|
|
17
19
|
{% endblock %}
|
|
@@ -47,7 +47,9 @@
|
|
|
47
47
|
style="display: inline">
|
|
48
48
|
{% csrf_token %}
|
|
49
49
|
<button type="submit" class="btn btn-danger">{% trans 'Delete' %}</button>
|
|
50
|
-
<button type="button" class="btn btn-primary" onclick="window.close();">
|
|
50
|
+
<button type="button" class="btn btn-primary" onclick="window.close();">
|
|
51
|
+
{% trans "Cancel" %}
|
|
52
|
+
</button>
|
|
51
53
|
</form>
|
|
52
54
|
</div>
|
|
53
55
|
<script>
|
|
@@ -17,7 +17,9 @@
|
|
|
17
17
|
{% csrf_token %} {{ form|crispy }}
|
|
18
18
|
<div class="py-3 fixed-bottom text-end bg-dark">
|
|
19
19
|
<button type="submit" class="btn btn-primary">{% trans "Save" %}</button>
|
|
20
|
-
<button type="button" class="btn btn-danger" onclick="window.close();">
|
|
20
|
+
<button type="button" class="btn btn-danger" onclick="window.close();">
|
|
21
|
+
{% trans "Cancel" %}
|
|
22
|
+
</button>
|
|
21
23
|
</div>
|
|
22
24
|
</form>
|
|
23
25
|
{% endblock %}
|
fnschoo1/canteen/views.py
CHANGED
|
@@ -248,8 +248,7 @@ def create_consumptions(request, ingredient_id=None):
|
|
|
248
248
|
) == "true" or not by_week
|
|
249
249
|
|
|
250
250
|
queries = (
|
|
251
|
-
Q(
|
|
252
|
-
& Q(storage_date__lte=date_end)
|
|
251
|
+
Q(storage_date__lte=date_end)
|
|
253
252
|
& Q(user=request.user)
|
|
254
253
|
& Q(is_disabled=False)
|
|
255
254
|
& Q(is_ignorable=False)
|
|
@@ -275,6 +274,13 @@ def create_consumptions(request, ingredient_id=None):
|
|
|
275
274
|
{"ingredients": ingredients, "date_range": date_range},
|
|
276
275
|
)
|
|
277
276
|
|
|
277
|
+
ingredients = [
|
|
278
|
+
i
|
|
279
|
+
for i in ingredients
|
|
280
|
+
if i.get_remaining_quantity(date_end) > 0
|
|
281
|
+
or i.storage_date >= date_start
|
|
282
|
+
]
|
|
283
|
+
|
|
278
284
|
ingredients_pinned = []
|
|
279
285
|
ingredients_unpinned = []
|
|
280
286
|
categories_top = Category.objects.filter(
|
|
@@ -291,6 +297,9 @@ def create_consumptions(request, ingredient_id=None):
|
|
|
291
297
|
|
|
292
298
|
ingredients = ingredients_pinned + ingredients_unpinned
|
|
293
299
|
|
|
300
|
+
for ingredient in ingredients:
|
|
301
|
+
ingredient.quantity_used = ingredient.get_consuming_quantity(date_start)
|
|
302
|
+
|
|
294
303
|
date_range_cp = date_range
|
|
295
304
|
date_range_cp = [d.strftime("%Y-%m-%d") for d in date_range]
|
|
296
305
|
meal_types = list(set([i.meal_type.name for i in ingredients]))
|