update data model

This commit is contained in:
Robert Einsle 2017-02-01 13:51:15 +01:00
parent 96dc601542
commit 616fd63bfc
10 changed files with 114 additions and 122 deletions

View File

@ -4,22 +4,17 @@ from .models import *
@admin.register(Location)
class LocationAdmin(admin.ModelAdmin):
list_display = ('name',)
pass
list_display = ('code', 'name', 'city',)
fields = ['code', 'name', 'street', 'plz', 'city', 'phone', 'email', 'url', ]
@admin.register(Client)
class ClientAdmin(admin.ModelAdmin):
pass
@admin.register(Table)
class TableAdmin(admin.ModelAdmin):
pass
list_display = ('desk1_name', 'desk2_name')
fields = ['location', 'desk1_enable', 'desk1_name', 'desk1_prize_nt', 'desk1_prize_ht', 'desk2_enable', 'desk2_name', 'desk2_prize_nt', 'desk2_prize_ht', ]
@admin.register(LocationData)
class LocationDataAdmin(admin.ModelAdmin):
list_display = ('location_id', 'table_no', 'tst', 'on_off', 'processed', 'error_msg')
fields = ['location_id', 'table_no', 'tst', 'on_off', 'processed', 'error_msg']
pass

View File

@ -1,9 +1,8 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.4 on 2017-01-03 18:28
# Generated by Django 1.10.5 on 2017-02-01 10:50
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
@ -15,30 +14,15 @@ class Migration(migrations.Migration):
operations = [
migrations.CreateModel(
name='Client',
fields=[
('id', models.UUIDField(editable=False, primary_key=True, serialize=False)),
],
),
migrations.CreateModel(
name='Location',
name='LocationData',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=30, unique=True)),
('location_id', models.CharField(max_length=32)),
('table_no', models.IntegerField()),
('tst', models.DateTimeField()),
('on_off', models.BooleanField()),
('processed', models.BooleanField(default=False)),
('error_msg', models.CharField(blank=True, max_length=16000, null=True)),
],
),
migrations.CreateModel(
name='Table',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('number', models.IntegerField()),
('name', models.CharField(max_length=30)),
('client', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='billard.Client')),
],
),
migrations.AddField(
model_name='client',
name='location',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='billard.Location'),
),
]

View File

@ -0,0 +1,29 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.5 on 2017-02-01 12:43
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('billard', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='Location',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('code', models.CharField(max_length=16, unique=True)),
('name', models.CharField(max_length=64, unique=True)),
('street', models.CharField(blank=True, max_length=64, null=True)),
('plz', models.CharField(blank=True, max_length=8, null=True)),
('city', models.CharField(blank=True, max_length=64, null=True)),
('phone', models.CharField(blank=True, max_length=64, null=True)),
('email', models.EmailField(blank=True, max_length=254, null=True)),
('url', models.URLField(blank=True, null=True)),
],
),
]

View File

@ -1,25 +0,0 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.5 on 2017-01-06 19:24
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('billard', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='LocationData',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('location_id', models.CharField(max_length=32)),
('table_no', models.IntegerField()),
('tst', models.DateTimeField()),
('on_off', models.BooleanField()),
],
),
]

View File

@ -1,25 +0,0 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.5 on 2017-01-09 14:09
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('billard', '0002_locationdata'),
]
operations = [
migrations.AddField(
model_name='locationdata',
name='error_msg',
field=models.CharField(blank=True, max_length=16000, null=True),
),
migrations.AddField(
model_name='locationdata',
name='processed',
field=models.BooleanField(default=False),
),
]

View File

@ -0,0 +1,31 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.5 on 2017-02-01 12:48
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('billard', '0002_location'),
]
operations = [
migrations.CreateModel(
name='Client',
fields=[
('id', models.UUIDField(editable=False, primary_key=True, serialize=False)),
('desk1_enable', models.BooleanField()),
('desk1_name', models.CharField(blank=True, max_length=32, null=True)),
('desk1_prize_nt', models.DecimalField(blank=True, decimal_places=2, max_digits=4, null=True)),
('desk1_prize_ht', models.DecimalField(blank=True, decimal_places=2, max_digits=4, null=True)),
('desk2_enable', models.BooleanField()),
('desk2_name', models.CharField(blank=True, max_length=32, null=True)),
('desk2_prize_nt', models.DecimalField(blank=True, decimal_places=2, max_digits=4, null=True)),
('desk2_prize_ht', models.DecimalField(blank=True, decimal_places=2, max_digits=4, null=True)),
('location', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='billard.Location')),
],
),
]

View File

@ -1,39 +1,6 @@
from django.db import models
class Location(models.Model):
name = models.CharField(max_length=30, unique=True)
def __str__(self):
return self.name
def __unicode__(self):
return self.name
class Client(models.Model):
id = models.UUIDField(primary_key=True, editable=False)
location = models.ForeignKey(Location)
def __str__(self):
return self.name
def __unicode__(self):
return self.name
class Table(models.Model):
client = models.ForeignKey(Client)
number = models.IntegerField()
name = models.CharField(max_length=30)
def __str__(self):
return self.name
def __unicode__(self):
return self.name
class LocationData(models.Model):
location_id = models.CharField(max_length=32, blank=False, null=False)
table_no = models.IntegerField(blank=False, null=False)
@ -47,3 +14,39 @@ class LocationData(models.Model):
def __unicode__(self):
return str(self.location_id)
class Location(models.Model):
code = models.CharField(max_length=16, unique=True)
name = models.CharField(max_length=64, unique=True)
street = models.CharField(max_length=64, blank=True, null=True)
plz = models.CharField(max_length=8, blank=True, null=True)
city = models.CharField(max_length=64, blank=True, null=True)
phone = models.CharField(max_length=64, blank=True, null=True)
email = models.EmailField(blank=True, null=True)
url = models.URLField(blank=True,null=True)
def __str__(self):
return self.name
def __unicode__(self):
return self.name
class Client(models.Model):
id = models.UUIDField(primary_key=True, editable=False)
location = models.ForeignKey(Location)
desk1_enable = models.BooleanField()
desk1_name = models.CharField(max_length=32, blank=True, null=True)
desk1_prize_nt = models.DecimalField(max_digits=4, decimal_places=2, blank=True, null=True)
desk1_prize_ht = models.DecimalField(max_digits=4, decimal_places=2, blank=True, null=True)
desk2_enable = models.BooleanField()
desk2_name = models.CharField(max_length=32, blank=True, null=True)
desk2_prize_nt = models.DecimalField(max_digits=4, decimal_places=2, blank=True, null=True)
desk2_prize_ht = models.DecimalField(max_digits=4, decimal_places=2, blank=True, null=True)
def __str__(self):
return self.name
def __unicode__(self):
return self.name

View File

@ -4,19 +4,19 @@ from rest_framework import serializers
class ClientSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = Client
#model = Client
fields = ('id', 'location',)
class LocationSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = Location
#model = Location
fields = ('name',)
class TableSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = Table
#model = Table
fields = ('client', 'number', 'name',)

View File

@ -6,17 +6,17 @@ from django.views.generic.detail import DetailView
class ClientViewSet(viewsets.ModelViewSet):
queryset = Client.objects.all()
queryset = LocationData.objects.all()
serializer_class = ClientSerializer
class LocationViewSet(viewsets.ModelViewSet):
queryset = Location.objects.all()
queryset = LocationData.objects.all()
serializer_class = LocationSerializer
class TableViewSet(viewsets.ModelViewSet):
queryset = Table.objects.all()
queryset = LocationData.objects.all()
serializer_class = TableSerializer

0
manage.py Executable file → Normal file
View File