modify accounting model
This commit is contained in:
parent
a8b9e7e61e
commit
3a49658f21
@ -2,25 +2,7 @@ from billard.models import *
|
||||
from rest_framework import serializers
|
||||
|
||||
|
||||
class ClientSerializer(serializers.HyperlinkedModelSerializer):
|
||||
class Meta:
|
||||
#model = Client
|
||||
fields = ('id', 'location',)
|
||||
|
||||
|
||||
class LocationSerializer(serializers.HyperlinkedModelSerializer):
|
||||
class Meta:
|
||||
#model = Location
|
||||
fields = ('name',)
|
||||
|
||||
|
||||
class TableSerializer(serializers.HyperlinkedModelSerializer):
|
||||
class Meta:
|
||||
#model = Table
|
||||
fields = ('client', 'number', 'name',)
|
||||
|
||||
|
||||
class LocationDataSerializer(serializers.HyperlinkedModelSerializer):
|
||||
class Meta:
|
||||
model = LocationData
|
||||
fields = ('location_id', 'table_no', 'tst', 'on_off',)
|
||||
fields = ('client_id', 'desk_no', 'tst', 'on_off',)
|
||||
|
@ -36,7 +36,8 @@ def display_client(client, desk_no):
|
||||
for a in acc:
|
||||
html += ' <tr>\n'
|
||||
html += ' <td>{}</td>\n'.format(a.time_from.strftime('%d.%m.%Y %H:%M:%S'))
|
||||
html += ' <td>{}</td>\n'.format((a.time_to if a.time_to is not None else ''))
|
||||
html += ' <td>{}</td>\n'.format(
|
||||
(a.time_to.strftime('%d.%m.%Y %H:%M:%S') if a.time_to is not None else ''))
|
||||
html += ' <td style="text-align: center;">{}</td>\n'\
|
||||
.format((a.prize if a.prize is not None else ''))
|
||||
html += ' <tr>\n'
|
||||
|
@ -3,9 +3,6 @@ from rest_framework import routers
|
||||
from billard import views
|
||||
|
||||
router = routers.DefaultRouter()
|
||||
router.register(r'clients', views.ClientViewSet)
|
||||
router.register(r'locations', views.LocationViewSet)
|
||||
router.register(r'tables', views.TableViewSet)
|
||||
router.register(r'location_data', views.LocationDataViewSet)
|
||||
|
||||
urlpatterns = [
|
||||
|
@ -8,21 +8,6 @@ from django.contrib.auth.decorators import login_required
|
||||
from django.db.models import Min
|
||||
|
||||
|
||||
class ClientViewSet(viewsets.ModelViewSet):
|
||||
queryset = LocationData.objects.all()
|
||||
serializer_class = ClientSerializer
|
||||
|
||||
|
||||
class LocationViewSet(viewsets.ModelViewSet):
|
||||
queryset = LocationData.objects.all()
|
||||
serializer_class = LocationSerializer
|
||||
|
||||
|
||||
class TableViewSet(viewsets.ModelViewSet):
|
||||
queryset = LocationData.objects.all()
|
||||
serializer_class = TableSerializer
|
||||
|
||||
|
||||
class LocationDataViewSet(viewsets.ModelViewSet):
|
||||
queryset = LocationData.objects.all()
|
||||
serializer_class = LocationDataSerializer
|
||||
|
@ -6,17 +6,19 @@ import requests
|
||||
|
||||
|
||||
url = 'http://127.0.0.1:8000/billard/api/v1/location_data/'
|
||||
token = '7fdc4e8fbe2508b70f73c65c2d05475632e2388a'
|
||||
client_id = '28a34fa1-7b62-4b78-8d2a-ada4db4ac6ea'
|
||||
token = '588d0f4c4b8b90b507e6d5c0ea26f0e28b021262'
|
||||
default_desk_id = 2
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--on', action="store_true", help="on or of the switch")
|
||||
parser.add_argument('--date', default=datetime.now(), help="the tst to set")
|
||||
parser.add_argument('--desk', default=1, help="the desk number")
|
||||
parser.add_argument('--desk', default=default_desk_id, help="the desk number")
|
||||
args = parser.parse_args()
|
||||
payload = {
|
||||
'location_id': 'a7b47b4b-5b63-3b2f-8af0-4b185843f419',
|
||||
'client_id': client_id,
|
||||
'desk_no': args.desk,
|
||||
'tst': args.date.strftime('%Y-%m-%dT%H:%M:%S%Z')
|
||||
}
|
||||
@ -29,6 +31,8 @@ def main():
|
||||
r = requests.post(url=url,
|
||||
data=payload,
|
||||
headers=headers)
|
||||
print(r.status_code)
|
||||
print(r.text)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
Loading…
Reference in New Issue
Block a user