Merge pull request #147 from ZeusWPI/first-party-and-no-test-notis

First party and no test notis
This commit is contained in:
zeuswpi-bot 2019-10-03 17:40:57 +02:00 committed by GitHub
commit 0daea7d270
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 73 additions and 32 deletions

3
.gitignore vendored
View file

@ -2,6 +2,9 @@
__pycache__/ __pycache__/
*.pyc *.pyc
# Static type checker cache
.mypy_cache/
# C extensions # C extensions
*.so *.so

View file

@ -51,7 +51,7 @@ Finally run the webserver with
### Adding dependencies/libraries ### Adding dependencies/libraries
1. Add new dependency to the `requirements.in` file 1. Add new dependency to the `requirements.in` file
2. Run `pip-compile` to freeze the dependency into the `requirements.txt` file together with it's own deps 2. Run `pip-compile` to freeze the dependency into the `requirements.txt` file together with its own deps
3. Run `pip-sync` to download frozen deps 3. Run `pip-sync` to download frozen deps
### Updating dependencies ### Updating dependencies

View file

@ -0,0 +1,24 @@
from app import db
from models import Location, Product
STUFFS = [
("Broodje zever", 540),
("Broodje aap", 0),
("Broodje goud", 500000),
]
def add() -> None:
testlocation = Location()
testlocation.configure(
"Testlocation",
"Please ignore!",
"0469 69 69 69",
"http://localhost:8000/",
)
db.session.add(testlocation)
for stuff in STUFFS:
entry = Product()
entry.configure(testlocation, *stuff)
db.session.add(entry)

View file

@ -3,18 +3,20 @@ import add_fitchen
import add_oceans_garden import add_oceans_garden
import add_primadonna import add_primadonna
import add_simpizza import add_simpizza
import add_testlocation
from app import db, create_app from app import db, create_app
entry_sets = { entry_sets = {
"Admins": add_admins.add, "Admins": add_admins.add,
"Testlocation": add_testlocation.add,
"Ocean's Garden": add_oceans_garden.add, "Ocean's Garden": add_oceans_garden.add,
"SimPizza": add_simpizza.add, "SimPizza": add_simpizza.add,
"Primadonna": add_primadonna.add, "Primadonna": add_primadonna.add,
"Fitchen": add_fitchen.add, "Fitchen": add_fitchen.add,
} }
yes = ["yes", "y", "Y"] yes = ["yes", "y"]
no = ["no", "n", "N"] no = ["no", "n"]
# Commit all the things # Commit all the things
@ -25,7 +27,7 @@ def commit() -> None:
def check_if_overwrite() -> bool: def check_if_overwrite() -> bool:
answer = input("Do you want to overwrite the previous database? (y/N) ") answer = input("Do you want to overwrite the previous database? (y/N) ")
return answer in yes return answer.lower() in yes
def add_all() -> None: def add_all() -> None:
@ -37,11 +39,13 @@ def add_all() -> None:
def recreate_from_scratch() -> None: def recreate_from_scratch() -> None:
confirmation = "Are you very very sure? (Will delete previous entries!) (y/N) " confirmation = "Are you very very sure? (Will delete previous entries!) (y/N) "
check = "I acknowledge any repercussions!" check = "I acknowledge any repercussions!"
if input(confirmation) in yes and input("Type: '{}' ".format(check)) == check: if input(confirmation).lower() in yes and input("Type: '{}' ".format(check)).lower() == check:
print("Resetting the database!") print("Resetting the database!")
db.drop_all() db.drop_all()
db.create_all() db.create_all()
add_to_current() add_to_current()
else:
print("You cancelled.")
def add_to_current() -> None: def add_to_current() -> None:
@ -52,15 +56,15 @@ def add_to_current() -> None:
["{}({}), ".format(loc, i) for i, loc in enumerate(available)] ["{}({}), ".format(loc, i) for i, loc in enumerate(available)]
).rstrip(", ") ).rstrip(", ")
while input("Do you still want to add something? (Y/n) ") not in no: while input("Do you still want to add something? (Y/n) ").lower() not in no:
print( print(
"What do you want to add? (Use numbers, or A for all, or C for cancel) " "What do you want to add? (Use numbers, or A for all, or C for cancel) "
) )
answer = input("Available: {} : ".format(add_numbers())) answer = input("Available: {} : ".format(add_numbers()))
if answer == "A": if answer.lower() == "a":
add_all() add_all()
available = [] available = []
elif answer == "C": elif answer.lower() == "c":
pass pass
elif answer.isnumeric() and answer in [str(x) for x in range(len(available))]: elif answer.isnumeric() and answer in [str(x) for x in range(len(available))]:
answer_index = int(answer) answer_index = int(answer)

View file

@ -1,29 +1,38 @@
import json import json
import typing
from datetime import datetime from datetime import datetime
from threading import Thread from threading import Thread
import requests import requests
from flask import current_app as app from flask import current_app as app
from flask import url_for from flask import url_for
from models.order import Order
def post_order_to_webhook(order_item) -> None: def webhook_text(order_item: Order) -> typing.Optional[str]:
message = "" if "Testlocation" in order_item.location.name:
return None
if order_item.courrier is not None: if order_item.courrier is not None:
message = "<!channel|@channel> {3} is going to {1}, order <{0}|here>! Deadline in {2} minutes!".format( return "<!channel|@channel> {3} is going to {1}, order <{0}|here>! Deadline in {2} minutes!".format(
url_for("order_bp.order", id=order_item.id, _external=True), url_for("order_bp.order", id=order_item.id, _external=True),
order_item.location.name, order_item.location.name,
remaining_minutes(order_item.stoptime), remaining_minutes(order_item.stoptime),
order_item.courrier.username.title(), order_item.courrier.username.title(),
) )
else:
message = "<!channel|@channel> New order for {}. Deadline in {} minutes. <{}|Open here.>".format( return "<!channel|@channel> New order for {}. Deadline in {} minutes. <{}|Open here.>".format(
order_item.location.name, order_item.location.name,
remaining_minutes(order_item.stoptime), remaining_minutes(order_item.stoptime),
url_for("order_bp.order", id=order_item.id, _external=True), url_for("order_bp.order", id=order_item.id, _external=True),
) )
webhookthread = WebhookSenderThread(message, app.config["SLACK_WEBHOOK"])
webhookthread.start()
def post_order_to_webhook(order_item: Order) -> None:
message = webhook_text(order_item)
if message:
webhookthread = WebhookSenderThread(message, app.config["SLACK_WEBHOOK"])
webhookthread.start()
class WebhookSenderThread(Thread): class WebhookSenderThread(Thread):

View file

@ -1,4 +1,3 @@
@import url("//fonts.googleapis.com/css?family=Roboto:300,400,500,700");
/*! /*!
* bootswatch v3.3.4+1 * bootswatch v3.3.4+1
* Homepage: http://bootswatch.com * Homepage: http://bootswatch.com

File diff suppressed because one or more lines are too long

1
app/static/css/select2.min.css vendored Normal file

File diff suppressed because one or more lines are too long

2
app/static/js/select2.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View file

@ -142,13 +142,13 @@
{% block styles %} {% block styles %}
{{ super() }} {{ super() }}
<link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.0/css/select2.min.css" rel="stylesheet" /> <link rel="stylesheet" href="{{ url_for('static', filename='css/select2.min.css') }}" />
<link rel="stylesheet" href="{{ url_for('static', filename='css/select2-bootstrap.min.css') }}"> <link rel="stylesheet" href="{{ url_for('static', filename='css/select2-bootstrap.min.css') }}">
<link rel="stylesheet" href="{{ url_for('static', filename='css/print.css') }}"> <link rel="stylesheet" href="{{ url_for('static', filename='css/print.css') }}">
{% endblock %} {% endblock %}
{% block scripts %} {% block scripts %}
{{ super() }} {{ super() }}
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.0/js/select2.min.js"></script> <script src="{{ url_for('static', filename='js/select2.min.js') }}"></script>
<script type="text/javascript"> <script type="text/javascript">
var select = $('.select').select2({ var select = $('.select').select2({
'sorter': function(results) { 'sorter': function(results) {

View file

@ -59,13 +59,13 @@
{% block styles -%} {% block styles -%}
{{ super() }} {{ super() }}
<link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.0-rc.2/css/select2.min.css" rel="stylesheet" /> <link rel="stylesheet" href="{{ url_for('static', filename='css/select2.min.css') }}" />
<link rel="stylesheet" href="{{ url_for('static', filename='css/bootstrap-datetimepicker.min.css') }}"> <link rel="stylesheet" href="{{ url_for('static', filename='css/bootstrap-datetimepicker.min.css') }}" />
<link rel="stylesheet" href="{{ url_for('static', filename='css/select2-bootstrap.min.css') }}"> <link rel="stylesheet" href="{{ url_for('static', filename='css/select2-bootstrap.min.css') }}" />
{%- endblock %} {%- endblock %}
{% block scripts -%} {% block scripts -%}
{{ super() }} {{ super() }}
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.0-rc.2/js/select2.min.js"></script> <script src="{{ url_for('static', filename='js/select2.min.js') }}"></script>
<script src="{{ url_for('static', filename='js/moment.min.js') }}"></script> <script src="{{ url_for('static', filename='js/moment.min.js') }}"></script>
<script src="{{ url_for('static', filename='js/bootstrap-datetimepicker.min.js') }}"></script> <script src="{{ url_for('static', filename='js/bootstrap-datetimepicker.min.js') }}"></script>
<script type="text/javascript"> <script type="text/javascript">

View file

@ -74,13 +74,13 @@
{% block styles -%} {% block styles -%}
{{ super() }} {{ super() }}
<link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.0-rc.2/css/select2.min.css" rel="stylesheet" /> <link rel="stylesheet" href="{{ url_for('static', filename='css/select2.min.css') }}" />
<link rel="stylesheet" href="{{ url_for('static', filename='css/bootstrap-datetimepicker.min.css') }}"> <link rel="stylesheet" href="{{ url_for('static', filename='css/bootstrap-datetimepicker.min.css') }}" />
<link rel="stylesheet" href="{{ url_for('static', filename='css/select2-bootstrap.min.css') }}"> <link rel="stylesheet" href="{{ url_for('static', filename='css/select2-bootstrap.min.css') }}" />
{%- endblock %} {%- endblock %}
{% block scripts -%} {% block scripts -%}
{{ super() }} {{ super() }}
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.0-rc.2/js/select2.min.js"></script> <script src="{{ url_for('static', filename='js/select2.min.js') }}"></script>
<script src="{{ url_for('static', filename='js/moment.min.js') }}"></script> <script src="{{ url_for('static', filename='js/moment.min.js') }}"></script>
<script src="{{ url_for('static', filename='js/bootstrap-datetimepicker.min.js') }}"></script> <script src="{{ url_for('static', filename='js/bootstrap-datetimepicker.min.js') }}"></script>
<script type="text/javascript"> <script type="text/javascript">