Check in current state

This commit is contained in:
Kumi 2020-02-01 15:05:10 +00:00
parent e87476b1f4
commit 196096a5ee
9 changed files with 32 additions and 11 deletions

View file

@ -1,6 +1,8 @@
from django.contrib import admin
from buyer.models import Card
# Register your models here.
class CardAdmin(admin.ModelAdmin):
list_display = ["number", "purchased", "delivered"]
ordering = ["delivered"]
admin.site.register(Card)
admin.site.register(Card, CardAdmin)

View file

@ -7,6 +7,7 @@ import random
from dbsettings.views import getValue
from buyer.models import Card
import time
from smsauth.views import sendSMS
def getCard(allow_buy=False):
unused = Card.objects.filter(delivered=None) # pylint: disable=E1101
@ -70,4 +71,8 @@ def buyCard():
time.sleep(15)
return Card()
return Card()
def sendStatus():
status = len(Card.objects.filter(delivered=None))
return sendSMS("A Paysafecard has been sold. There are %i remaining in stock." % status, getValue("buyer.recipient"))

View file

@ -1 +1 @@
Die Kartennummer lautet: {{ object.card.number }}
Die Kartennummer lautet: {{ object.card.number | stringformat:"016d" }}

View file

@ -7,7 +7,7 @@ from django.utils import timezone
from datetime import timedelta
from django.http import Http404
from smsauth.views import requestToken
from buyer.views import getCard
from buyer.views import getCard, sendStatus
from ledger.models import Payment
def makeCardURL(card):
@ -39,4 +39,5 @@ class CardView(LoginRequiredMixin, DetailView):
raise Http404()
obj.card.delivered = timezone.now()
obj.card.save()
sendStatus()
return obj

View file

@ -1,6 +1,15 @@
from django.contrib import admin
from ledger.models import Payment
from django.utils import timezone
# Register your models here.
def repay(modeladmin, request, queryset):
queryset.update(repayment=timezone.now())
admin.site.register(Payment)
repay.short_description = "Mark selected payments as repaid"
class PaymentAdmin(admin.ModelAdmin):
list_display = ["description", "amount", "date", "repayment"]
ordering = ["date"]
actions = [repay]
admin.site.register(Payment, PaymentAdmin)

View file

@ -1,3 +1,4 @@
selenium
bs4
twilio
django-bulk-admin

View file

@ -23,8 +23,8 @@ def useToken(token):
def requestToken():
token = generateToken()
storeToken(token)
return sendSMS("Bitte verwende diesen Code, um deine Bestellung zu bestätigen: %s" % token)
return sendSMS("Bitte verwende diesen Code, um deine Bestellung zu bestätigen: %s" % token, getValue("smsauth.recipient"))
def sendSMS(text):
def sendSMS(text, recipient):
client = Client(getValue("smsauth.twilio.sid"), getValue("smsauth.twilio.token"))
return client.messages.create(body=text, from_=getValue("smsauth.twilio.number"), to=getValue("smsauth.recipient"))
return client.messages.create(body=text, from_=getValue("smsauth.twilio.number"), to=recipient)

View file

@ -98,7 +98,7 @@ AUTH_PASSWORD_VALIDATORS = [
LANGUAGE_CODE = 'de-at'
TIME_ZONE = 'UTC'
TIME_ZONE = 'Europe/Vienna'
USE_I18N = True
@ -111,6 +111,7 @@ USE_TZ = True
# https://docs.djangoproject.com/en/2.2/howto/static-files/
STATIC_URL = '/static/'
STATIC_ROOT = '/var/www/html/static/'
# Custom settings for Susioma project

2
uwsgi.sh Executable file
View file

@ -0,0 +1,2 @@
#!/bin/bash
/usr/local/bin/uwsgi --http 127.0.0.1:8000 --module susioma.wsgi --uid 1001 --processes 8