fetchphones progress
This commit is contained in:
parent
731b4be077
commit
490b82db0d
5 changed files with 33 additions and 11 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -63,3 +63,5 @@ target/
|
||||||
# Virtualenv
|
# Virtualenv
|
||||||
bin/
|
bin/
|
||||||
pyvenv.cfg
|
pyvenv.cfg
|
||||||
|
|
||||||
|
*/migrations/*
|
||||||
|
|
21
.vscode/launch.json
vendored
Normal file
21
.vscode/launch.json
vendored
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
{
|
||||||
|
// Use IntelliSense to learn about possible attributes.
|
||||||
|
// Hover to view descriptions of existing attributes.
|
||||||
|
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
|
||||||
|
{
|
||||||
|
"name": "Python: Django",
|
||||||
|
"type": "python",
|
||||||
|
"request": "launch",
|
||||||
|
//"python": "/home/francesco/Code/suitablephones/",
|
||||||
|
"program": "${workspaceFolder}/manage.py",
|
||||||
|
"args": [
|
||||||
|
"fetchphones"
|
||||||
|
],
|
||||||
|
"django": true,
|
||||||
|
"justMyCode": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -26,16 +26,15 @@ class Command(BaseCommand):
|
||||||
dev = Device()
|
dev = Device()
|
||||||
for key, value in data.items():
|
for key, value in data.items():
|
||||||
if key == "bluetooth":
|
if key == "bluetooth":
|
||||||
bt = Bluetooth.objects.filter(*value.items())
|
bt = Bluetooth.objects.filter(**value)
|
||||||
if not bt.exists():
|
if not bt.exists():
|
||||||
bt = Bluetooth()
|
bt = Bluetooth()
|
||||||
for subkey, subvalue in value.items():
|
for subkey, subvalue in value.items():
|
||||||
bt
|
setattr(bt, subkey, subvalue)
|
||||||
for subkey, subvalue in value.items():
|
bt.save()
|
||||||
#logging.warning(type(subkey))
|
#for subkey, subvalue in value.items():
|
||||||
#logging.warning(subkey)
|
# setattr(bt, subkey, subvalue)
|
||||||
#print(type(subvalue) + subvalue)
|
# bt.save()
|
||||||
setattr(bt, subkey, subvalue)
|
|
||||||
# elif key == "cameras":
|
# elif key == "cameras":
|
||||||
# cam = []
|
# cam = []
|
||||||
# for c in Camera.objects.filter(*value.items())
|
# for c in Camera.objects.filter(*value.items())
|
||||||
|
|
|
@ -5,10 +5,10 @@ from django.db import models
|
||||||
|
|
||||||
class Bluetooth(models.Model):
|
class Bluetooth(models.Model):
|
||||||
spec = models.CharField(max_length=100)
|
spec = models.CharField(max_length=100)
|
||||||
profile = models.CharField(max_length=100)
|
profiles = models.CharField(max_length=100)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return f"Bluetooth: {self.spec}"
|
return f"Bluetooth: {self.spec - self.profiles}"
|
||||||
|
|
||||||
|
|
||||||
class Camera(models.Model):
|
class Camera(models.Model):
|
||||||
|
@ -30,7 +30,7 @@ class Device(models.Model):
|
||||||
architecture = models.CharField(max_length=100)
|
architecture = models.CharField(max_length=100)
|
||||||
#before_install = <class 'dict'>
|
#before_install = <class 'dict'>
|
||||||
bluetooth = models.ForeignKey(Bluetooth, on_delete=models.CASCADE)
|
bluetooth = models.ForeignKey(Bluetooth, on_delete=models.CASCADE)
|
||||||
cameras = models.ManyToManyField(Camera)
|
#cameras = models.ManyToManyField(Camera)
|
||||||
cpu = models.CharField(max_length=100)
|
cpu = models.CharField(max_length=100)
|
||||||
codename = models.CharField(max_length=100)
|
codename = models.CharField(max_length=100)
|
||||||
cpu_cores = models.CharField(max_length=100)
|
cpu_cores = models.CharField(max_length=100)
|
||||||
|
|
|
@ -6,7 +6,7 @@ from suitablephones.views import BluetoothViewSet, CameraViewSet, DeviceViewSet
|
||||||
router = routers.DefaultRouter()
|
router = routers.DefaultRouter()
|
||||||
router.register(r'devices', DeviceViewSet)
|
router.register(r'devices', DeviceViewSet)
|
||||||
router.register(r'bluetooth', BluetoothViewSet)
|
router.register(r'bluetooth', BluetoothViewSet)
|
||||||
router.register(r'camera', CameraViewSet)
|
#router.register(r'camera', CameraViewSet)
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('api/', include(router.urls)),
|
path('api/', include(router.urls)),
|
||||||
|
|
Loading…
Reference in a new issue