fnschool 20251012.81520.855__py3-none-any.whl → 20251013.81200.824__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 +2 -2
- fnschoo1/canteen/templates/canteen/consumption/create.html +3 -0
- fnschoo1/canteen/workbook/generate.py +88 -56
- {fnschool-20251012.81520.855.dist-info → fnschool-20251013.81200.824.dist-info}/METADATA +1 -1
- {fnschool-20251012.81520.855.dist-info → fnschool-20251013.81200.824.dist-info}/RECORD +9 -9
- {fnschool-20251012.81520.855.dist-info → fnschool-20251013.81200.824.dist-info}/WHEEL +0 -0
- {fnschool-20251012.81520.855.dist-info → fnschool-20251013.81200.824.dist-info}/entry_points.txt +0 -0
- {fnschool-20251012.81520.855.dist-info → fnschool-20251013.81200.824.dist-info}/licenses/LICENSE +0 -0
- {fnschool-20251012.81520.855.dist-info → fnschool-20251013.81200.824.dist-info}/top_level.txt +0 -0
fnschoo1/__init__.py
CHANGED
|
@@ -6,7 +6,7 @@ import random
|
|
|
6
6
|
import sys
|
|
7
7
|
from pathlib import Path
|
|
8
8
|
|
|
9
|
-
__version__ = "
|
|
9
|
+
__version__ = "20251013.81200.824"
|
|
10
10
|
|
|
11
11
|
FNSCHOOL_PATH = Path(__file__).parent
|
|
12
12
|
if FNSCHOOL_PATH.as_posix() not in sys.path:
|
|
@@ -46,7 +46,7 @@ def main():
|
|
|
46
46
|
if is_windows:
|
|
47
47
|
os.startfile(local_url)
|
|
48
48
|
else:
|
|
49
|
-
os.system("open " + local_url)
|
|
49
|
+
os.system("sleep 5 && open " + local_url)
|
|
50
50
|
except Exception as e:
|
|
51
51
|
print(e)
|
|
52
52
|
|
|
@@ -8,6 +8,9 @@
|
|
|
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>
|
|
13
|
+
|
|
11
14
|
<div class="col col-3 col-md-2 col-lg-2">
|
|
12
15
|
<input class=" form-control"
|
|
13
16
|
onkeydown="if(event.keyCode==13){list_consumptions();}"
|
|
@@ -15,7 +15,15 @@ from dateutil.relativedelta import relativedelta
|
|
|
15
15
|
from django.contrib.auth.decorators import login_required
|
|
16
16
|
from django.contrib.auth.mixins import LoginRequiredMixin
|
|
17
17
|
from django.core.paginator import EmptyPage, PageNotAnInteger, Paginator
|
|
18
|
-
from django.db.models import
|
|
18
|
+
from django.db.models import (
|
|
19
|
+
Count,
|
|
20
|
+
DecimalField,
|
|
21
|
+
ExpressionWrapper,
|
|
22
|
+
F,
|
|
23
|
+
Q,
|
|
24
|
+
Sum,
|
|
25
|
+
Value,
|
|
26
|
+
)
|
|
19
27
|
from django.db.models.functions import Coalesce
|
|
20
28
|
from django.http import HttpResponse
|
|
21
29
|
from django.shortcuts import get_object_or_404, redirect, render
|
|
@@ -1597,54 +1605,69 @@ class CanteenWorkBook:
|
|
|
1597
1605
|
& Q(is_disabled=False)
|
|
1598
1606
|
& Q(is_ignorable=False)
|
|
1599
1607
|
).all()
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
i.storage_date
|
|
1609
|
-
for i in ingredients
|
|
1610
|
-
if i.storage_date >= self.date_start
|
|
1608
|
+
|
|
1609
|
+
consumptions = []
|
|
1610
|
+
for ingredient in ingredients:
|
|
1611
|
+
consumptions += [
|
|
1612
|
+
c
|
|
1613
|
+
for c in ingredient.consumptions.filter(
|
|
1614
|
+
Q(date_of_using__lte=self.date_end) & Q(is_disabled=False)
|
|
1615
|
+
).all()
|
|
1611
1616
|
]
|
|
1617
|
+
|
|
1618
|
+
inventory_days = []
|
|
1619
|
+
dates_of_using = sorted(
|
|
1620
|
+
list(set([c.date_of_using for c in consumptions]))
|
|
1612
1621
|
)
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1622
|
+
for i, date_of_using in enumerate(dates_of_using):
|
|
1623
|
+
if i + 1 < len(dates_of_using):
|
|
1624
|
+
if (date_of_using + timedelta(days=1)) < dates_of_using[i + 1]:
|
|
1625
|
+
inventory_days.append(date_of_using)
|
|
1626
|
+
else:
|
|
1627
|
+
inventory_days.append(date_of_using)
|
|
1617
1628
|
|
|
1629
|
+
if len(inventory_days) < 1:
|
|
1630
|
+
inventory_days.insert(-1, self.date_end)
|
|
1631
|
+
|
|
1632
|
+
inventory_days.insert(
|
|
1633
|
+
0, (self.date_start.replace(day=1) - timedelta(days=1))
|
|
1634
|
+
)
|
|
1618
1635
|
formed_ingredients = []
|
|
1619
|
-
for
|
|
1620
|
-
|
|
1636
|
+
for inventory_day in inventory_days:
|
|
1637
|
+
inventory_day_ingredients = []
|
|
1621
1638
|
for ingredient in ingredients:
|
|
1639
|
+
if (
|
|
1640
|
+
ingredient.storage_date > inventory_day
|
|
1641
|
+
and inventory_day != inventory_days[-1]
|
|
1642
|
+
):
|
|
1643
|
+
continue
|
|
1622
1644
|
remaining_quantity = ingredient.quantity - sum(
|
|
1623
1645
|
[
|
|
1624
1646
|
c.amount_used
|
|
1625
1647
|
for c in ingredient.consumptions.filter(
|
|
1626
1648
|
Q(is_disabled=False)
|
|
1649
|
+
& Q(date_of_using__lte=inventory_day)
|
|
1627
1650
|
).all()
|
|
1628
|
-
if c.date_of_using <= sunday
|
|
1629
1651
|
]
|
|
1630
1652
|
)
|
|
1631
1653
|
if remaining_quantity > Decimal("0.0"):
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
form_count = len(sunday_ingredients) / ingredient_rows_count
|
|
1654
|
+
inventory_day_ingredients.append(ingredient)
|
|
1655
|
+
form_count = len(inventory_day_ingredients) / ingredient_rows_count
|
|
1635
1656
|
surplus_ingredients_len = (
|
|
1636
|
-
len(
|
|
1657
|
+
len(inventory_day_ingredients) % ingredient_rows_count
|
|
1637
1658
|
)
|
|
1638
1659
|
fake_ingredients_len = (
|
|
1639
1660
|
ingredient_rows_count - surplus_ingredients_len
|
|
1640
1661
|
)
|
|
1641
1662
|
|
|
1642
|
-
|
|
1643
|
-
|
|
1663
|
+
inventory_day_ingredients = sorted(
|
|
1664
|
+
inventory_day_ingredients, key=lambda i: i.category.name
|
|
1644
1665
|
)
|
|
1645
1666
|
|
|
1646
|
-
|
|
1647
|
-
|
|
1667
|
+
if len(inventory_day_ingredients) < 1:
|
|
1668
|
+
continue
|
|
1669
|
+
s_ingredient0 = inventory_day_ingredients[0]
|
|
1670
|
+
inventory_day_ingredients += [
|
|
1648
1671
|
Ingredient(
|
|
1649
1672
|
user=user,
|
|
1650
1673
|
storage_date=self.date_start,
|
|
@@ -1660,17 +1683,21 @@ class CanteenWorkBook:
|
|
|
1660
1683
|
for i in range(fake_ingredients_len)
|
|
1661
1684
|
]
|
|
1662
1685
|
for index in range(
|
|
1663
|
-
0, len(
|
|
1686
|
+
0, len(inventory_day_ingredients), ingredient_rows_count
|
|
1664
1687
|
):
|
|
1665
|
-
split_ingredients =
|
|
1688
|
+
split_ingredients = inventory_day_ingredients[
|
|
1666
1689
|
index : index + ingredient_rows_count
|
|
1667
1690
|
]
|
|
1668
1691
|
|
|
1669
|
-
formed_ingredients.append(
|
|
1692
|
+
formed_ingredients.append(
|
|
1693
|
+
[inventory_day, index, split_ingredients]
|
|
1694
|
+
)
|
|
1670
1695
|
|
|
1671
|
-
for index, (
|
|
1672
|
-
|
|
1673
|
-
|
|
1696
|
+
for index, (
|
|
1697
|
+
inventory_day,
|
|
1698
|
+
inventory_day_index,
|
|
1699
|
+
ingredients,
|
|
1700
|
+
) in enumerate(formed_ingredients):
|
|
1674
1701
|
|
|
1675
1702
|
title_row_num = (ingredient_rows_count + 8) * index + 1
|
|
1676
1703
|
title_cell = sheet.cell(title_row_num, 1)
|
|
@@ -1693,9 +1720,9 @@ class CanteenWorkBook:
|
|
|
1693
1720
|
)
|
|
1694
1721
|
).format(
|
|
1695
1722
|
affiliation=user.affiliation,
|
|
1696
|
-
year=
|
|
1697
|
-
month=
|
|
1698
|
-
day=
|
|
1723
|
+
year=inventory_day.year,
|
|
1724
|
+
month=inventory_day.month,
|
|
1725
|
+
day=inventory_day.day,
|
|
1699
1726
|
)
|
|
1700
1727
|
|
|
1701
1728
|
sub_title_affiliation_date_cell.font = self.font_12
|
|
@@ -1766,6 +1793,7 @@ class CanteenWorkBook:
|
|
|
1766
1793
|
)
|
|
1767
1794
|
|
|
1768
1795
|
summary_total_price = Decimal("0.0")
|
|
1796
|
+
formed_ingredients_index = index
|
|
1769
1797
|
for index, ingredient in enumerate(ingredients):
|
|
1770
1798
|
ingredient_row_num = header1_row_num + index + 1
|
|
1771
1799
|
ingredient_quantity = (
|
|
@@ -1774,9 +1802,9 @@ class CanteenWorkBook:
|
|
|
1774
1802
|
[
|
|
1775
1803
|
c.amount_used
|
|
1776
1804
|
for c in ingredient.consumptions.filter(
|
|
1777
|
-
|
|
1805
|
+
Q(date_of_using__lte=inventory_day)
|
|
1806
|
+
& Q(is_disabled=False)
|
|
1778
1807
|
).all()
|
|
1779
|
-
if c.date_of_using <= sunday
|
|
1780
1808
|
]
|
|
1781
1809
|
)
|
|
1782
1810
|
if ingredient.id
|
|
@@ -1808,25 +1836,29 @@ class CanteenWorkBook:
|
|
|
1808
1836
|
|
|
1809
1837
|
summary_row_num = header1_row_num + ingredient_rows_count + 1
|
|
1810
1838
|
|
|
1811
|
-
|
|
1812
|
-
formed_ingredients[
|
|
1813
|
-
if 0 <=
|
|
1839
|
+
prev_inventory_day = (
|
|
1840
|
+
formed_ingredients[formed_ingredients_index - 1][0]
|
|
1841
|
+
if 0 <= formed_ingredients_index - 1 < len(formed_ingredients)
|
|
1814
1842
|
else None
|
|
1815
1843
|
)
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
if 0 <
|
|
1844
|
+
next_inventory_day = (
|
|
1845
|
+
formed_ingredients[formed_ingredients_index + 1][0]
|
|
1846
|
+
if 0 < formed_ingredients_index + 1 < len(formed_ingredients)
|
|
1819
1847
|
else None
|
|
1820
1848
|
)
|
|
1821
|
-
|
|
1849
|
+
summary_col1_value = ""
|
|
1822
1850
|
|
|
1823
|
-
if
|
|
1824
|
-
|
|
1851
|
+
if next_inventory_day and next_inventory_day == inventory_day:
|
|
1852
|
+
summary_col1_value = _(
|
|
1853
|
+
"Sub0-summary Total Price (Surplus Sheet)"
|
|
1854
|
+
)
|
|
1855
|
+
else:
|
|
1856
|
+
summary_col1_value = _("Summary Total Price (Surplus Sheet)")
|
|
1825
1857
|
summary_total_price = Decimal("0.0")
|
|
1826
1858
|
ingredients_list = [
|
|
1827
1859
|
__ingredients
|
|
1828
|
-
for
|
|
1829
|
-
if
|
|
1860
|
+
for __inventory_day, __inventory_day_index, __ingredients in formed_ingredients
|
|
1861
|
+
if __inventory_day == inventory_day
|
|
1830
1862
|
]
|
|
1831
1863
|
for ingredients in ingredients_list:
|
|
1832
1864
|
for ingredient in ingredients:
|
|
@@ -1835,7 +1867,8 @@ class CanteenWorkBook:
|
|
|
1835
1867
|
[
|
|
1836
1868
|
c.amount_used
|
|
1837
1869
|
for c in ingredient.consumptions.filter(
|
|
1838
|
-
is_disabled=False
|
|
1870
|
+
Q(is_disabled=False)
|
|
1871
|
+
& Q(date_of_using__lte=inventory_day)
|
|
1839
1872
|
).all()
|
|
1840
1873
|
]
|
|
1841
1874
|
)
|
|
@@ -1846,10 +1879,7 @@ class CanteenWorkBook:
|
|
|
1846
1879
|
ingredient_quantity * ingredient.unit_price
|
|
1847
1880
|
)
|
|
1848
1881
|
|
|
1849
|
-
|
|
1850
|
-
summary_1_value = _("Sub0-summary Total Price (Surplus Sheet)")
|
|
1851
|
-
|
|
1852
|
-
sheet.cell(summary_row_num, 1, summary_1_value)
|
|
1882
|
+
sheet.cell(summary_row_num, 1, summary_col1_value)
|
|
1853
1883
|
|
|
1854
1884
|
sheet.cell(summary_row_num, 4, summary_total_price)
|
|
1855
1885
|
sheet.cell(summary_row_num, 6, summary_total_price)
|
|
@@ -2088,8 +2118,10 @@ class CanteenWorkBook:
|
|
|
2088
2118
|
|
|
2089
2119
|
|
|
2090
2120
|
def get_workbook_zip(request, month):
|
|
2091
|
-
meal_types = MealType.objects.
|
|
2092
|
-
|
|
2121
|
+
meal_types = MealType.objects.annotate(
|
|
2122
|
+
ingredients_count=Count("ingredients")
|
|
2123
|
+
).filter(
|
|
2124
|
+
Q(user=request.user) & Q(is_disabled=False) & Q(ingredients_count__gt=0)
|
|
2093
2125
|
)
|
|
2094
2126
|
|
|
2095
2127
|
zip_buffer = io.BytesIO()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: fnschool
|
|
3
|
-
Version:
|
|
3
|
+
Version: 20251013.81200.824
|
|
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>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
fnschoo1/__init__.py,sha256=
|
|
1
|
+
fnschoo1/__init__.py,sha256=SbSXFTr7zEcgWFHg92chlgThEpDfsUOXtDTKRjyh-Ns,1507
|
|
2
2
|
fnschoo1/manage.py,sha256=pMv0yE2eTcNrgskSHDUdRrnY51iTm1DXg32I8mWDDqw,696
|
|
3
3
|
fnschoo1/canteen/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
4
|
fnschoo1/canteen/admin.py,sha256=suMo4x8I3JBxAFBVIdE-5qnqZ6JAZV0FESABHOSc-vg,63
|
|
@@ -28,7 +28,7 @@ fnschoo1/canteen/templates/canteen/category/delete.html,sha256=MnPyFzjO3HonOljwx
|
|
|
28
28
|
fnschoo1/canteen/templates/canteen/category/list.html,sha256=aj81uoA-jmdv8mZT-Y9DxjOHVGrSfI1z0DB1YnJWb4w,2045
|
|
29
29
|
fnschoo1/canteen/templates/canteen/category/update.html,sha256=8Nzdbe8UorrJHzElkrdqvLaPnUvcvGhrViZB4D86wqo,815
|
|
30
30
|
fnschoo1/canteen/templates/canteen/consumption/_create.html,sha256=lpST1R0vL1PEI1YE9d0-bcWWpCMH-INjIF-7pweAHuU,1008
|
|
31
|
-
fnschoo1/canteen/templates/canteen/consumption/create.html,sha256=
|
|
31
|
+
fnschoo1/canteen/templates/canteen/consumption/create.html,sha256=KQbx4htFR_KjBJXqVvcZcZFDmRdASD5Hltu7NZF7-g0,14849
|
|
32
32
|
fnschoo1/canteen/templates/canteen/ingredient/close.html,sha256=pLYeJmGaOEJKMUJdZmYzz_n--l28IRDQ4fXvetP_Vsc,200
|
|
33
33
|
fnschoo1/canteen/templates/canteen/ingredient/create.html,sha256=xZvh0tP_cv2HPQ96JSHChO6Ni23tzHc5YJCUhE2yEqM,807
|
|
34
34
|
fnschoo1/canteen/templates/canteen/ingredient/create_one.html,sha256=O8EPSvAnEZ-4VJiwFdoyxJrMOoMpRkH6CyfvWwHaVgc,599
|
|
@@ -40,7 +40,7 @@ fnschoo1/canteen/templates/canteen/meal_type/delete.html,sha256=1UmCyXD-6lbYl-IE
|
|
|
40
40
|
fnschoo1/canteen/templates/canteen/meal_type/list.html,sha256=c5kJUE1OgpRtSrMV4wFwL_gbRSaX_XMM4Zt1JTx34_g,1907
|
|
41
41
|
fnschoo1/canteen/templates/canteen/meal_type/update.html,sha256=Rfv1TamSFIKHzvUNlgnmrPmfmzrehPpuo5Hv8VF0yek,818
|
|
42
42
|
fnschoo1/canteen/workbook/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
43
|
-
fnschoo1/canteen/workbook/generate.py,sha256=
|
|
43
|
+
fnschoo1/canteen/workbook/generate.py,sha256=n6q0s3qoHbKQ-DpaqcJarnTHsomndOb3DtfC66vHprE,83946
|
|
44
44
|
fnschoo1/fnschool/__init__.py,sha256=TmHhzykpKNMoMf6eD-EKvbvmnlzs1XGHtvD55ae1sXs,287
|
|
45
45
|
fnschoo1/fnschool/asgi.py,sha256=kzkqosS10uBlyBX53EXcsATcvEZmac6nsPzyOHCuucE,393
|
|
46
46
|
fnschoo1/fnschool/settings.py,sha256=l9Y1iQCivSfmsNfnHltfXLzxP6gG4VMIL4GEZgAp8YM,4357
|
|
@@ -93,9 +93,9 @@ fnschoo1/templates/includes/_navigation.html,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRk
|
|
|
93
93
|
fnschoo1/templates/includes/_paginator.html,sha256=Z-Hxcdmun4SJ1YcHnWTDLfW8wrngROiBTwr4NZWaPP4,1246
|
|
94
94
|
fnschoo1/templates/registration/logged_out.html,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
95
95
|
fnschoo1/templates/registration/login.html,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
96
|
-
fnschool-
|
|
97
|
-
fnschool-
|
|
98
|
-
fnschool-
|
|
99
|
-
fnschool-
|
|
100
|
-
fnschool-
|
|
101
|
-
fnschool-
|
|
96
|
+
fnschool-20251013.81200.824.dist-info/licenses/LICENSE,sha256=2n6rt7r999OuXp8iOqW9we7ORaxWncIbOwN1ILRGR2g,7651
|
|
97
|
+
fnschool-20251013.81200.824.dist-info/METADATA,sha256=b-copPlDf-Am6WcOCl1KGXm7KtzvYxL59wSYY5TL9Kk,4752
|
|
98
|
+
fnschool-20251013.81200.824.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
99
|
+
fnschool-20251013.81200.824.dist-info/entry_points.txt,sha256=To2PDA9r0qhE0Wq1-M8hEE8uXxTrTe16BOcpKPT-q5g,47
|
|
100
|
+
fnschool-20251013.81200.824.dist-info/top_level.txt,sha256=s6ZKnNm94Q0-247a50eI7jDK98uPF6P2kC9Ovd3LUlM,9
|
|
101
|
+
fnschool-20251013.81200.824.dist-info/RECORD,,
|
|
File without changes
|
{fnschool-20251012.81520.855.dist-info → fnschool-20251013.81200.824.dist-info}/entry_points.txt
RENAMED
|
File without changes
|
{fnschool-20251012.81520.855.dist-info → fnschool-20251013.81200.824.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|
{fnschool-20251012.81520.855.dist-info → fnschool-20251013.81200.824.dist-info}/top_level.txt
RENAMED
|
File without changes
|