Compare commits
No commits in common. "main" and "15" have entirely different histories.
2
.gitignore
vendored
|
@ -1,7 +1,7 @@
|
||||||
/data/*
|
/data/*
|
||||||
/data/logs/*
|
/data/logs/*
|
||||||
/data/tls/*
|
/data/tls/*
|
||||||
/data/django_static/*
|
/data/static/*
|
||||||
/data/profilepictures/*
|
/data/profilepictures/*
|
||||||
/data/archive/*
|
/data/archive/*
|
||||||
!/data/logs/
|
!/data/logs/
|
||||||
|
|
345
README.md
|
@ -1,4 +1,4 @@
|
||||||
# Drinks Manager
|
# Drinks Manager (Season 3)
|
||||||
|
|
||||||
Note: This software is tailored to my own needs.
|
Note: This software is tailored to my own needs.
|
||||||
I probably won't accept feature requests, and don't recommend you
|
I probably won't accept feature requests, and don't recommend you
|
||||||
|
@ -75,346 +75,3 @@ or
|
||||||
```
|
```
|
||||||
./start.sh --devel
|
./start.sh --devel
|
||||||
```
|
```
|
||||||
|
|
||||||
# Third-Party Licenses
|
|
||||||
|
|
||||||
This software contains third-party software and resources.
|
|
||||||
These are listed here with their respective licenses.
|
|
||||||
|
|
||||||
## Simple Keyboard
|
|
||||||
|
|
||||||
Source: https://github.com/hodgef/simple-keyboard
|
|
||||||
|
|
||||||
```
|
|
||||||
MIT License
|
|
||||||
|
|
||||||
Copyright (c) 2019 Francisco Hodge and project contributors.
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
|
||||||
copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
SOFTWARE.
|
|
||||||
```
|
|
||||||
|
|
||||||
## Inter (Font)
|
|
||||||
|
|
||||||
Source: https://github.com/rsms/inter/
|
|
||||||
|
|
||||||
```
|
|
||||||
Copyright (c) 2016 The Inter Project Authors (https://github.com/rsms/inter)
|
|
||||||
|
|
||||||
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
|
||||||
This license is copied below, and is also available with a FAQ at:
|
|
||||||
http://scripts.sil.org/OFL
|
|
||||||
|
|
||||||
-----------------------------------------------------------
|
|
||||||
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
|
||||||
-----------------------------------------------------------
|
|
||||||
|
|
||||||
PREAMBLE
|
|
||||||
The goals of the Open Font License (OFL) are to stimulate worldwide
|
|
||||||
development of collaborative font projects, to support the font creation
|
|
||||||
efforts of academic and linguistic communities, and to provide a free and
|
|
||||||
open framework in which fonts may be shared and improved in partnership
|
|
||||||
with others.
|
|
||||||
|
|
||||||
The OFL allows the licensed fonts to be used, studied, modified and
|
|
||||||
redistributed freely as long as they are not sold by themselves. The
|
|
||||||
fonts, including any derivative works, can be bundled, embedded,
|
|
||||||
redistributed and/or sold with any software provided that any reserved
|
|
||||||
names are not used by derivative works. The fonts and derivatives,
|
|
||||||
however, cannot be released under any other type of license. The
|
|
||||||
requirement for fonts to remain under this license does not apply
|
|
||||||
to any document created using the fonts or their derivatives.
|
|
||||||
|
|
||||||
DEFINITIONS
|
|
||||||
"Font Software" refers to the set of files released by the Copyright
|
|
||||||
Holder(s) under this license and clearly marked as such. This may
|
|
||||||
include source files, build scripts and documentation.
|
|
||||||
|
|
||||||
"Reserved Font Name" refers to any names specified as such after the
|
|
||||||
copyright statement(s).
|
|
||||||
|
|
||||||
"Original Version" refers to the collection of Font Software components as
|
|
||||||
distributed by the Copyright Holder(s).
|
|
||||||
|
|
||||||
"Modified Version" refers to any derivative made by adding to, deleting,
|
|
||||||
or substituting -- in part or in whole -- any of the components of the
|
|
||||||
Original Version, by changing formats or by porting the Font Software to a
|
|
||||||
new environment.
|
|
||||||
|
|
||||||
"Author" refers to any designer, engineer, programmer, technical
|
|
||||||
writer or other person who contributed to the Font Software.
|
|
||||||
|
|
||||||
PERMISSION AND CONDITIONS
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
|
||||||
redistribute, and sell modified and unmodified copies of the Font
|
|
||||||
Software, subject to the following conditions:
|
|
||||||
|
|
||||||
1) Neither the Font Software nor any of its individual components,
|
|
||||||
in Original or Modified Versions, may be sold by itself.
|
|
||||||
|
|
||||||
2) Original or Modified Versions of the Font Software may be bundled,
|
|
||||||
redistributed and/or sold with any software, provided that each copy
|
|
||||||
contains the above copyright notice and this license. These can be
|
|
||||||
included either as stand-alone text files, human-readable headers or
|
|
||||||
in the appropriate machine-readable metadata fields within text or
|
|
||||||
binary files as long as those fields can be easily viewed by the user.
|
|
||||||
|
|
||||||
3) No Modified Version of the Font Software may use the Reserved Font
|
|
||||||
Name(s) unless explicit written permission is granted by the corresponding
|
|
||||||
Copyright Holder. This restriction only applies to the primary font name as
|
|
||||||
presented to the users.
|
|
||||||
|
|
||||||
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
|
||||||
Software shall not be used to promote, endorse or advertise any
|
|
||||||
Modified Version, except to acknowledge the contribution(s) of the
|
|
||||||
Copyright Holder(s) and the Author(s) or with their explicit written
|
|
||||||
permission.
|
|
||||||
|
|
||||||
5) The Font Software, modified or unmodified, in part or in whole,
|
|
||||||
must be distributed entirely under this license, and must not be
|
|
||||||
distributed under any other license. The requirement for fonts to
|
|
||||||
remain under this license does not apply to any document created
|
|
||||||
using the Font Software.
|
|
||||||
|
|
||||||
TERMINATION
|
|
||||||
This license becomes null and void if any of the above conditions are
|
|
||||||
not met.
|
|
||||||
|
|
||||||
DISCLAIMER
|
|
||||||
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
|
||||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
|
||||||
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
|
||||||
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
||||||
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
|
||||||
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
||||||
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
|
||||||
OTHER DEALINGS IN THE FONT SOFTWARE.
|
|
||||||
```
|
|
||||||
|
|
||||||
## Material Design Icons
|
|
||||||
|
|
||||||
Source: https://github.com/google/material-design-icons
|
|
||||||
Files:
|
|
||||||
- `./app/static/material-icons/*`
|
|
||||||
- `./data/profilepictures/default.svg`
|
|
||||||
|
|
||||||
```
|
|
||||||
Apache License
|
|
||||||
Version 2.0, January 2004
|
|
||||||
http://www.apache.org/licenses/
|
|
||||||
|
|
||||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
||||||
|
|
||||||
1. Definitions.
|
|
||||||
|
|
||||||
"License" shall mean the terms and conditions for use, reproduction,
|
|
||||||
and distribution as defined by Sections 1 through 9 of this document.
|
|
||||||
|
|
||||||
"Licensor" shall mean the copyright owner or entity authorized by
|
|
||||||
the copyright owner that is granting the License.
|
|
||||||
|
|
||||||
"Legal Entity" shall mean the union of the acting entity and all
|
|
||||||
other entities that control, are controlled by, or are under common
|
|
||||||
control with that entity. For the purposes of this definition,
|
|
||||||
"control" means (i) the power, direct or indirect, to cause the
|
|
||||||
direction or management of such entity, whether by contract or
|
|
||||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
||||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
||||||
|
|
||||||
"You" (or "Your") shall mean an individual or Legal Entity
|
|
||||||
exercising permissions granted by this License.
|
|
||||||
|
|
||||||
"Source" form shall mean the preferred form for making modifications,
|
|
||||||
including but not limited to software source code, documentation
|
|
||||||
source, and configuration files.
|
|
||||||
|
|
||||||
"Object" form shall mean any form resulting from mechanical
|
|
||||||
transformation or translation of a Source form, including but
|
|
||||||
not limited to compiled object code, generated documentation,
|
|
||||||
and conversions to other media types.
|
|
||||||
|
|
||||||
"Work" shall mean the work of authorship, whether in Source or
|
|
||||||
Object form, made available under the License, as indicated by a
|
|
||||||
copyright notice that is included in or attached to the work
|
|
||||||
(an example is provided in the Appendix below).
|
|
||||||
|
|
||||||
"Derivative Works" shall mean any work, whether in Source or Object
|
|
||||||
form, that is based on (or derived from) the Work and for which the
|
|
||||||
editorial revisions, annotations, elaborations, or other modifications
|
|
||||||
represent, as a whole, an original work of authorship. For the purposes
|
|
||||||
of this License, Derivative Works shall not include works that remain
|
|
||||||
separable from, or merely link (or bind by name) to the interfaces of,
|
|
||||||
the Work and Derivative Works thereof.
|
|
||||||
|
|
||||||
"Contribution" shall mean any work of authorship, including
|
|
||||||
the original version of the Work and any modifications or additions
|
|
||||||
to that Work or Derivative Works thereof, that is intentionally
|
|
||||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
||||||
or by an individual or Legal Entity authorized to submit on behalf of
|
|
||||||
the copyright owner. For the purposes of this definition, "submitted"
|
|
||||||
means any form of electronic, verbal, or written communication sent
|
|
||||||
to the Licensor or its representatives, including but not limited to
|
|
||||||
communication on electronic mailing lists, source code control systems,
|
|
||||||
and issue tracking systems that are managed by, or on behalf of, the
|
|
||||||
Licensor for the purpose of discussing and improving the Work, but
|
|
||||||
excluding communication that is conspicuously marked or otherwise
|
|
||||||
designated in writing by the copyright owner as "Not a Contribution."
|
|
||||||
|
|
||||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
||||||
on behalf of whom a Contribution has been received by Licensor and
|
|
||||||
subsequently incorporated within the Work.
|
|
||||||
|
|
||||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
||||||
this License, each Contributor hereby grants to You a perpetual,
|
|
||||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
||||||
copyright license to reproduce, prepare Derivative Works of,
|
|
||||||
publicly display, publicly perform, sublicense, and distribute the
|
|
||||||
Work and such Derivative Works in Source or Object form.
|
|
||||||
|
|
||||||
3. Grant of Patent License. Subject to the terms and conditions of
|
|
||||||
this License, each Contributor hereby grants to You a perpetual,
|
|
||||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
||||||
(except as stated in this section) patent license to make, have made,
|
|
||||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
||||||
where such license applies only to those patent claims licensable
|
|
||||||
by such Contributor that are necessarily infringed by their
|
|
||||||
Contribution(s) alone or by combination of their Contribution(s)
|
|
||||||
with the Work to which such Contribution(s) was submitted. If You
|
|
||||||
institute patent litigation against any entity (including a
|
|
||||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
||||||
or a Contribution incorporated within the Work constitutes direct
|
|
||||||
or contributory patent infringement, then any patent licenses
|
|
||||||
granted to You under this License for that Work shall terminate
|
|
||||||
as of the date such litigation is filed.
|
|
||||||
|
|
||||||
4. Redistribution. You may reproduce and distribute copies of the
|
|
||||||
Work or Derivative Works thereof in any medium, with or without
|
|
||||||
modifications, and in Source or Object form, provided that You
|
|
||||||
meet the following conditions:
|
|
||||||
|
|
||||||
(a) You must give any other recipients of the Work or
|
|
||||||
Derivative Works a copy of this License; and
|
|
||||||
|
|
||||||
(b) You must cause any modified files to carry prominent notices
|
|
||||||
stating that You changed the files; and
|
|
||||||
|
|
||||||
(c) You must retain, in the Source form of any Derivative Works
|
|
||||||
that You distribute, all copyright, patent, trademark, and
|
|
||||||
attribution notices from the Source form of the Work,
|
|
||||||
excluding those notices that do not pertain to any part of
|
|
||||||
the Derivative Works; and
|
|
||||||
|
|
||||||
(d) If the Work includes a "NOTICE" text file as part of its
|
|
||||||
distribution, then any Derivative Works that You distribute must
|
|
||||||
include a readable copy of the attribution notices contained
|
|
||||||
within such NOTICE file, excluding those notices that do not
|
|
||||||
pertain to any part of the Derivative Works, in at least one
|
|
||||||
of the following places: within a NOTICE text file distributed
|
|
||||||
as part of the Derivative Works; within the Source form or
|
|
||||||
documentation, if provided along with the Derivative Works; or,
|
|
||||||
within a display generated by the Derivative Works, if and
|
|
||||||
wherever such third-party notices normally appear. The contents
|
|
||||||
of the NOTICE file are for informational purposes only and
|
|
||||||
do not modify the License. You may add Your own attribution
|
|
||||||
notices within Derivative Works that You distribute, alongside
|
|
||||||
or as an addendum to the NOTICE text from the Work, provided
|
|
||||||
that such additional attribution notices cannot be construed
|
|
||||||
as modifying the License.
|
|
||||||
|
|
||||||
You may add Your own copyright statement to Your modifications and
|
|
||||||
may provide additional or different license terms and conditions
|
|
||||||
for use, reproduction, or distribution of Your modifications, or
|
|
||||||
for any such Derivative Works as a whole, provided Your use,
|
|
||||||
reproduction, and distribution of the Work otherwise complies with
|
|
||||||
the conditions stated in this License.
|
|
||||||
|
|
||||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
||||||
any Contribution intentionally submitted for inclusion in the Work
|
|
||||||
by You to the Licensor shall be under the terms and conditions of
|
|
||||||
this License, without any additional terms or conditions.
|
|
||||||
Notwithstanding the above, nothing herein shall supersede or modify
|
|
||||||
the terms of any separate license agreement you may have executed
|
|
||||||
with Licensor regarding such Contributions.
|
|
||||||
|
|
||||||
6. Trademarks. This License does not grant permission to use the trade
|
|
||||||
names, trademarks, service marks, or product names of the Licensor,
|
|
||||||
except as required for reasonable and customary use in describing the
|
|
||||||
origin of the Work and reproducing the content of the NOTICE file.
|
|
||||||
|
|
||||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
||||||
agreed to in writing, Licensor provides the Work (and each
|
|
||||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
||||||
implied, including, without limitation, any warranties or conditions
|
|
||||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
||||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
||||||
appropriateness of using or redistributing the Work and assume any
|
|
||||||
risks associated with Your exercise of permissions under this License.
|
|
||||||
|
|
||||||
8. Limitation of Liability. In no event and under no legal theory,
|
|
||||||
whether in tort (including negligence), contract, or otherwise,
|
|
||||||
unless required by applicable law (such as deliberate and grossly
|
|
||||||
negligent acts) or agreed to in writing, shall any Contributor be
|
|
||||||
liable to You for damages, including any direct, indirect, special,
|
|
||||||
incidental, or consequential damages of any character arising as a
|
|
||||||
result of this License or out of the use or inability to use the
|
|
||||||
Work (including but not limited to damages for loss of goodwill,
|
|
||||||
work stoppage, computer failure or malfunction, or any and all
|
|
||||||
other commercial damages or losses), even if such Contributor
|
|
||||||
has been advised of the possibility of such damages.
|
|
||||||
|
|
||||||
9. Accepting Warranty or Additional Liability. While redistributing
|
|
||||||
the Work or Derivative Works thereof, You may choose to offer,
|
|
||||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
||||||
or other liability obligations and/or rights consistent with this
|
|
||||||
License. However, in accepting such obligations, You may act only
|
|
||||||
on Your own behalf and on Your sole responsibility, not on behalf
|
|
||||||
of any other Contributor, and only if You agree to indemnify,
|
|
||||||
defend, and hold each Contributor harmless for any liability
|
|
||||||
incurred by, or claims asserted against, such Contributor by reason
|
|
||||||
of your accepting any such warranty or additional liability.
|
|
||||||
|
|
||||||
END OF TERMS AND CONDITIONS
|
|
||||||
|
|
||||||
APPENDIX: How to apply the Apache License to your work.
|
|
||||||
|
|
||||||
To apply the Apache License to your work, attach the following
|
|
||||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
||||||
replaced with your own identifying information. (Don't include
|
|
||||||
the brackets!) The text should be enclosed in the appropriate
|
|
||||||
comment syntax for the file format. We also recommend that a
|
|
||||||
file or class name and description of purpose be included on the
|
|
||||||
same "printed page" as the copyright notice for easier
|
|
||||||
identification within third-party archives.
|
|
||||||
|
|
||||||
Copyright [yyyy] [name of copyright owner]
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
```
|
|
||||||
|
|
14
app/admin.py
|
@ -43,24 +43,20 @@ class CustomUserAdmin(UserAdmin):
|
||||||
|
|
||||||
fieldsets_ = list((*UserAdmin.fieldsets,))
|
fieldsets_ = list((*UserAdmin.fieldsets,))
|
||||||
fieldsets_.insert(1, (
|
fieldsets_.insert(1, (
|
||||||
"Visibility",
|
|
||||||
{"fields": ("hide_from_userlist",)},
|
|
||||||
))
|
|
||||||
fieldsets_.insert(2, (
|
|
||||||
"Balance",
|
"Balance",
|
||||||
{"fields": ("balance", "allow_order_with_negative_balance")},
|
{"fields": ("balance", "allow_order_with_negative_balance")},
|
||||||
))
|
))
|
||||||
fieldsets_.insert(3, (
|
fieldsets_.insert(2, (
|
||||||
"Supply",
|
"Supply",
|
||||||
{"fields": ("allowed_to_supply",)},
|
{"fields": ("allowed_to_supply",)},
|
||||||
))
|
))
|
||||||
fieldsets_.insert(4, (
|
fieldsets_.insert(3, (
|
||||||
"Profile Picture",
|
"Profile Picture",
|
||||||
{"fields": ("profile_picture_filename",)},
|
{"fields": ("profile_picture_filename",)},
|
||||||
))
|
))
|
||||||
fieldsets = tuple(fieldsets_)
|
fieldsets = tuple(fieldsets_)
|
||||||
|
|
||||||
list_display = ["username", "balance", "allow_order_with_negative_balance", "is_active", "hide_from_userlist"]
|
list_display = ["username", "balance", "is_active", "allow_order_with_negative_balance"]
|
||||||
|
|
||||||
def get_actions(self, request): # remove the "delete_selected" action because it breaks some functionality
|
def get_actions(self, request): # remove the "delete_selected" action because it breaks some functionality
|
||||||
actions = super().get_actions(request)
|
actions = super().get_actions(request)
|
||||||
|
@ -95,7 +91,9 @@ class CustomRegisterAdmin(admin.ModelAdmin):
|
||||||
return actions
|
return actions
|
||||||
|
|
||||||
def delete_selected_new(self, request, queryset):
|
def delete_selected_new(self, request, queryset):
|
||||||
|
#print(queryset)
|
||||||
for supply in queryset:
|
for supply in queryset:
|
||||||
|
#print(order)
|
||||||
supply.delete()
|
supply.delete()
|
||||||
if queryset.count() < 2:
|
if queryset.count() < 2:
|
||||||
self.message_user(request, f"Revoked {queryset.count()} supply.")
|
self.message_user(request, f"Revoked {queryset.count()} supply.")
|
||||||
|
@ -119,7 +117,9 @@ class CustomOrderAdmin(admin.ModelAdmin):
|
||||||
return actions
|
return actions
|
||||||
|
|
||||||
def delete_selected_new(self, request, queryset):
|
def delete_selected_new(self, request, queryset):
|
||||||
|
#print(queryset)
|
||||||
for order in queryset:
|
for order in queryset:
|
||||||
|
#print(order)
|
||||||
order.delete()
|
order.delete()
|
||||||
self.message_user(request, f"Revoked {queryset.count()} order(s).")
|
self.message_user(request, f"Revoked {queryset.count()} order(s).")
|
||||||
delete_selected_new.short_description = "Revoke selected orders"
|
delete_selected_new.short_description = "Revoke selected orders"
|
||||||
|
|
|
@ -2,8 +2,6 @@
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.db import connection
|
from django.db import connection
|
||||||
from django.utils.translation import gettext
|
|
||||||
from calendar import day_name
|
|
||||||
|
|
||||||
|
|
||||||
COMBINE_ALPHABET = "abcdefghijklmnopqrstuvwxyz"
|
COMBINE_ALPHABET = "abcdefghijklmnopqrstuvwxyz"
|
||||||
|
@ -16,6 +14,7 @@ def _db_select(sql_select:str):
|
||||||
result = cursor.fetchall()
|
result = cursor.fetchall()
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
def _combine_results(results:list) -> dict:
|
def _combine_results(results:list) -> dict:
|
||||||
'''
|
'''
|
||||||
e.g.
|
e.g.
|
||||||
|
@ -45,13 +44,10 @@ def select_history(user, language_code="en") -> list:
|
||||||
user_id = user.pk
|
user_id = user.pk
|
||||||
result = _db_select(f"""
|
result = _db_select(f"""
|
||||||
select
|
select
|
||||||
price_sum as "sum",
|
|
||||||
concat(
|
concat(
|
||||||
product_name,
|
product_name, ' (',
|
||||||
' (',
|
|
||||||
content_litres::real, -- converting to real removes trailing zeros
|
content_litres::real, -- converting to real removes trailing zeros
|
||||||
'l) x ', amount
|
'l) x ', amount, ' - ', price_sum, '{settings.CURRENCY_SUFFIX}') as "text",
|
||||||
) as "text",
|
|
||||||
datetime
|
datetime
|
||||||
from app_order
|
from app_order
|
||||||
where user_id = {user_id}
|
where user_id = {user_id}
|
||||||
|
@ -59,28 +55,22 @@ def select_history(user, language_code="en") -> list:
|
||||||
union
|
union
|
||||||
|
|
||||||
select
|
select
|
||||||
transaction_sum as "sum",
|
concat('Deposit: +', transaction_sum, '{settings.CURRENCY_SUFFIX}') as "text",
|
||||||
'{gettext("Deposit")}' as "text",
|
|
||||||
datetime
|
datetime
|
||||||
from app_userdeposits_view
|
from app_userdeposits_view
|
||||||
where user_id = {user_id}
|
where user_id = {user_id}
|
||||||
|
|
||||||
union
|
|
||||||
|
|
||||||
select
|
|
||||||
transaction_sum as "sum",
|
|
||||||
comment as "text",
|
|
||||||
datetime
|
|
||||||
from app_registertransaction
|
|
||||||
where user_id = {user_id} and is_transfer = true
|
|
||||||
|
|
||||||
order by datetime desc
|
order by datetime desc
|
||||||
fetch first 30 rows only;
|
fetch first 30 rows only;
|
||||||
""")
|
""")
|
||||||
result = [list(row) for row in result]
|
result = [list(row) for row in result]
|
||||||
|
if language_code == "de": # reformat for german translation
|
||||||
|
for row in result:
|
||||||
|
row[0] = row[0].replace(".", ",")
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def select_orders_per_month(user) -> dict:
|
|
||||||
|
def orders_per_month(user) -> list:
|
||||||
# number of orders per month (last 12 months)
|
# number of orders per month (last 12 months)
|
||||||
result_user = _db_select(f"""
|
result_user = _db_select(f"""
|
||||||
select
|
select
|
||||||
|
@ -101,35 +91,32 @@ def select_orders_per_month(user) -> dict:
|
||||||
group by "month"
|
group by "month"
|
||||||
order by "month" desc;
|
order by "month" desc;
|
||||||
""")
|
""")
|
||||||
return _combine_results([result_all, result_user])
|
return _combine_results([result_user, result_all])
|
||||||
|
|
||||||
def select_orders_per_weekday(user) -> list:
|
|
||||||
|
def orders_per_weekday(user) -> list:
|
||||||
# number of orders per weekday (all time)
|
# number of orders per weekday (all time)
|
||||||
result = _db_select(f"""
|
result_user = _db_select(f"""
|
||||||
with q_all as (
|
|
||||||
select
|
select
|
||||||
extract(isodow from datetime) as "d",
|
to_char(datetime, 'Day') as "day",
|
||||||
sum(amount) as "c"
|
sum(amount) as "count"
|
||||||
from app_order
|
|
||||||
group by d
|
|
||||||
), q_user as (
|
|
||||||
select
|
|
||||||
extract(isodow from datetime) as "d",
|
|
||||||
sum(amount) as "c"
|
|
||||||
from app_order
|
from app_order
|
||||||
where user_id = {user.pk}
|
where user_id = {user.pk}
|
||||||
group by d
|
group by "day"
|
||||||
)
|
order by "count" desc;
|
||||||
select q_all.d as "day", q_all.c, q_user.c from q_all full join q_user on q_all.d = q_user.d
|
|
||||||
group by day, q_all.c, q_user.c
|
|
||||||
order by day asc;
|
|
||||||
""")
|
""")
|
||||||
for i in range(len(result)):
|
result_all = _db_select(f"""
|
||||||
day_, all_, user_ = result[i]
|
select
|
||||||
result[i] = (day_name[int(day_)-1], all_, user_)
|
to_char(datetime, 'Day') as "day",
|
||||||
return result
|
sum(amount) as "count"
|
||||||
|
from app_order
|
||||||
|
group by "day"
|
||||||
|
order by "count" desc;
|
||||||
|
""")
|
||||||
|
return _combine_results([result_user, result_all])
|
||||||
|
|
||||||
def select_orders_per_drink(user) -> dict:
|
|
||||||
|
def orders_per_drink(user) -> list:
|
||||||
# number of orders per drink (all time)
|
# number of orders per drink (all time)
|
||||||
result_user = _db_select(f"""
|
result_user = _db_select(f"""
|
||||||
select
|
select
|
||||||
|
@ -150,31 +137,4 @@ def select_orders_per_drink(user) -> dict:
|
||||||
group by d.product_name
|
group by d.product_name
|
||||||
order by "data" desc;
|
order by "data" desc;
|
||||||
""")
|
""")
|
||||||
return _combine_results([result_all, result_user])
|
return _combine_results([result_user, result_all])
|
||||||
|
|
||||||
def select_order_sum_per_user_all_users() -> list:
|
|
||||||
# sum of all orders per user, for all users
|
|
||||||
result = _db_select(f"""
|
|
||||||
select
|
|
||||||
app_user.username as user,
|
|
||||||
sum(app_order.price_sum) as sum
|
|
||||||
from app_user
|
|
||||||
left outer join app_order on (app_user.id = app_order.user_id)
|
|
||||||
group by app_user.id
|
|
||||||
order by app_user asc;
|
|
||||||
""")
|
|
||||||
return result
|
|
||||||
|
|
||||||
def select_deposit_sum_per_user_all_users() -> list:
|
|
||||||
# sum of all orders per user, for all users
|
|
||||||
result = _db_select(f"""
|
|
||||||
select
|
|
||||||
app_user.username as user,
|
|
||||||
sum(rt.transaction_sum) as sum
|
|
||||||
from app_user
|
|
||||||
left outer join app_registertransaction rt on (app_user.id = rt.user_id)
|
|
||||||
where rt.is_user_deposit is true or rt.is_user_deposit is null
|
|
||||||
group by app_user.id
|
|
||||||
order by app_user asc;
|
|
||||||
""")
|
|
||||||
return result
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: PACKAGE VERSION\n"
|
"Project-Id-Version: PACKAGE VERSION\n"
|
||||||
"Report-Msgid-Bugs-To: \n"
|
"Report-Msgid-Bugs-To: \n"
|
||||||
"POT-Creation-Date: 2023-11-01 19:29+0100\n"
|
"POT-Creation-Date: 2023-02-17 22:11+0100\n"
|
||||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||||
"Last-Translator: Julian MĂĽller (ChaoticByte)\n"
|
"Last-Translator: Julian MĂĽller (ChaoticByte)\n"
|
||||||
"Language: DE\n"
|
"Language: DE\n"
|
||||||
|
@ -33,21 +33,20 @@ msgstr "Ein Fehler ist aufgetreten. Bitte ab- und wieder anmelden."
|
||||||
msgid "Drinks - Deposit"
|
msgid "Drinks - Deposit"
|
||||||
msgstr "Getränke - Einzahlen"
|
msgstr "Getränke - Einzahlen"
|
||||||
|
|
||||||
#: app/templates/deposit.html:17 app/templates/userpanel.html:18
|
#: app/templates/deposit.html:17 app/templates/userpanel.html:23
|
||||||
msgid "Deposit"
|
msgid "Deposit"
|
||||||
msgstr "Einzahlen"
|
msgstr "Einzahlen"
|
||||||
|
|
||||||
#: app/templates/deposit.html:19 app/templates/transfer.html:43
|
#: app/templates/deposit.html:19
|
||||||
msgid "Amount"
|
msgid "Amount"
|
||||||
msgstr "Summe"
|
msgstr "Summe"
|
||||||
|
|
||||||
#: app/templates/deposit.html:30 app/templates/order.html:54
|
#: app/templates/deposit.html:30 app/templates/order.html:54
|
||||||
#: app/templates/registration/login.html:28 app/templates/supply.html:29
|
#: app/templates/registration/login.html:28 app/templates/supply.html:29
|
||||||
#: app/templates/transfer.html:54
|
|
||||||
msgid "cancel"
|
msgid "cancel"
|
||||||
msgstr "Abbrechen"
|
msgstr "Abbrechen"
|
||||||
|
|
||||||
#: app/templates/deposit.html:31 app/templates/transfer.html:55
|
#: app/templates/deposit.html:31
|
||||||
msgid "confirm"
|
msgid "confirm"
|
||||||
msgstr "Bestätigen"
|
msgstr "Bestätigen"
|
||||||
|
|
||||||
|
@ -55,7 +54,7 @@ msgstr "Bestätigen"
|
||||||
msgid "Drinks - History"
|
msgid "Drinks - History"
|
||||||
msgstr "Getränke - Verlauf"
|
msgstr "Getränke - Verlauf"
|
||||||
|
|
||||||
#: app/templates/history.html:10 app/templates/userpanel.html:23
|
#: app/templates/history.html:10 app/templates/userpanel.html:30
|
||||||
msgid "History"
|
msgid "History"
|
||||||
msgstr "Verlauf"
|
msgstr "Verlauf"
|
||||||
|
|
||||||
|
@ -165,65 +164,49 @@ msgstr "Wähle deinen Account"
|
||||||
msgid "Drinks - Statistics"
|
msgid "Drinks - Statistics"
|
||||||
msgstr "Getränke - Statistiken"
|
msgstr "Getränke - Statistiken"
|
||||||
|
|
||||||
#: app/templates/statistics.html:10 app/templates/userpanel.html:24
|
#: app/templates/statistics.html:10 app/templates/userpanel.html:31
|
||||||
msgid "Statistics"
|
msgid "Statistics"
|
||||||
msgstr "Statistiken"
|
msgstr "Statistiken"
|
||||||
|
|
||||||
#: app/templates/statistics.html:13
|
#: app/templates/statistics.html:13
|
||||||
msgid "orders / drink"
|
msgid "Orders per drink"
|
||||||
msgstr "Bestellungen / Getränk"
|
msgstr "Bestellungen pro Getränk"
|
||||||
|
|
||||||
#: app/templates/statistics.html:16
|
#: app/templates/statistics.html:16
|
||||||
msgid "drink"
|
msgid "drink"
|
||||||
msgstr "Getränk"
|
msgstr "Getränk"
|
||||||
|
|
||||||
#: app/templates/statistics.html:17 app/templates/statistics.html:36
|
#: app/templates/statistics.html:17 app/templates/statistics.html:34
|
||||||
#: app/templates/statistics.html:53
|
#: app/templates/statistics.html:51
|
||||||
msgid "all"
|
|
||||||
msgstr "Alle"
|
|
||||||
|
|
||||||
#: app/templates/statistics.html:18 app/templates/statistics.html:37
|
|
||||||
#: app/templates/statistics.html:54
|
|
||||||
msgid "you"
|
msgid "you"
|
||||||
msgstr "Du"
|
msgstr "Du"
|
||||||
|
|
||||||
#: app/templates/statistics.html:32
|
#: app/templates/statistics.html:18 app/templates/statistics.html:35
|
||||||
msgid "orders / month"
|
#: app/templates/statistics.html:52
|
||||||
msgstr "Bestellungen / Monat"
|
msgid "all"
|
||||||
|
msgstr "Alle"
|
||||||
|
|
||||||
#: app/templates/statistics.html:35
|
#: app/templates/statistics.html:30
|
||||||
|
msgid "Orders per month (last 12 months)"
|
||||||
|
msgstr "Bestellungen pro Monat (letzte 12 Monate)"
|
||||||
|
|
||||||
|
#: app/templates/statistics.html:33
|
||||||
msgid "month"
|
msgid "month"
|
||||||
msgstr "Monat"
|
msgstr "Monat"
|
||||||
|
|
||||||
#: app/templates/statistics.html:49
|
#: app/templates/statistics.html:47
|
||||||
msgid "orders / weekday"
|
msgid "Orders per weekday"
|
||||||
msgstr "Bestellungen / Wochentag"
|
msgstr "Bestellungen pro Wochentag"
|
||||||
|
|
||||||
#: app/templates/statistics.html:52
|
#: app/templates/statistics.html:50
|
||||||
msgid "day"
|
msgid "day"
|
||||||
msgstr "Tag"
|
msgstr "Tag"
|
||||||
|
|
||||||
#: app/templates/statistics.html:69
|
|
||||||
msgid "order sum"
|
|
||||||
msgstr "Bestellungen"
|
|
||||||
|
|
||||||
#: app/templates/statistics.html:72 app/templates/statistics.html:89
|
|
||||||
msgid "user"
|
|
||||||
msgstr "Benutzer"
|
|
||||||
|
|
||||||
#: app/templates/statistics.html:73 app/templates/statistics.html:90
|
|
||||||
msgid "sum"
|
|
||||||
msgstr "Summe"
|
|
||||||
|
|
||||||
#: app/templates/statistics.html:86
|
|
||||||
msgid "deposit sum"
|
|
||||||
msgstr "Einzahlungen"
|
|
||||||
|
|
||||||
#: app/templates/supply.html:7
|
#: app/templates/supply.html:7
|
||||||
msgid "Drinks - Supply"
|
msgid "Drinks - Supply"
|
||||||
msgstr "Getränke - Beschaffung"
|
msgstr "Getränke - Beschaffung"
|
||||||
|
|
||||||
#: app/templates/supply.html:14 app/templates/userpanel.html:30
|
#: app/templates/supply.html:14 app/templates/userpanel.html:36
|
||||||
msgid "Supply"
|
msgid "Supply"
|
||||||
msgstr "Beschaffung"
|
msgstr "Beschaffung"
|
||||||
|
|
||||||
|
@ -243,31 +226,23 @@ msgstr "Senden"
|
||||||
msgid "You are not allowed to view this site."
|
msgid "You are not allowed to view this site."
|
||||||
msgstr "Dir fehlt die Berechtigung, diese Seite anzuzeigen."
|
msgstr "Dir fehlt die Berechtigung, diese Seite anzuzeigen."
|
||||||
|
|
||||||
#: app/templates/transfer.html:6
|
#: app/templates/userpanel.html:9 app/templates/userpanel.html:11
|
||||||
msgid "Drinks - Transfer"
|
msgid "User"
|
||||||
msgstr "Getränke - Geld senden"
|
msgstr "Benutzer"
|
||||||
|
|
||||||
#: app/templates/transfer.html:17
|
#: app/templates/userpanel.html:15 app/templates/userpanel.html:17
|
||||||
msgid "Transfer Money"
|
|
||||||
msgstr "Geld senden"
|
|
||||||
|
|
||||||
#: app/templates/transfer.html:19
|
|
||||||
msgid "Recipient"
|
|
||||||
msgstr "Empfänger"
|
|
||||||
|
|
||||||
#: app/templates/userpanel.html:10 app/templates/userpanel.html:12
|
|
||||||
msgid "Balance"
|
msgid "Balance"
|
||||||
msgstr "Saldo"
|
msgstr "Saldo"
|
||||||
|
|
||||||
#: app/templates/userpanel.html:19
|
#: app/templates/userpanel.html:24
|
||||||
msgid "Logout"
|
msgid "Logout"
|
||||||
msgstr "Abmelden"
|
msgstr "Abmelden"
|
||||||
|
|
||||||
#: app/templates/userpanel.html:28
|
#: app/templates/userpanel.html:27
|
||||||
msgid "Transfer"
|
msgid "Account"
|
||||||
msgstr "Geld senden"
|
msgstr "Account"
|
||||||
|
|
||||||
#: app/templates/userpanel.html:32
|
#: app/templates/userpanel.html:38
|
||||||
msgid "Change Password"
|
msgid "Change Password"
|
||||||
msgstr "Passwort ändern"
|
msgstr "Passwort ändern"
|
||||||
|
|
||||||
|
|
|
@ -1,17 +0,0 @@
|
||||||
# Generated by Django 4.1.6 on 2023-04-13 19:12
|
|
||||||
|
|
||||||
from django.db import migrations, models
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
dependencies = [
|
|
||||||
("app", "0002_setup"),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.AddField(
|
|
||||||
model_name="user",
|
|
||||||
name="hide_from_userlist",
|
|
||||||
field=models.BooleanField(default=False),
|
|
||||||
),
|
|
||||||
]
|
|
|
@ -1,17 +0,0 @@
|
||||||
# Generated by Django 4.1.6 on 2023-04-14 20:01
|
|
||||||
|
|
||||||
from django.db import migrations, models
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
dependencies = [
|
|
||||||
("app", "0003_user_hide_from_userlist"),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.AddField(
|
|
||||||
model_name="registertransaction",
|
|
||||||
name="is_transfer",
|
|
||||||
field=models.BooleanField(default=False),
|
|
||||||
),
|
|
||||||
]
|
|
|
@ -13,7 +13,6 @@ class User(AbstractUser):
|
||||||
allow_order_with_negative_balance = models.BooleanField(default=False)
|
allow_order_with_negative_balance = models.BooleanField(default=False)
|
||||||
profile_picture_filename = models.CharField(default="default.svg", max_length=25)
|
profile_picture_filename = models.CharField(default="default.svg", max_length=25)
|
||||||
allowed_to_supply = models.BooleanField(default=False)
|
allowed_to_supply = models.BooleanField(default=False)
|
||||||
hide_from_userlist = models.BooleanField(default=False)
|
|
||||||
|
|
||||||
def delete(self, *args, **kwargs):
|
def delete(self, *args, **kwargs):
|
||||||
self.balance = 0
|
self.balance = 0
|
||||||
|
@ -40,12 +39,11 @@ class Drink(models.Model):
|
||||||
do_not_count = models.BooleanField(default=False)
|
do_not_count = models.BooleanField(default=False)
|
||||||
|
|
||||||
def delete(self, *args, **kwargs):
|
def delete(self, *args, **kwargs):
|
||||||
# we flag the field as deleted.
|
|
||||||
self.deleted = True
|
self.deleted = True
|
||||||
super().save()
|
super().save()
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return f"{self.product_name} ({float(self.content_litres):.2f}l) - {self.price} {settings.CURRENCY_SUFFIX}"
|
return f"{self.product_name} ({float(self.content_litres):.2f}l) - {self.price}{settings.CURRENCY_SUFFIX}"
|
||||||
|
|
||||||
|
|
||||||
class RegisterTransaction(models.Model):
|
class RegisterTransaction(models.Model):
|
||||||
|
@ -60,34 +58,35 @@ class RegisterTransaction(models.Model):
|
||||||
old_transaction_sum = models.DecimalField(max_digits=6, decimal_places=2, default=0.00)
|
old_transaction_sum = models.DecimalField(max_digits=6, decimal_places=2, default=0.00)
|
||||||
datetime = models.DateTimeField(default=timezone.now)
|
datetime = models.DateTimeField(default=timezone.now)
|
||||||
is_user_deposit = models.BooleanField(default=False)
|
is_user_deposit = models.BooleanField(default=False)
|
||||||
is_transfer = models.BooleanField(default=False)
|
|
||||||
comment = models.TextField(default=" ")
|
comment = models.TextField(default=" ")
|
||||||
user = models.ForeignKey(User, on_delete=models.CASCADE)
|
user = models.ForeignKey(User, on_delete=models.CASCADE)
|
||||||
|
|
||||||
def save(self, *args, **kwargs):
|
def save(self, *args, **kwargs):
|
||||||
if self._state.adding:
|
if self._state.adding:
|
||||||
if self.is_user_deposit or self.is_transfer: # update user balance
|
if self.is_user_deposit == True: # update user balance
|
||||||
self.user.balance += self.transaction_sum
|
self.user.balance += self.transaction_sum
|
||||||
self.user.save()
|
self.user.save()
|
||||||
self.old_transaction_sum = self.transaction_sum
|
self.old_transaction_sum = self.transaction_sum
|
||||||
super().save(*args, **kwargs)
|
super().save(*args, **kwargs)
|
||||||
else:
|
else:
|
||||||
# update user balance
|
|
||||||
if self.is_user_deposit or self.is_transfer:
|
|
||||||
self.user.balance += self.transaction_sum - self.old_transaction_sum
|
|
||||||
self.user.save()
|
|
||||||
# update register transaction
|
# update register transaction
|
||||||
|
sum_diff = self.transaction_sum - self.old_transaction_sum
|
||||||
|
# update user balance
|
||||||
|
if self.is_user_deposit == True:
|
||||||
|
ub_sum_diff = self.transaction_sum - self.old_transaction_sum
|
||||||
|
self.user.balance += ub_sum_diff
|
||||||
|
self.user.save()
|
||||||
self.old_transaction_sum = self.transaction_sum
|
self.old_transaction_sum = self.transaction_sum
|
||||||
super().save(*args, **kwargs)
|
super().save(*args, **kwargs)
|
||||||
|
|
||||||
def delete(self, *args, **kwargs):
|
def delete(self, *args, **kwargs):
|
||||||
# update user deposit
|
# update user deposit
|
||||||
if self.is_user_deposit or self.is_transfer:
|
if self.is_user_deposit:
|
||||||
self.user.balance -= self.transaction_sum
|
self.user.balance -= self.transaction_sum
|
||||||
self.user.save()
|
self.user.save()
|
||||||
super().delete(*args, kwargs)
|
super().delete(*args, kwargs)
|
||||||
|
|
||||||
def __str__(self): return f"{self.transaction_sum} {settings.CURRENCY_SUFFIX} by {self.user}"
|
def __str__(self): return f"{self.transaction_sum}{settings.CURRENCY_SUFFIX} by {self.user}"
|
||||||
|
|
||||||
|
|
||||||
class Order(models.Model):
|
class Order(models.Model):
|
||||||
|
@ -108,9 +107,10 @@ class Order(models.Model):
|
||||||
price_sum = models.DecimalField(max_digits=6, decimal_places=2, default=0, editable=False)
|
price_sum = models.DecimalField(max_digits=6, decimal_places=2, default=0, editable=False)
|
||||||
content_litres = models.DecimalField(max_digits=6, decimal_places=3, default=0, editable=False)
|
content_litres = models.DecimalField(max_digits=6, decimal_places=3, default=0, editable=False)
|
||||||
|
|
||||||
|
# TODO: Add more comments on how and why the save & delete functions are implemented
|
||||||
|
# address this in a refactoring issue.
|
||||||
|
|
||||||
def save(self, *args, **kwargs):
|
def save(self, *args, **kwargs):
|
||||||
# saving this may affect other fields
|
|
||||||
# so we reimplement the save function
|
|
||||||
drink = Drink.objects.get(pk=self.drink.pk)
|
drink = Drink.objects.get(pk=self.drink.pk)
|
||||||
if self._state.adding and drink.available > 0:
|
if self._state.adding and drink.available > 0:
|
||||||
if not drink.do_not_count:
|
if not drink.do_not_count:
|
||||||
|
@ -126,7 +126,6 @@ class Order(models.Model):
|
||||||
raise ValidationError("This entry can't be changed.")
|
raise ValidationError("This entry can't be changed.")
|
||||||
|
|
||||||
def delete(self, *args, **kwargs):
|
def delete(self, *args, **kwargs):
|
||||||
# when deleting, we affect other fields as well.
|
|
||||||
self.user.balance += self.price_sum
|
self.user.balance += self.price_sum
|
||||||
self.user.save()
|
self.user.save()
|
||||||
drink = Drink.objects.get(pk=self.drink.pk)
|
drink = Drink.objects.get(pk=self.drink.pk)
|
||||||
|
@ -135,7 +134,7 @@ class Order(models.Model):
|
||||||
drink.save()
|
drink.save()
|
||||||
super().delete(*args, **kwargs)
|
super().delete(*args, **kwargs)
|
||||||
|
|
||||||
def __str__(self): return f"{self.drink.product_name} ({float(self.drink.content_litres):.2f}l) x {self.amount} - {self.price_sum} {settings.CURRENCY_SUFFIX}"
|
def __str__(self): return f"{self.drink.product_name} ({float(self.drink.content_litres):.2f}l) x {self.amount} - {self.price_sum}{settings.CURRENCY_SUFFIX}"
|
||||||
|
|
||||||
|
|
||||||
class Global(models.Model):
|
class Global(models.Model):
|
||||||
|
|
|
@ -1,56 +1,28 @@
|
||||||
/* Fonts */
|
|
||||||
|
|
||||||
@font-face {
|
|
||||||
font-family: "Inter";
|
|
||||||
src: url('/static/fonts/Inter-Regular.ttf');
|
|
||||||
font-weight: normal;
|
|
||||||
font-style: normal;
|
|
||||||
}
|
|
||||||
@font-face {
|
|
||||||
font-family: "Inter";
|
|
||||||
src: url('/static/fonts/Inter-Bold.ttf');
|
|
||||||
font-weight: bold;
|
|
||||||
font-style: normal;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Variables */
|
/* Variables */
|
||||||
|
|
||||||
:root {
|
:root {
|
||||||
--font-family: "Inter";
|
--font-family: 'Liberation Sans', sans-serif;
|
||||||
--color: #fafafa;
|
--color: #fafafa;
|
||||||
--color-disabled: #ffffff50;
|
--color-error: #ff682c;
|
||||||
--color-error: #ff817c;
|
--bg-page-color: #222222;
|
||||||
--bg-page: linear-gradient(
|
--bg-color: #4e4e4e;
|
||||||
-10deg,
|
--bg-hover-color: #636363;
|
||||||
#071c29 10%,
|
--bg-color2: #383838;
|
||||||
#4a8897
|
--bg-hover-color2: #4a4a4a;
|
||||||
);
|
--border-color: #808080;
|
||||||
--bg-color: #ffffff35;
|
|
||||||
--bg-color2: #ffffff25;
|
|
||||||
--bg-hover-color: #ffffff50;
|
|
||||||
--border-color: #ffffff50;
|
|
||||||
--bg-globalmessage: #161616;
|
--bg-globalmessage: #161616;
|
||||||
--border-radius: .6rem;
|
--border-radius: .5rem;
|
||||||
--element-padding: .6rem .8rem;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* General */
|
/* General */
|
||||||
|
|
||||||
body,
|
|
||||||
input,
|
|
||||||
select,
|
|
||||||
button, .button
|
|
||||||
{
|
|
||||||
font-family: var(--font-family);
|
|
||||||
}
|
|
||||||
|
|
||||||
body {
|
body {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
width: 100vw;
|
width: 100vw;
|
||||||
min-height: 100vh;
|
min-height: 100vh;
|
||||||
font-size: 17px;
|
font-family: var(--font-family);
|
||||||
background: var(--bg-page);
|
background: var(--bg-page-color);
|
||||||
color: var(--color);
|
color: var(--color);
|
||||||
overflow-x: hidden;
|
overflow-x: hidden;
|
||||||
}
|
}
|
||||||
|
@ -60,7 +32,7 @@ a {
|
||||||
}
|
}
|
||||||
|
|
||||||
h1 {
|
h1 {
|
||||||
font-size: 28px;
|
font-size: 1.8rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
h1, h2, h3, h4 {
|
h1, h2, h3, h4 {
|
||||||
|
@ -78,38 +50,18 @@ input[type="number"]::-webkit-inner-spin-button {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
input[type="text"],
|
input[type="text"], input[type="password"], input[type="number"] {
|
||||||
input[type="password"],
|
padding: .6rem .8rem;
|
||||||
input[type="number"],
|
text-align: center;
|
||||||
select {
|
font-size: 1rem;
|
||||||
padding: var(--element-padding);
|
|
||||||
text-align: center !important;
|
|
||||||
font-size: 16px;
|
|
||||||
color: var(--color);
|
color: var(--color);
|
||||||
border: none;
|
border: none;
|
||||||
outline: none;
|
outline: none;
|
||||||
border: 1px solid var(--border-color);
|
border-bottom: 1px solid var(--border-color);
|
||||||
border-radius: var(--border-radius);
|
border-radius: var(--border-radius);
|
||||||
background: var(--bg-color);
|
background: var(--bg-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
input[type="text"]::placeholder,
|
|
||||||
input[type="password"]::placeholder,
|
|
||||||
input[type="number"]::placeholder,
|
|
||||||
select > option:disabled {
|
|
||||||
color: var(--color-disabled);
|
|
||||||
}
|
|
||||||
|
|
||||||
select {
|
|
||||||
appearance: none;
|
|
||||||
-webkit-appearance: none;
|
|
||||||
-moz-appearance: none;
|
|
||||||
background-image: url("/static/material-icons/arrow-drop-down.svg");
|
|
||||||
background-repeat: no-repeat;
|
|
||||||
background-position: right;
|
|
||||||
background-size: 1.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
table {
|
table {
|
||||||
border-collapse: collapse;
|
border-collapse: collapse;
|
||||||
border-spacing: 0;
|
border-spacing: 0;
|
||||||
|
@ -117,15 +69,20 @@ table {
|
||||||
border-radius: var(--border-radius);
|
border-radius: var(--border-radius);
|
||||||
}
|
}
|
||||||
|
|
||||||
tr > th,
|
tr {
|
||||||
tr > td {
|
|
||||||
background: var(--bg-color);
|
background: var(--bg-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
tr:nth-child(2n+2) > td {
|
tr:nth-child(2n+2) {
|
||||||
background: var(--bg-color2);
|
background: var(--bg-color2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Rounded corners on table cells apparently don't work with
|
||||||
|
Firefox, so Firefox users won't have rounded corners
|
||||||
|
on tables. Can't fix that by myself.
|
||||||
|
*/
|
||||||
|
|
||||||
table tr:first-child th:first-child {
|
table tr:first-child th:first-child {
|
||||||
border-top-left-radius: var(--border-radius);
|
border-top-left-radius: var(--border-radius);
|
||||||
}
|
}
|
||||||
|
@ -170,6 +127,7 @@ th {
|
||||||
|
|
||||||
.globalmessage > div {
|
.globalmessage > div {
|
||||||
width: 96%;
|
width: 96%;
|
||||||
|
text-align: center;
|
||||||
word-break: keep-all;
|
word-break: keep-all;
|
||||||
word-wrap: break-word;
|
word-wrap: break-word;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
@ -179,7 +137,11 @@ th {
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
margin-top: 1rem;
|
margin-top: 1rem;
|
||||||
width: 94%;
|
width: 94%;
|
||||||
gap: 2rem;
|
gap: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.userinfo {
|
||||||
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.userinfo > span {
|
.userinfo > span {
|
||||||
|
@ -197,10 +159,6 @@ th {
|
||||||
gap: .5rem;
|
gap: .5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.userpanel-buttons > .button, .userpanel-buttons button {
|
|
||||||
height: 1.2rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.userbalancewarn {
|
.userbalancewarn {
|
||||||
color: var(--color-error);
|
color: var(--color-error);
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
|
@ -234,7 +192,7 @@ main {
|
||||||
}
|
}
|
||||||
|
|
||||||
.footer > div {
|
.footer > div {
|
||||||
font-size: 16px;
|
font-size: .95rem;
|
||||||
margin-top: .15rem;
|
margin-top: .15rem;
|
||||||
margin-bottom: .15rem;
|
margin-bottom: .15rem;
|
||||||
}
|
}
|
||||||
|
@ -274,18 +232,19 @@ main {
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
.text-align-right {
|
|
||||||
text-align: right;
|
|
||||||
}
|
|
||||||
|
|
||||||
.text-align-center {
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.gap-1rem {
|
.gap-1rem {
|
||||||
gap: 1rem;
|
gap: 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.fill {
|
||||||
|
height: 100%;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fill-vertical {
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
.buttons {
|
.buttons {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
|
@ -298,26 +257,24 @@ main {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
font-family: var(--font-family);
|
||||||
|
text-decoration: none;
|
||||||
|
text-align: center !important;
|
||||||
|
background: var(--bg-color);
|
||||||
|
color: var(--color);
|
||||||
|
font-size: 1rem;
|
||||||
|
padding: .6rem .8rem;
|
||||||
outline: none;
|
outline: none;
|
||||||
border: 1px solid var(--border-color);
|
border: none;
|
||||||
|
border-bottom: 1px solid var(--border-color);
|
||||||
border-radius: var(--border-radius);
|
border-radius: var(--border-radius);
|
||||||
|
cursor: pointer;
|
||||||
|
user-select: none;
|
||||||
|
box-sizing: content-box;
|
||||||
width: fit-content;
|
width: fit-content;
|
||||||
}
|
}
|
||||||
|
|
||||||
.button, button, .dropdownchoice {
|
.button:hover, button:hover, .button:active, button:active {
|
||||||
padding: var(--element-padding);
|
|
||||||
font-size: 16px;
|
|
||||||
text-align: center !important;
|
|
||||||
text-decoration: none;
|
|
||||||
color: var(--color);
|
|
||||||
box-sizing: content-box;
|
|
||||||
cursor: pointer;
|
|
||||||
user-select: none;
|
|
||||||
background: var(--bg-color);
|
|
||||||
}
|
|
||||||
|
|
||||||
.button:hover, button:hover,
|
|
||||||
.button:active, button:active {
|
|
||||||
background: var(--bg-hover-color);
|
background: var(--bg-hover-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -325,55 +282,30 @@ main {
|
||||||
opacity: 40%;
|
opacity: 40%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.formheading {
|
.appform > .forminfo {
|
||||||
margin-bottom: 2rem;
|
width: 100%;
|
||||||
}
|
|
||||||
|
|
||||||
.forminfo {
|
|
||||||
width: fit-content;
|
|
||||||
min-width: 16rem;
|
|
||||||
text-align: left;
|
text-align: left;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
gap: 2rem;
|
gap: 2rem;
|
||||||
padding-bottom: .15rem;
|
|
||||||
border-bottom: 1px solid #ffffff20;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.forminfo > span:last-child {
|
.forminfo > span:last-child {
|
||||||
float: right;
|
float: right;
|
||||||
}
|
}
|
||||||
|
|
||||||
.appform, .appform > * {
|
|
||||||
max-width: 90vw;
|
|
||||||
}
|
|
||||||
|
|
||||||
.appform > .forminput {
|
.appform > .forminput {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
justify-content: space-between;
|
justify-content: space-evenly;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
gap: 1rem;
|
gap: 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.forminput > input, .forminput > select {
|
.appform > .statusinfo {
|
||||||
width: 100% !important;
|
margin-top: .5rem;
|
||||||
}
|
|
||||||
|
|
||||||
.forminput > .keyboard-input, #transfer-recipient {
|
|
||||||
/* the keyboard has a 5px padding */
|
|
||||||
margin-left: 5px !important;
|
|
||||||
margin-right: 5px !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.appform > .buttons {
|
|
||||||
margin-top: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
#statusinfo {
|
|
||||||
margin-top: 1rem;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.dropdownmenu {
|
.dropdownmenu {
|
||||||
|
@ -384,89 +316,77 @@ main {
|
||||||
border-radius: var(--border-radius);
|
border-radius: var(--border-radius);
|
||||||
}
|
}
|
||||||
|
|
||||||
#dropdownnope {
|
|
||||||
position: fixed;
|
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
width: 100vw;
|
|
||||||
height: 100vh;
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.dropdownbutton {
|
.dropdownbutton {
|
||||||
|
width: fit-content;
|
||||||
z-index: 190;
|
z-index: 190;
|
||||||
}
|
text-align: center;
|
||||||
|
justify-content: center;
|
||||||
.dropdownbutton > img {
|
|
||||||
width: auto;
|
|
||||||
height: 100%;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.dropdownlist {
|
.dropdownlist {
|
||||||
margin-top: 3rem;
|
|
||||||
position: absolute;
|
position: absolute;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
border-radius: var(--border-radius);
|
|
||||||
box-shadow: 0 0 .5rem #00000025;
|
|
||||||
}
|
|
||||||
|
|
||||||
.dropdownlist, #dropdownnope {
|
|
||||||
visibility: hidden;
|
|
||||||
opacity: 0%;
|
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
}
|
border-radius: var(--border-radius) !important;
|
||||||
|
z-index: 200;
|
||||||
.dropdownvisible .dropdownlist,
|
margin-top: 3.2rem;
|
||||||
.dropdownvisible #dropdownnope {
|
opacity: 0%;
|
||||||
opacity: 100%;
|
transition: opacity 100ms;
|
||||||
background: #00000020;
|
|
||||||
visibility: visible;
|
|
||||||
pointer-events: visible;
|
|
||||||
z-index: 100;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.dropdownchoice {
|
.dropdownchoice {
|
||||||
z-index: 200;
|
border-radius: 0 !important;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
text-decoration: none;
|
text-align: center;
|
||||||
|
justify-content: center;
|
||||||
|
background: var(--bg-color2) !important;
|
||||||
|
backdrop-filter: none !important;
|
||||||
width: initial;
|
width: initial;
|
||||||
min-width: max-content;
|
|
||||||
border-bottom: 1px solid var(--border-color);
|
|
||||||
border-left: 1px solid var(--border-color);
|
|
||||||
border-right: 1px solid var(--border-color);
|
|
||||||
}
|
|
||||||
|
|
||||||
.dropdownchoice:first-child {
|
|
||||||
border-top: 1px solid var(--border-color);
|
|
||||||
border-top-left-radius: var(--border-radius);
|
|
||||||
border-top-right-radius: var(--border-radius);
|
|
||||||
}
|
|
||||||
|
|
||||||
.dropdownchoice:last-child {
|
|
||||||
border-bottom: 1px solid var(--border-color);
|
|
||||||
border-bottom-left-radius: var(--border-radius);
|
|
||||||
border-bottom-right-radius: var(--border-radius);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.dropdownchoice:hover {
|
.dropdownchoice:hover {
|
||||||
background: var(--bg-hover-color);
|
background: var(--bg-hover-color2) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dropdownlist :first-child {
|
||||||
|
border-top-left-radius: var(--border-radius) !important;
|
||||||
|
border-top-right-radius: var(--border-radius) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dropdownlist :last-child {
|
||||||
|
border-bottom-left-radius: var(--border-radius) !important;
|
||||||
|
border-bottom-right-radius: var(--border-radius) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dropdownvisible .dropdownlist {
|
||||||
|
opacity: 100%;
|
||||||
|
visibility: visible;
|
||||||
|
pointer-events: visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
.customnumberinput {
|
.customnumberinput {
|
||||||
height: 2.2rem;
|
height: 2.2rem;
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
align-items: center;
|
|
||||||
gap: .25rem;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.customnumberinput button {
|
.customnumberinput button {
|
||||||
width: 2.2rem !important;
|
min-width: 2.5rem !important;
|
||||||
height: 2.2rem !important;
|
width: 2.5rem !important;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.customnumberinput-minus {
|
||||||
|
border-bottom-right-radius: 0;
|
||||||
|
border-top-right-radius: 0;
|
||||||
|
z-index: 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
.customnumberinput-plus {
|
||||||
|
border-bottom-left-radius: 0;
|
||||||
|
border-top-left-radius: 0;
|
||||||
|
z-index: 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
.customnumberinput input[type="number"] {
|
.customnumberinput input[type="number"] {
|
||||||
|
@ -475,13 +395,13 @@ main {
|
||||||
padding: 0;
|
padding: 0;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
background: var(--bg-color2);
|
background: var(--bg-color2);
|
||||||
|
border-radius: 0 !important;
|
||||||
-webkit-appearance: textfield;
|
-webkit-appearance: textfield;
|
||||||
-moz-appearance: textfield;
|
-moz-appearance: textfield;
|
||||||
appearance: textfield;
|
appearance: textfield;
|
||||||
}
|
}
|
||||||
|
|
||||||
.errortext {
|
.errortext {
|
||||||
font-weight: bold;
|
|
||||||
color: var(--color-error);
|
color: var(--color-error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -491,11 +411,6 @@ main {
|
||||||
|
|
||||||
/* Login */
|
/* Login */
|
||||||
|
|
||||||
.userlist-container {
|
|
||||||
flex-grow: 1;
|
|
||||||
padding-bottom: 10vh;
|
|
||||||
}
|
|
||||||
|
|
||||||
.userlist {
|
.userlist {
|
||||||
width: 60%;
|
width: 60%;
|
||||||
list-style: none;
|
list-style: none;
|
||||||
|
@ -505,7 +420,8 @@ main {
|
||||||
}
|
}
|
||||||
|
|
||||||
.userlist > li {
|
.userlist > li {
|
||||||
padding: .1rem .6rem;
|
margin-bottom: .5rem;
|
||||||
|
padding: 0 .5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.userlist > li > img {
|
.userlist > li > img {
|
||||||
|
@ -518,7 +434,7 @@ main {
|
||||||
.userlist > li > div {
|
.userlist > li > div {
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
padding: .7rem 1.1rem;
|
padding: .8rem 1.1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.loginform {
|
.loginform {
|
||||||
|
@ -530,18 +446,6 @@ main {
|
||||||
margin-top: 0;
|
margin-top: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#passwordoverlay-container {
|
|
||||||
position: fixed;
|
|
||||||
width: 100vw;
|
|
||||||
height: 100vh;
|
|
||||||
top: 0;
|
|
||||||
right: 0;
|
|
||||||
background: var(--bg-page);
|
|
||||||
align-items: center;
|
|
||||||
padding-top: 10vh;
|
|
||||||
z-index: 200;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Drinks List */
|
/* Drinks List */
|
||||||
|
|
||||||
.drinks-list {
|
.drinks-list {
|
||||||
|
@ -558,37 +462,7 @@ main {
|
||||||
.drinks-list > li > .button {
|
.drinks-list > li > .button {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
padding: .7rem 1.1rem;
|
padding: .8rem 1.1rem;
|
||||||
}
|
|
||||||
|
|
||||||
/* Statistics */
|
|
||||||
|
|
||||||
.statistics-container {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
align-items: flex-start;
|
|
||||||
justify-content: center;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
max-width: 90vw;
|
|
||||||
gap: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.statistics-container > div {
|
|
||||||
height: 100%;
|
|
||||||
width: 16rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Blur */
|
|
||||||
|
|
||||||
@supports (backdrop-filter: blur()) {
|
|
||||||
.dropdownvisible #dropdownnope {
|
|
||||||
backdrop-filter: blur(16px);
|
|
||||||
}
|
|
||||||
#passwordoverlay-container {
|
|
||||||
background: #00000020;
|
|
||||||
backdrop-filter: blur(64px); /* fallback */
|
|
||||||
backdrop-filter: blur(128px);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Responsive */
|
/* Responsive */
|
||||||
|
@ -611,10 +485,9 @@ main {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@media only screen and (max-width: 860px) {
|
@media only screen and (max-width: 700px) {
|
||||||
.userpanel {
|
.userpanel {
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 1rem;
|
|
||||||
}
|
}
|
||||||
.userlist {
|
.userlist {
|
||||||
gap: 0.25rem;
|
gap: 0.25rem;
|
||||||
|
@ -631,12 +504,4 @@ main {
|
||||||
.drinks-list {
|
.drinks-list {
|
||||||
width: 90%;
|
width: 90%;
|
||||||
}
|
}
|
||||||
.dropdownlist {
|
|
||||||
width: 14rem;
|
|
||||||
right: calc(50vw - 7rem); /* regard width */
|
|
||||||
left: auto;
|
|
||||||
}
|
|
||||||
#keyboard {
|
|
||||||
display: none !important;
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -5,8 +5,6 @@
|
||||||
width: 50rem;
|
width: 50rem;
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
background: transparent;
|
background: transparent;
|
||||||
font-family: "Inter";
|
|
||||||
font-size: 16px;
|
|
||||||
}
|
}
|
||||||
.simple-keyboard.darkTheme .hg-button {
|
.simple-keyboard.darkTheme .hg-button {
|
||||||
height: 50px;
|
height: 50px;
|
||||||
|
@ -15,8 +13,8 @@
|
||||||
align-items: center;
|
align-items: center;
|
||||||
background: var(--bg-color);
|
background: var(--bg-color);
|
||||||
color: white;
|
color: white;
|
||||||
border: 1px solid var(--border-color);
|
border: none;
|
||||||
border-radius: var(--border-radius);
|
border-bottom: 1px solid var(--border-color);
|
||||||
}
|
}
|
||||||
.simple-keyboard.darkTheme .hg-button:active,
|
.simple-keyboard.darkTheme .hg-button:active,
|
||||||
.simple-keyboard.darkTheme .hg-button:hover {
|
.simple-keyboard.darkTheme .hg-button:hover {
|
Before Width: | Height: | Size: 43 KiB After Width: | Height: | Size: 43 KiB |
Before Width: | Height: | Size: 41 KiB After Width: | Height: | Size: 41 KiB |
|
@ -1,15 +1,15 @@
|
||||||
document.addEventListener("DOMContentLoaded", () => {
|
document.addEventListener("DOMContentLoaded", () => {
|
||||||
// elements
|
// elements
|
||||||
let customForm = document.getElementById("customform");
|
let depositForm = document.getElementById("depositform");
|
||||||
let statusInfo = document.getElementById("statusinfo");
|
let statusInfo = document.getElementById("statusinfo");
|
||||||
let submitButton = document.getElementById("submitbtn");
|
let depositSubmitButton = document.getElementById("depositsubmitbtn");
|
||||||
// event listener for deposit form
|
// event listener for deposit form
|
||||||
// this implements a custom submit method
|
// this implements a custom submit method
|
||||||
customForm.addEventListener("submit", (event) => {
|
depositForm.addEventListener("submit", (event) => {
|
||||||
submitButton.disabled = true;
|
depositSubmitButton.disabled = true;
|
||||||
event.preventDefault(); // Don't do the default submit action!
|
event.preventDefault(); // Don't do the default submit action!
|
||||||
let xhr = new XMLHttpRequest();
|
let xhr = new XMLHttpRequest();
|
||||||
let formData = new FormData(customForm);
|
let formData = new FormData(depositForm);
|
||||||
xhr.addEventListener("load", (event) => {
|
xhr.addEventListener("load", (event) => {
|
||||||
status_ = event.target.status;
|
status_ = event.target.status;
|
||||||
response_ = event.target.responseText;
|
response_ = event.target.responseText;
|
||||||
|
@ -28,7 +28,7 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||||
statusInfo.innerText = "An error occured. Redirecting in 5 seconds...";
|
statusInfo.innerText = "An error occured. Redirecting in 5 seconds...";
|
||||||
window.setTimeout(() => { window.location.replace("/") }, 5000);
|
window.setTimeout(() => { window.location.replace("/") }, 5000);
|
||||||
})
|
})
|
||||||
xhr.open("POST", customForm.action);
|
xhr.open("POST", "/api/deposit");
|
||||||
xhr.send(formData);
|
xhr.send(formData);
|
||||||
});
|
});
|
||||||
});
|
});
|
|
@ -6,6 +6,7 @@
|
||||||
let passwordOverlayElement;
|
let passwordOverlayElement;
|
||||||
let pwOverlayCancelButton;
|
let pwOverlayCancelButton;
|
||||||
let userlistButtons;
|
let userlistButtons;
|
||||||
|
let pinpadButtons;
|
||||||
let userlistContainerElement;
|
let userlistContainerElement;
|
||||||
// Add event listeners after DOM Content loaded
|
// Add event listeners after DOM Content loaded
|
||||||
document.addEventListener("DOMContentLoaded", () => {
|
document.addEventListener("DOMContentLoaded", () => {
|
||||||
|
@ -35,14 +36,9 @@
|
||||||
function show_password_overlay() {
|
function show_password_overlay() {
|
||||||
window.scrollTo(0, 0);
|
window.scrollTo(0, 0);
|
||||||
passwordOverlayElement.classList.remove("nodisplay");
|
passwordOverlayElement.classList.remove("nodisplay");
|
||||||
passwordInputElement.focus()
|
|
||||||
}
|
}
|
||||||
function hide_password_overlay() {
|
function hide_password_overlay() {
|
||||||
passwordOverlayElement.classList.add("nodisplay");
|
passwordOverlayElement.classList.add("nodisplay");
|
||||||
passwordInputElement.value = "";
|
passwordInputElement.value = "";
|
||||||
// Dispatch an Input Event to the input element to trigger the on-
|
|
||||||
// screen keyboard to update its buffer. This fixes a security
|
|
||||||
// issue on the login page.
|
|
||||||
passwordInputElement.dispatchEvent(new Event("input", {bubbles: true}));
|
|
||||||
}
|
}
|
||||||
})();
|
})();
|
14
app/static/js/main.js
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
document.addEventListener("DOMContentLoaded", () => {
|
||||||
|
let dropdownmenuElement = document.getElementById("dropdownmenu");
|
||||||
|
let dropdownmenuButtonElement = document.getElementById("dropdownmenu-button");
|
||||||
|
if (dropdownmenuButtonElement != null) {
|
||||||
|
dropdownmenuButtonElement.addEventListener("click", () => {
|
||||||
|
if (dropdownmenuElement.classList.contains("dropdownvisible")) {
|
||||||
|
dropdownmenuElement.classList.remove("dropdownvisible");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
dropdownmenuElement.classList.add("dropdownvisible");
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
});
|
|
@ -38,8 +38,7 @@
|
||||||
"1 2 3",
|
"1 2 3",
|
||||||
"4 5 6",
|
"4 5 6",
|
||||||
"7 8 9",
|
"7 8 9",
|
||||||
"0 . ,",
|
"{bksp} . ,"
|
||||||
"{bksp}"
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
// Check if on smartphone
|
// Check if on smartphone
|
39
app/static/js/supply.js
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
document.addEventListener("DOMContentLoaded", () => {
|
||||||
|
// elements
|
||||||
|
let supplyDescriptionElement = document.getElementById("supplydescription");
|
||||||
|
let supplyPriceElement = document.getElementById("supplyprice");
|
||||||
|
let supplyFormElement = document.getElementById("supplyform");
|
||||||
|
let statusInfoElement = document.getElementById("statusinfo");
|
||||||
|
let supplySubmitButton = document.getElementById("supplysubmitbtn");
|
||||||
|
// custom submit method
|
||||||
|
supplyFormElement.addEventListener("submit", (event) => {
|
||||||
|
supplySubmitButton.disabled = true;
|
||||||
|
event.preventDefault(); // Don't do the default submit action!
|
||||||
|
if (isNaN(parseFloat(supplyPriceElement.value)) || supplyDescriptionElement.value == "") {
|
||||||
|
statusInfoElement.innerText = "Please enter a description and price."
|
||||||
|
supplySubmitButton.disabled = false;
|
||||||
|
}
|
||||||
|
let xhr = new XMLHttpRequest();
|
||||||
|
let formData = new FormData(supplyFormElement);
|
||||||
|
xhr.addEventListener("load", (event) => {
|
||||||
|
status_ = event.target.status;
|
||||||
|
response_ = event.target.responseText;
|
||||||
|
if (status_ == 200 && response_ == "success") {
|
||||||
|
statusInfoElement.innerText = "Success.";
|
||||||
|
window.location.replace("/");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
statusInfoElement.classList.add("errortext");
|
||||||
|
statusInfoElement.innerText = "An error occured.";
|
||||||
|
window.setTimeout(() => { window.location.reload() }, 5000);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
xhr.addEventListener("error", (event) => {
|
||||||
|
statusInfoElement.classList.add("errortext");
|
||||||
|
statusInfoElement.innerText = "An error occured.";
|
||||||
|
window.setTimeout(() => { window.location.reload() }, 5000);
|
||||||
|
})
|
||||||
|
xhr.open("POST", "/api/supply");
|
||||||
|
xhr.send(formData);
|
||||||
|
});
|
||||||
|
});
|
|
@ -25,7 +25,7 @@
|
||||||
<div class="flex flex-center">
|
<div class="flex flex-center">
|
||||||
{% translate "An error occured. Please log out and log in again." %}
|
{% translate "An error occured. Please log out and log in again." %}
|
||||||
<br>
|
<br>
|
||||||
<a class="button" href="/accounts/logout">log out</a>
|
<a href="/accounts/logout">log out</a>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</main>
|
</main>
|
||||||
|
|
|
@ -8,26 +8,29 @@
|
||||||
|
|
||||||
{% block headAdditional %}
|
{% block headAdditional %}
|
||||||
<link rel="stylesheet" href="/static/css/simple-keyboard.css">
|
<link rel="stylesheet" href="/static/css/simple-keyboard.css">
|
||||||
<link rel="stylesheet" href="/static/css/simple-keyboard_custom.css">
|
<link rel="stylesheet" href="/static/css/simple-keyboard_dark.css">
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h1 class="formheading">{% translate "Deposit" %}</h1>
|
<form id="depositform" class="flex flex-column flex-center appform gap-1rem">
|
||||||
<form id="customform" class="flex flex-column flex-center appform gap-1rem" action="/api/deposit">
|
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
|
<h1 class="formheading">{% translate "Deposit" %}</h1>
|
||||||
<div class="flex forminput">
|
<div class="flex forminput">
|
||||||
<input type="number" name="depositamount" class="keyboard-input depositamount" max="9999.99" min="1.00" step="0.01" placeholder="{% translate 'Amount' %} ({{ currency_suffix }})" autofocus required>
|
<span>{% translate "Amount" %} {{ currency_suffix }}:</span>
|
||||||
|
<span>
|
||||||
|
<input type="number" name="depositamount" id="depositamount" class="keyboard-input" max="9999.99" min="1.00" step="0.01" autofocus>
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
<div id="statusinfo"></div>
|
||||||
<!-- Virtual Keyboard -->
|
<!-- Virtual Keyboard -->
|
||||||
<div id="keyboard" class="simple-keyboard" data-layout="numeric"></div>
|
<div id="keyboard" class="simple-keyboard" data-layout="numeric"></div>
|
||||||
<script src="/static/js/simple-keyboard.js"></script>
|
<script src="/static/js/simple-keyboard.js"></script>
|
||||||
<script src="/static/js/simple-keyboard_configure.js"></script>
|
<script src="/static/js/simple-keyboard_configure.js"></script>
|
||||||
<div class="flex-center buttons">
|
<div class="flex-center buttons">
|
||||||
<a href="/" class="button">{% translate "cancel" %}</a>
|
<a href="/" class="button">{% translate "cancel" %}</a>
|
||||||
<input type="submit" id="submitbtn" class="button" value='{% translate "confirm" %}'>
|
<input type="submit" id="depositsubmitbtn" class="button" value='{% translate "confirm" %}'>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
<div id="statusinfo"></div>
|
<script src="/static/js/deposit.js"></script>
|
||||||
<script src="/static/js/custom_form.js"></script>
|
|
||||||
<script src="/static/js/autoreload.js"></script>
|
<script src="/static/js/autoreload.js"></script>
|
||||||
{% endblock %}
|
{% endblock %}
|
|
@ -2,6 +2,6 @@
|
||||||
<footer class="footer-container">
|
<footer class="footer-container">
|
||||||
<div class="flex flex-row flex-center flex-wrap footer">
|
<div class="flex flex-row flex-center flex-wrap footer">
|
||||||
<div>Version {{ app_version }}</div>
|
<div>Version {{ app_version }}</div>
|
||||||
<div>Copyright (C) 2021-2025, Julian MĂĽller (ChaoticByte)</div>
|
<div>Copyright (C) 2021, Julian MĂĽller (ChaoticByte)</div>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
|
@ -1,5 +1,5 @@
|
||||||
{% if global_message != "" %}
|
{% if global_message != "" %}
|
||||||
<div class="flex flex-center globalmessage text-align-center">
|
<div class="flex flex-center globalmessage">
|
||||||
<div>{{ global_message }}</div>
|
<div>{{ global_message }}</div>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
|
@ -11,13 +11,13 @@
|
||||||
{% if history %}
|
{% if history %}
|
||||||
<table class="history">
|
<table class="history">
|
||||||
<tr>
|
<tr>
|
||||||
<th colspan="3">{% translate "last 30 actions" %}</th>
|
<th>{% translate "last 30 actions" %}</th>
|
||||||
|
<th></th>
|
||||||
</tr>
|
</tr>
|
||||||
{% for h in history %}
|
{% for h in history %}
|
||||||
<tr>
|
<tr>
|
||||||
<td class="text-align-right">{{ h.0 }} {{ currency_suffix }}</td>
|
<td>{{ h.0 }}</td>
|
||||||
<td>{{ h.1 }}</td>
|
<td class="historydate">{{ h.1 }}</td>
|
||||||
<td>{{ h.2 }}</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -11,31 +11,31 @@
|
||||||
<div class="flex flex-column flex-center">
|
<div class="flex flex-column flex-center">
|
||||||
{% if drink and drink.available > 0 and not drink.deleted %}
|
{% if drink and drink.available > 0 and not drink.deleted %}
|
||||||
{% if user.balance > 0 or user.allow_order_with_negative_balance %}
|
{% if user.balance > 0 or user.allow_order_with_negative_balance %}
|
||||||
<h1 class="formheading">{% translate "Order" %}</h1>
|
|
||||||
<form id="orderform" class="flex flex-column flex-center appform gap-1rem">
|
<form id="orderform" class="flex flex-column flex-center appform gap-1rem">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
|
<h1 class="formheading">{% translate "Order" %}</h1>
|
||||||
<div class="forminfo">
|
<div class="forminfo">
|
||||||
<span>{% translate "Drink" %}</span>
|
<span>{% translate "Drink" %}:</span>
|
||||||
<span>{{ drink.product_name }}</span>
|
<span>{{ drink.product_name }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="forminfo">
|
<div class="forminfo">
|
||||||
<span>{% translate "Price per Item" %} ({{ currency_suffix }})</span>
|
<span>{% translate "Price per Item" %} ({{ currency_suffix }}):</span>
|
||||||
<span id="priceperdrink" data-drink-price="{% localize off %}{{ drink.price }}{% endlocalize %}">
|
<span id="priceperdrink" data-drink-price="{% localize off %}{{ drink.price }}{% endlocalize %}">
|
||||||
{{ drink.price }}
|
{{ drink.price }}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
{% if not drink.do_not_count %}
|
{% if not drink.do_not_count %}
|
||||||
<div class="forminfo">
|
<div class="forminfo">
|
||||||
<span>{% translate "Available" %}</span>
|
<span>{% translate "Available" %}:</span>
|
||||||
<span>{{ drink.available }}</span>
|
<span>{{ drink.available }}</span>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<div class="forminfo">
|
<div class="forminfo">
|
||||||
<span>{% translate "Sum" %} ({{ currency_suffix }})</span>
|
<span>{% translate "Sum" %} ({{ currency_suffix }}):</span>
|
||||||
<span id="ordercalculatedsum">{{ drink.price }}</span>
|
<span id="ordercalculatedsum">{{ drink.price }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex forminput">
|
<div class="flex forminput">
|
||||||
<span>{% translate "Count" %}</span>
|
<span>{% translate "Count" %}:</span>
|
||||||
<span class="flex flex-row customnumberinput">
|
<span class="flex flex-row customnumberinput">
|
||||||
<button type="button" class="customnumberinput-minus" id="numberofdrinks-btn-minus">-</button>
|
<button type="button" class="customnumberinput-minus" id="numberofdrinks-btn-minus">-</button>
|
||||||
{% if drink.do_not_count %}
|
{% if drink.do_not_count %}
|
||||||
|
@ -48,19 +48,19 @@
|
||||||
<button type="button" class="customnumberinput-plus" id="numberofdrinks-btn-plus">+</button>
|
<button type="button" class="customnumberinput-plus" id="numberofdrinks-btn-plus">+</button>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
<div id="statusinfo"></div>
|
||||||
<input type="hidden" name="drinkid" id="drinkid" value="{{ drink.id }}">
|
<input type="hidden" name="drinkid" id="drinkid" value="{{ drink.id }}">
|
||||||
<div class="buttons">
|
<div class="buttons">
|
||||||
<a href="/" class="button">{% translate "cancel" %}</a>
|
<a href="/" class="button">{% translate "cancel" %}</a>
|
||||||
<input type="submit" id="ordersubmitbtn" class="button" value='{% translate "order" %}'>
|
<input type="submit" id="ordersubmitbtn" class="button" value='{% translate "order" %}'>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
<div id="statusinfo"></div>
|
|
||||||
<script src="/static/js/order.js"></script>
|
<script src="/static/js/order.js"></script>
|
||||||
<script src="/static/js/custom_number_input.js"></script>
|
<script src="/static/js/custom_number_input.js"></script>
|
||||||
{% else %}
|
{% else %}
|
||||||
<div class="flex flex-center flex-column">
|
<div class="flex flex-center">
|
||||||
<p>{% translate "Your balance is too low to order a drink." %}</p>
|
<p>{% translate "Your balance is too low to order a drink." %}</p>
|
||||||
<a href="/" class="button">{% translate "back" %}</a>
|
<a href="/">{% translate "back" %}</a>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% else %}
|
{% else %}
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
{% block headAdditional %}
|
{% block headAdditional %}
|
||||||
<link rel="stylesheet" href="/static/css/simple-keyboard.css">
|
<link rel="stylesheet" href="/static/css/simple-keyboard.css">
|
||||||
<link rel="stylesheet" href="/static/css/simple-keyboard_custom.css">
|
<link rel="stylesheet" href="/static/css/simple-keyboard_dark.css">
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
@ -19,7 +19,7 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<div class="flex flex-column gap-1rem nodisplay" id="passwordoverlay-container">
|
<div class="flex flex-column gap-1rem nodisplay" id="passwordoverlay-container">
|
||||||
<div class="passwordoverlay">
|
<div class="passwordoverlay">
|
||||||
<h1 class="formheading">{% translate "Log in" %}</h1>
|
<h1>{% translate "Log in" %}</h1>
|
||||||
<form method="post" action="{% url 'login' %}" class="flex flex-center loginform">
|
<form method="post" action="{% url 'login' %}" class="flex flex-center loginform">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<input type="text" name="username" autofocus="" autocapitalize="none" autocomplete="username" maxlength="150" required="" id="id_username">
|
<input type="text" name="username" autofocus="" autocapitalize="none" autocomplete="username" maxlength="150" required="" id="id_username">
|
||||||
|
@ -36,7 +36,7 @@
|
||||||
<script src="/static/js/simple-keyboard.js"></script>
|
<script src="/static/js/simple-keyboard.js"></script>
|
||||||
<script src="/static/js/simple-keyboard_configure.js"></script>
|
<script src="/static/js/simple-keyboard_configure.js"></script>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-column flex-center userlist-container">
|
<div class="flex flex-column flex-center">
|
||||||
<h1>{% translate "Choose your account" %}</h1>
|
<h1>{% translate "Choose your account" %}</h1>
|
||||||
<ul class="flex flex-center flex-wrap userlist">
|
<ul class="flex flex-center flex-wrap userlist">
|
||||||
{% for user_ in user_list %}
|
{% for user_ in user_list %}
|
||||||
|
@ -48,8 +48,6 @@
|
||||||
{{ user_.last_name }},
|
{{ user_.last_name }},
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{{ user_.first_name }}
|
{{ user_.first_name }}
|
||||||
{% elif user_.last_name %}
|
|
||||||
{{ user_.last_name }}
|
|
||||||
{% else %}
|
{% else %}
|
||||||
{{ user_.username }}
|
{{ user_.username }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -8,96 +8,57 @@
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h1>{% translate "Statistics" %}</h1>
|
<h1>{% translate "Statistics" %}</h1>
|
||||||
<div class="statistics-container">
|
<div>
|
||||||
<div class="flex flex-column">
|
<div class="flex flex-column flex-center">
|
||||||
<h3>{% translate "orders / drink" %}</h3>
|
<h3>{% translate "Orders per drink" %}</h3>
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<th>{% translate "drink" %}</th>
|
<th>{% translate "drink" %}</th>
|
||||||
<th>{% translate "all" %}</th>
|
|
||||||
<th>{% translate "you" %}</th>
|
<th>{% translate "you" %}</th>
|
||||||
|
<th>{% translate "all" %}</th>
|
||||||
</tr>
|
</tr>
|
||||||
{% for key, values in orders_per_drink.items %}
|
{% for key, values in orders_per_drink.items %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ key }}</td>
|
<td>{{ key }}</td>
|
||||||
<td>{{ values.a|default:0 }}</td>
|
<td>{{ values.a|default:"0" }}</td>
|
||||||
<td>{{ values.b|default:0 }}</td>
|
<td>{{ values.b|default:"0" }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div class="flex flex-column flex-center">
|
||||||
<div class="statistics-container">
|
<h3>{% translate "Orders per month (last 12 months)" %}</h3>
|
||||||
<div class="flex flex-column">
|
|
||||||
<h3>{% translate "orders / month" %}</h3>
|
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<th>{% translate "month" %}</th>
|
<th>{% translate "month" %}</th>
|
||||||
<th>{% translate "all" %}</th>
|
|
||||||
<th>{% translate "you" %}</th>
|
<th>{% translate "you" %}</th>
|
||||||
|
<th>{% translate "all" %}</th>
|
||||||
</tr>
|
</tr>
|
||||||
{% for key, values in orders_per_month.items %}
|
{% for key, values in orders_per_month.items %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ key }}</td>
|
<td>{{ key }}</td>
|
||||||
<td>{{ values.a|default:0 }}</td>
|
<td>{{ values.a|default:"0" }}</td>
|
||||||
<td>{{ values.b|default:0 }}</td>
|
<td>{{ values.b|default:"0" }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-column">
|
<div class="flex flex-column flex-center">
|
||||||
<h3>{% translate "orders / weekday" %}</h3>
|
<h3>{% translate "Orders per weekday" %}</h3>
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<th>{% translate "day" %}</th>
|
<th>{% translate "day" %}</th>
|
||||||
<th>{% translate "all" %}</th>
|
|
||||||
<th>{% translate "you" %}</th>
|
<th>{% translate "you" %}</th>
|
||||||
|
<th>{% translate "all" %}</th>
|
||||||
</tr>
|
</tr>
|
||||||
{% for values in orders_per_weekday %}
|
{% for key, values in orders_per_weekday.items %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ values.0 }}</td>
|
<td>{{ key }}</td>
|
||||||
<td>{{ values.1|default:0 }}</td>
|
<td>{{ values.a|default:"0" }}</td>
|
||||||
<td>{{ values.2|default:0 }}</td>
|
<td>{{ values.b|default:"0" }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
<div class="statistics-container">
|
|
||||||
{% if user.is_superuser or perms.app.view_order %}
|
|
||||||
<div class="flex flex-column">
|
|
||||||
<h3>{% translate "order sum" %}</h3>
|
|
||||||
<table>
|
|
||||||
<tr>
|
|
||||||
<th>{% translate "user" %}</th>
|
|
||||||
<th>{% translate "sum" %}</th>
|
|
||||||
</tr>
|
|
||||||
{% for values in order_sum_per_user %}
|
|
||||||
<tr>
|
|
||||||
<td>{{ values.0 }}</td>
|
|
||||||
<td>{{ values.1|default:0.0 }} {{ currency_suffix }}</td>
|
|
||||||
</tr>
|
|
||||||
{% endfor %}
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
{% if user.is_superuser or perms.app.view_registertransaction %}
|
|
||||||
<div class="flex flex-column">
|
|
||||||
<h3>{% translate "deposit sum" %}</h3>
|
|
||||||
<table>
|
|
||||||
<tr>
|
|
||||||
<th>{% translate "user" %}</th>
|
|
||||||
<th>{% translate "sum" %}</th>
|
|
||||||
</tr>
|
|
||||||
{% for values in deposit_sum_per_user %}
|
|
||||||
<tr>
|
|
||||||
<td>{{ values.0 }}</td>
|
|
||||||
<td>{{ values.1|default:0.0 }} {{ currency_suffix }}</td>
|
|
||||||
</tr>
|
|
||||||
{% endfor %}
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
<script src="/static/js/autoreload.js"></script>
|
<script src="/static/js/autoreload.js"></script>
|
||||||
{% endblock %}
|
{% endblock %}
|
|
@ -9,22 +9,28 @@
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
{% if user.is_superuser or user.allowed_to_supply %}
|
{% if user.is_superuser or user.allowed_to_supply %}
|
||||||
<h1 class="formheading">{% translate "Supply" %}</h1>
|
<form id="supplyform" class="flex flex-column flex-center appform gap-1rem">
|
||||||
<form id="customform" class="flex flex-column flex-center appform gap-1rem" action="/api/supply">
|
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
|
<h1 class="formheading">{% translate "Supply" %}</h1>
|
||||||
<div class="flex forminput">
|
<div class="flex forminput">
|
||||||
<input type="text" name="supplydescription" placeholder="{% translate 'Description' %}" autofocus required>
|
<span>{% translate "Description" %}:</span>
|
||||||
|
<span>
|
||||||
|
<input type="text" name="supplydescription" id="supplydescription" autofocus>
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex forminput">
|
<div class="flex forminput">
|
||||||
<input type="number" name="supplyprice" max="9999.99" min="1.00" step="0.01" placeholder="{% translate 'Price' %} ({{ currency_suffix }})" required>
|
<span>{% translate "Price" %} ({{ currency_suffix }}):</span>
|
||||||
|
<span>
|
||||||
|
<input type="number" name="supplyprice" id="supplyprice" max="9999.99" min="1.00" step="0.01">
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
<div id="statusinfo"></div>
|
||||||
<div class="buttons">
|
<div class="buttons">
|
||||||
<a href="/" class="button">{% translate "cancel" %}</a>
|
<a href="/" class="button">{% translate "cancel" %}</a>
|
||||||
<input type="submit" id="submitbtn" class="button" value='{% translate "submit" %}'>
|
<input type="submit" id="supplysubmitbtn" class="button" value='{% translate "submit" %}'>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
<div id="statusinfo"></div>
|
<script src="/static/js/supply.js"></script>
|
||||||
<script src="/static/js/custom_form.js"></script>
|
|
||||||
<script src="/static/js/custom_number_input.js"></script>
|
<script src="/static/js/custom_number_input.js"></script>
|
||||||
{% else %}
|
{% else %}
|
||||||
<div class="flex flex-center">
|
<div class="flex flex-center">
|
||||||
|
|
|
@ -1,54 +0,0 @@
|
||||||
{% extends "baselayout.html" %}
|
|
||||||
|
|
||||||
{% load i18n %}
|
|
||||||
|
|
||||||
{% block title %}
|
|
||||||
{% translate "Drinks - Transfer" %}
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block headAdditional %}
|
|
||||||
<link rel="stylesheet" href="/static/css/simple-keyboard.css">
|
|
||||||
<link rel="stylesheet" href="/static/css/simple-keyboard_custom.css">
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block content %}
|
|
||||||
<h1 class="formheading">{% translate "Transfer Money" %}</h1>
|
|
||||||
<form id="customform" class="flex flex-column flex-center appform gap-1rem" action="/api/transfer">
|
|
||||||
{% csrf_token %}
|
|
||||||
<div class="flex forminput">
|
|
||||||
<select name="recipientuser" id="transfer-recipient" required>
|
|
||||||
<option value="" selected disabled>Recipient</option>
|
|
||||||
{% for user_ in user_list %}
|
|
||||||
{% if user_.id != user.id %}
|
|
||||||
<option value="{{user_.id}}">
|
|
||||||
{% if user_.first_name %}
|
|
||||||
{% if user_.last_name %}
|
|
||||||
{{ user_.last_name }},
|
|
||||||
{% endif %}
|
|
||||||
{{ user_.first_name }}
|
|
||||||
{% elif user_.last_name %}
|
|
||||||
{{ user_.last_name }}
|
|
||||||
{% else %}
|
|
||||||
{{ user_.username }}
|
|
||||||
{% endif %}
|
|
||||||
{% endif %}
|
|
||||||
</option>
|
|
||||||
{% endfor %}
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
<div class="flex forminput">
|
|
||||||
<input type="number" name="transferamount" class="keyboard-input" max="{{ user.balance }}" min="0.01" step="0.01" placeholder="{% translate 'Amount' %} ({{ currency_suffix }})" autofocus required>
|
|
||||||
</div>
|
|
||||||
<!-- Virtual Keyboard -->
|
|
||||||
<div id="keyboard" class="simple-keyboard" data-layout="numeric"></div>
|
|
||||||
<script src="/static/js/simple-keyboard.js"></script>
|
|
||||||
<script src="/static/js/simple-keyboard_configure.js"></script>
|
|
||||||
<div class="flex-center buttons">
|
|
||||||
<a href="/" class="button">{% translate "cancel" %}</a>
|
|
||||||
<input type="submit" id="submitbtn" class="button" value='{% translate "confirm" %}'>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
<div id="statusinfo"></div>
|
|
||||||
<script src="/static/js/custom_form.js"></script>
|
|
||||||
<script src="/static/js/autoreload.js"></script>
|
|
||||||
{% endblock %}
|
|
|
@ -2,14 +2,19 @@
|
||||||
{% load static %}
|
{% load static %}
|
||||||
|
|
||||||
<div class="flex flex-center userpanel">
|
<div class="flex flex-center userpanel">
|
||||||
<div class="userinfo text-align-center">
|
<div class="userinfo">
|
||||||
<img src="/profilepictures/{{ user.profile_picture_filename|urlencode }}"><span>{% if user.first_name != "" %}
|
<img src="/profilepictures/{{ user.profile_picture_filename|urlencode }}">
|
||||||
{{ user.first_name }} {{ user.last_name }} ({{ user.username }}){% else %}{{ user.username }}{% endif %}
|
<span>
|
||||||
|
{% if user.first_name != "" %}
|
||||||
|
{% translate "User" %}: {{ user.first_name }} {{ user.last_name }} ({{ user.username }})
|
||||||
|
{% else %}
|
||||||
|
{% translate "User" %}: {{ user.username }}
|
||||||
|
{% endif %}
|
||||||
-
|
-
|
||||||
{% if user.balance < 0.01 %}
|
{% if user.balance < 0.01 %}
|
||||||
<span class="userbalancewarn">{% translate "Balance" %}: {{ user.balance }} {{ currency_suffix }}</span>
|
<span class="userbalancewarn">{% translate "Balance" %}: {{ user.balance }}{{ currency_suffix }}</span>
|
||||||
{% else %}
|
{% else %}
|
||||||
<span>{% translate "Balance" %}: {{ user.balance }} {{ currency_suffix }}</span>
|
<span>{% translate "Balance" %}: {{ user.balance }}{{ currency_suffix }}</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
@ -18,19 +23,19 @@
|
||||||
<a class="button" href="/deposit">{% translate "Deposit" %}</a>
|
<a class="button" href="/deposit">{% translate "Deposit" %}</a>
|
||||||
<a class="button" href="/accounts/logout">{% translate "Logout" %}</a>
|
<a class="button" href="/accounts/logout">{% translate "Logout" %}</a>
|
||||||
<div class="dropdownmenu" id="dropdownmenu">
|
<div class="dropdownmenu" id="dropdownmenu">
|
||||||
<div id="dropdownnope"></div>
|
<button class="dropdownbutton" id="dropdownmenu-button">
|
||||||
<button class="dropdownbutton" id="dropdownmenu-button"><img src="/static/material-icons/menu.svg"></button>
|
<div>{% translate "Account" %}</div>
|
||||||
|
</button>
|
||||||
<div class="dropdownlist">
|
<div class="dropdownlist">
|
||||||
<a class="dropdownchoice" href="/history">{% translate "History" %}</a>
|
<a class="button dropdownchoice" href="/history">{% translate "History" %}</a>
|
||||||
<a class="dropdownchoice" href="/statistics">{% translate "Statistics" %}</a>
|
<a class="button dropdownchoice" href="/statistics">{% translate "Statistics" %}</a>
|
||||||
{% if user.is_superuser or user.is_staff %}
|
{% if user.is_superuser or user.is_staff %}
|
||||||
<a class="dropdownchoice" href="/admin/">Admin Panel</a>
|
<a class="button dropdownchoice" href="/admin/">Admin Panel</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<a class="dropdownchoice" href="/transfer/">{% translate "Transfer" %}</a>
|
|
||||||
{% if user.is_superuser or user.allowed_to_supply %}
|
{% if user.is_superuser or user.allowed_to_supply %}
|
||||||
<a class="dropdownchoice" href="/supply/">{% translate "Supply" %}</a>
|
<a class="button dropdownchoice" href="/supply/">{% translate "Supply" %}</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<a class="dropdownchoice" href="/accounts/password_change/">{% translate "Change Password" %}</a>
|
<a class="button dropdownchoice" href="/accounts/password_change/">{% translate "Change Password" %}</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -10,7 +10,6 @@ urlpatterns = [
|
||||||
path('history/', views.history),
|
path('history/', views.history),
|
||||||
path('deposit/', views.deposit),
|
path('deposit/', views.deposit),
|
||||||
path('statistics/', views.statistics),
|
path('statistics/', views.statistics),
|
||||||
path('transfer/', views.transfer),
|
|
||||||
path('supply/', views.supply),
|
path('supply/', views.supply),
|
||||||
path('accounts/login/', views.login_page, name="login"),
|
path('accounts/login/', views.login_page, name="login"),
|
||||||
path('accounts/logout/', auth_views.LogoutView.as_view(), name='logout'),
|
path('accounts/logout/', auth_views.LogoutView.as_view(), name='logout'),
|
||||||
|
@ -20,6 +19,5 @@ urlpatterns = [
|
||||||
# API #
|
# API #
|
||||||
path('api/order-drink', views.api_order_drink),
|
path('api/order-drink', views.api_order_drink),
|
||||||
path('api/deposit', views.api_deposit),
|
path('api/deposit', views.api_deposit),
|
||||||
path('api/transfer', views.api_transfer),
|
|
||||||
path('api/supply', views.api_supply)
|
path('api/supply', views.api_supply)
|
||||||
]
|
]
|
||||||
|
|
53
app/views.py
|
@ -25,7 +25,7 @@ from .models import RegisterTransaction
|
||||||
|
|
||||||
|
|
||||||
def login_page(request):
|
def login_page(request):
|
||||||
userlist = get_user_model().objects.filter(hide_from_userlist=False).filter(is_active=True).order_by("username")
|
userlist = get_user_model().objects.filter(is_superuser=False).filter(is_active=True).order_by("username")
|
||||||
if request.method == "POST":
|
if request.method == "POST":
|
||||||
form = AuthenticationForm(request.POST)
|
form = AuthenticationForm(request.POST)
|
||||||
username = request.POST['username']
|
username = request.POST['username']
|
||||||
|
@ -50,6 +50,7 @@ def login_page(request):
|
||||||
"user_list": userlist
|
"user_list": userlist
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def index(request):
|
def index(request):
|
||||||
context = {
|
context = {
|
||||||
|
@ -57,6 +58,7 @@ def index(request):
|
||||||
}
|
}
|
||||||
return render(request, "index.html", context)
|
return render(request, "index.html", context)
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def history(request):
|
def history(request):
|
||||||
context = {
|
context = {
|
||||||
|
@ -64,6 +66,7 @@ def history(request):
|
||||||
}
|
}
|
||||||
return render(request, "history.html", context)
|
return render(request, "history.html", context)
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def order(request, drinkid):
|
def order(request, drinkid):
|
||||||
try:
|
try:
|
||||||
|
@ -73,6 +76,7 @@ def order(request, drinkid):
|
||||||
except Drink.DoesNotExist:
|
except Drink.DoesNotExist:
|
||||||
return HttpResponseRedirect("/")
|
return HttpResponseRedirect("/")
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def deposit(request):
|
def deposit(request):
|
||||||
return render(request, "deposit.html", {})
|
return render(request, "deposit.html", {})
|
||||||
|
@ -80,32 +84,24 @@ def deposit(request):
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def statistics(request):
|
def statistics(request):
|
||||||
user = request.user
|
|
||||||
context = {
|
context = {
|
||||||
"orders_per_month": db_queries.select_orders_per_month(user),
|
"orders_per_month": db_queries.orders_per_month(request.user),
|
||||||
"orders_per_weekday": db_queries.select_orders_per_weekday(user),
|
"orders_per_weekday": db_queries.orders_per_weekday(request.user),
|
||||||
"orders_per_drink": db_queries.select_orders_per_drink(user),
|
"orders_per_drink": db_queries.orders_per_drink(request.user),
|
||||||
}
|
}
|
||||||
# Advanced statistics
|
|
||||||
if user.has_perm("app.view_order") or user.is_superuser:
|
|
||||||
context["order_sum_per_user"] = db_queries.select_order_sum_per_user_all_users()
|
|
||||||
if user.has_perm("app.view_registertransaction") or user.is_superuser:
|
|
||||||
context["deposit_sum_per_user"] = db_queries.select_deposit_sum_per_user_all_users()
|
|
||||||
return render(request, "statistics.html", context)
|
return render(request, "statistics.html", context)
|
||||||
|
|
||||||
@login_required
|
|
||||||
def transfer(request):
|
|
||||||
userlist = get_user_model().objects.filter(hide_from_userlist=False).filter(is_active=True).order_by("username")
|
|
||||||
return render(request, "transfer.html", {"user_list": userlist})
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def supply(request):
|
def supply(request):
|
||||||
return render(request, "supply.html")
|
return render(request, "supply.html")
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def redirect_home(request):
|
def redirect_home(request):
|
||||||
return HttpResponseRedirect("/")
|
return HttpResponseRedirect("/")
|
||||||
|
|
||||||
|
|
||||||
# API for XHR requests #
|
# API for XHR requests #
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
|
@ -127,6 +123,7 @@ def api_order_drink(request):
|
||||||
print(f"An exception occured while processing an order: User: {user.username} - Exception: {e}", file=sys.stderr)
|
print(f"An exception occured while processing an order: User: {user.username} - Exception: {e}", file=sys.stderr)
|
||||||
return HttpResponse(b"", status=500)
|
return HttpResponse(b"", status=500)
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def api_deposit(request):
|
def api_deposit(request):
|
||||||
# check request -> deposit
|
# check request -> deposit
|
||||||
|
@ -143,35 +140,9 @@ def api_deposit(request):
|
||||||
return HttpResponse("success", status=200)
|
return HttpResponse("success", status=200)
|
||||||
else: raise Exception("Deposit amount too big or small.")
|
else: raise Exception("Deposit amount too big or small.")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"An exception occured while processing a deposit transaction: User: {user.username} - Exception: {e}", file=sys.stderr)
|
print(f"An exception occured while processing a transaction: User: {user.username} - Exception: {e}", file=sys.stderr)
|
||||||
return HttpResponse(b"", status=500)
|
return HttpResponse(b"", status=500)
|
||||||
|
|
||||||
@login_required
|
|
||||||
def api_transfer(request):
|
|
||||||
# check request -> transfer
|
|
||||||
user = request.user
|
|
||||||
try:
|
|
||||||
recipient = get_user_model().objects.get(id=int(request.POST["recipientuser"]))
|
|
||||||
if recipient.id == user.id:
|
|
||||||
raise Exception(f"User {user.username} tried to transfer to themself.")
|
|
||||||
amount = decimal.Decimal(request.POST["transferamount"])
|
|
||||||
if 0.00 < amount <= user.balance:
|
|
||||||
# create transaction
|
|
||||||
RegisterTransaction.objects.create(
|
|
||||||
transaction_sum=-amount,
|
|
||||||
comment=f"Transfer to {recipient.username}",
|
|
||||||
is_transfer=True,
|
|
||||||
user=user)
|
|
||||||
RegisterTransaction.objects.create(
|
|
||||||
transaction_sum=amount,
|
|
||||||
comment=f"Transfer from {user.username}",
|
|
||||||
is_transfer=True,
|
|
||||||
user=recipient)
|
|
||||||
return HttpResponse("success", status=200)
|
|
||||||
else: raise Exception("Transfer amount too big or small.")
|
|
||||||
except Exception as e:
|
|
||||||
print(f"An exception occured while processing a transfer transaction: User: {user.username} - Exception: {e}", file=sys.stderr)
|
|
||||||
return HttpResponse(b"", status=500)
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def api_supply(request):
|
def api_supply(request):
|
||||||
|
|
|
@ -9,8 +9,7 @@
|
||||||
|
|
||||||
{$CADDY_HOSTS} {
|
{$CADDY_HOSTS} {
|
||||||
# the tls certificates
|
# the tls certificates
|
||||||
# tls {$DATADIR}/tls/server.pem {$DATADIR}/tls/server-key.pem
|
tls {$DATADIR}/tls/server.pem {$DATADIR}/tls/server-key.pem
|
||||||
tls internal
|
|
||||||
route {
|
route {
|
||||||
# profile pictures
|
# profile pictures
|
||||||
file_server /profilepictures/* {
|
file_server /profilepictures/* {
|
||||||
|
@ -18,11 +17,7 @@
|
||||||
}
|
}
|
||||||
# static files
|
# static files
|
||||||
file_server /static/* {
|
file_server /static/* {
|
||||||
root {$ROOTDIR}
|
root {$DATADIR}/static/..
|
||||||
}
|
|
||||||
# django static files
|
|
||||||
file_server /django_static/* {
|
|
||||||
root {$DATADIR}/django_static/..
|
|
||||||
}
|
}
|
||||||
# favicon
|
# favicon
|
||||||
redir /favicon.ico /static/favicon.ico
|
redir /favicon.ico /static/favicon.ico
|
||||||
|
|
|
@ -1 +1,28 @@
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" fill="#fff" height="48" viewBox="0 96 960 960" width="48"><path d="M222 801q63-40 124.5-60.5T480 720q72 0 134 20.5T739 801q44-54 62.5-109T820 576q0-145-97.5-242.5T480 236q-145 0-242.5 97.5T140 576q0 61 19 116t63 109Zm257.814-195Q422 606 382.5 566.314q-39.5-39.686-39.5-97.5t39.686-97.314q39.686-39.5 97.5-39.5t97.314 39.686q39.5 39.686 39.5 97.5T577.314 566.5q-39.686 39.5-97.5 39.5Zm-.219 370q-83.146 0-156.275-31.5t-127.225-86Q142 804 111 731.159 80 658.319 80 575.5q0-82.819 31.5-155.659Q143 347 197.5 293t127.341-85.5Q397.681 176 480.5 176q82.819 0 155.659 31.5Q709 239 763 293t85.5 127Q880 493 880 575.734q0 82.734-31.5 155.5T763 858.5q-54 54.5-127.129 86T479.595 976Z"/></svg>
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||||
|
|
||||||
|
<svg
|
||||||
|
width="16"
|
||||||
|
height="16"
|
||||||
|
viewBox="0 0 16 16"
|
||||||
|
version="1.1"
|
||||||
|
id="svg5"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg">
|
||||||
|
<defs
|
||||||
|
id="defs2" />
|
||||||
|
<g
|
||||||
|
id="layer1">
|
||||||
|
<circle
|
||||||
|
style="fill:#808080;fill-opacity:1;stroke:#fffcfe;stroke-opacity:1"
|
||||||
|
id="path848"
|
||||||
|
cx="8"
|
||||||
|
cy="4.5"
|
||||||
|
r="2.5" />
|
||||||
|
<path
|
||||||
|
style="fill:#7f7f7f;fill-opacity:1;stroke:#fffcff;stroke-opacity:1"
|
||||||
|
id="path3433"
|
||||||
|
d="m -3,-13.499699 a 5,5 0 0 1 -2.5,4.3301274 5,5 0 0 1 -5,0 5,5 0 0 1 -2.5,-4.3301274 h 5 z"
|
||||||
|
transform="scale(-1)" />
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
|
Before Width: | Height: | Size: 722 B After Width: | Height: | Size: 740 B |
|
@ -149,8 +149,8 @@ LOCALE_PATHS = [
|
||||||
# Static files (CSS, JavaScript, Images)
|
# Static files (CSS, JavaScript, Images)
|
||||||
# https://docs.djangoproject.com/en/4.1/howto/static-files/
|
# https://docs.djangoproject.com/en/4.1/howto/static-files/
|
||||||
|
|
||||||
STATIC_URL = "django_static/"
|
STATIC_URL = "static/"
|
||||||
STATIC_ROOT = BASE_DIR / "data" / "django_static"
|
STATIC_ROOT = BASE_DIR / "data" / "static"
|
||||||
|
|
||||||
# Default primary key field type
|
# Default primary key field type
|
||||||
# https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field
|
# https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
Django~=4.2
|
Django~=4.1
|
||||||
psycopg2~=2.9
|
psycopg2~=2.9.5
|
||||||
uvicorn[standard]~=0.27
|
uvicorn~=0.20.0
|
||||||
PyYAML~=6.0
|
PyYAML~=6.0
|
||||||
|
|
|
@ -14,17 +14,6 @@ from time import sleep
|
||||||
from yaml import safe_load
|
from yaml import safe_load
|
||||||
|
|
||||||
|
|
||||||
banner = r""" ___ _ _
|
|
||||||
| \ _ _ (_) _ _ | |__ ___ ___
|
|
||||||
| |) || '_|| || ' \ | / /(_-< |___|
|
|
||||||
|___/ |_| |_||_||_||_\_\/__/
|
|
||||||
__ __ Version {version}
|
|
||||||
| \/ | __ _ _ _ __ _ __ _ ___ _ _
|
|
||||||
| |\/| |/ _` || ' \ / _` |/ _` |/ -_)| '_|
|
|
||||||
|_| |_|\__,_||_||_|\__,_|\__, |\___||_|
|
|
||||||
|___/
|
|
||||||
"""
|
|
||||||
|
|
||||||
base_directory = Path(__file__).parent.parent
|
base_directory = Path(__file__).parent.parent
|
||||||
data_directory = base_directory / "data"
|
data_directory = base_directory / "data"
|
||||||
logfile_directory = data_directory / "logs"
|
logfile_directory = data_directory / "logs"
|
||||||
|
@ -32,7 +21,6 @@ configuration_file = data_directory / "config.yml"
|
||||||
caddyfile = data_directory / "Caddyfile"
|
caddyfile = data_directory / "Caddyfile"
|
||||||
logfile_caddy = logfile_directory / "caddy.log"
|
logfile_caddy = logfile_directory / "caddy.log"
|
||||||
logfile_app = logfile_directory / "app.log"
|
logfile_app = logfile_directory / "app.log"
|
||||||
logfile_sessioncleanup = logfile_directory / "session-cleanup.log"
|
|
||||||
|
|
||||||
|
|
||||||
class MonitoredSubprocess:
|
class MonitoredSubprocess:
|
||||||
|
@ -91,8 +79,6 @@ def cleanup_procs(processes):
|
||||||
|
|
||||||
|
|
||||||
def start_and_monitor(monitored_subprocesses: list):
|
def start_and_monitor(monitored_subprocesses: list):
|
||||||
# display banner
|
|
||||||
print(banner.format(version=os.environ["APP_VERSION"]))
|
|
||||||
# start processes
|
# start processes
|
||||||
for p in monitored_subprocesses:
|
for p in monitored_subprocesses:
|
||||||
p.try_start()
|
p.try_start()
|
||||||
|
@ -131,7 +117,6 @@ if __name__ == "__main__":
|
||||||
["./venv/bin/python3", "./manage.py", "migrate", "--noinput"], env=os.environ).wait()
|
["./venv/bin/python3", "./manage.py", "migrate", "--noinput"], env=os.environ).wait()
|
||||||
# Caddy configuration via env
|
# Caddy configuration via env
|
||||||
environment_caddy = os.environ
|
environment_caddy = os.environ
|
||||||
environment_caddy["ROOTDIR"] = str(base_directory.absolute())
|
|
||||||
environment_caddy["DATADIR"] = str(data_directory.absolute())
|
environment_caddy["DATADIR"] = str(data_directory.absolute())
|
||||||
environment_caddy["CADDY_HOSTS"] = ", ".join(config["caddy"]["hosts"])
|
environment_caddy["CADDY_HOSTS"] = ", ".join(config["caddy"]["hosts"])
|
||||||
environment_caddy["HTTP_PORT"] = str(config["caddy"]["http_port"])
|
environment_caddy["HTTP_PORT"] = str(config["caddy"]["http_port"])
|
||||||
|
@ -185,6 +170,6 @@ if __name__ == "__main__":
|
||||||
MonitoredSubprocess(
|
MonitoredSubprocess(
|
||||||
"Session Autocleaner",
|
"Session Autocleaner",
|
||||||
["./scripts/_session-autocleaner.py", str(config["app"]["session_clear_interval"])],
|
["./scripts/_session-autocleaner.py", str(config["app"]["session_clear_interval"])],
|
||||||
logfile_sessioncleanup)
|
logfile_app)
|
||||||
]
|
]
|
||||||
start_and_monitor(procs)
|
start_and_monitor(procs)
|
||||||
|
|
2
start.sh
|
@ -11,6 +11,6 @@ chmod -c -R g-w,o-rwx .gitignore
|
||||||
|
|
||||||
export PYTHONPATH="$basedir"
|
export PYTHONPATH="$basedir"
|
||||||
export DJANGO_SETTINGS_MODULE="project.settings"
|
export DJANGO_SETTINGS_MODULE="project.settings"
|
||||||
export APP_VERSION="22"
|
export APP_VERSION="15"
|
||||||
|
|
||||||
exec ./scripts/_bootstrap.py "$@"
|
exec ./scripts/_bootstrap.py "$@"
|
||||||
|
|
|
@ -1,21 +0,0 @@
|
||||||
document.addEventListener("DOMContentLoaded", () => {
|
|
||||||
let dropdownmenuElement = document.getElementById("dropdownmenu");
|
|
||||||
let dropdownmenuButtonElement = document.getElementById("dropdownmenu-button");
|
|
||||||
let dropdownmenuNopeElement = document.getElementById("dropdownnope");
|
|
||||||
function toggleDropDown() {
|
|
||||||
if (dropdownmenuElement.classList.contains("dropdownvisible")) {
|
|
||||||
dropdownmenuElement.classList.remove("dropdownvisible");
|
|
||||||
dropdownmenuNopeElement.classList.remove("dropdownvisible");
|
|
||||||
} else {
|
|
||||||
dropdownmenuElement.classList.add("dropdownvisible");
|
|
||||||
dropdownmenuNopeElement.classList.add("dropdownvisible");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (dropdownmenuButtonElement != null) {
|
|
||||||
dropdownmenuButtonElement.addEventListener("click", toggleDropDown);
|
|
||||||
dropdownmenuNopeElement.addEventListener("click", () => {
|
|
||||||
dropdownmenuElement.classList.remove("dropdownvisible");
|
|
||||||
dropdownmenuNopeElement.classList.remove("dropdownvisible");
|
|
||||||
})
|
|
||||||
}
|
|
||||||
});
|
|
|
@ -1 +0,0 @@
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" fill="#fff" height="48" viewBox="0 96 960 960" width="48"><path d="M480 696 280 497h400L480 696Z"/></svg>
|
|
Before Width: | Height: | Size: 145 B |
|
@ -1 +0,0 @@
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" fill="#fff" height="48" viewBox="0 96 960 960" width="48"><path d="M115.935 822.696v-68.131h728.13v68.131h-728.13Zm0-212.631v-68.13h728.13v68.13h-728.13Zm0-212.63v-68.37h728.13v68.37h-728.13Z"/></svg>
|
|
Before Width: | Height: | Size: 240 B |