fetchphones progress

This commit is contained in:
d0c 2023-01-11 16:58:18 +01:00
parent 731b4be077
commit 490b82db0d
5 changed files with 33 additions and 11 deletions

2
.gitignore vendored
View file

@ -63,3 +63,5 @@ target/
# Virtualenv
bin/
pyvenv.cfg
*/migrations/*

21
.vscode/launch.json vendored Normal file
View 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
}
]
}

View file

@ -26,16 +26,15 @@ class Command(BaseCommand):
dev = Device()
for key, value in data.items():
if key == "bluetooth":
bt = Bluetooth.objects.filter(*value.items())
bt = Bluetooth.objects.filter(**value)
if not bt.exists():
bt = Bluetooth()
for subkey, subvalue in value.items():
bt
for subkey, subvalue in value.items():
#logging.warning(type(subkey))
#logging.warning(subkey)
#print(type(subvalue) + subvalue)
setattr(bt, subkey, subvalue)
setattr(bt, subkey, subvalue)
bt.save()
#for subkey, subvalue in value.items():
# setattr(bt, subkey, subvalue)
# bt.save()
# elif key == "cameras":
# cam = []
# for c in Camera.objects.filter(*value.items())

View file

@ -5,10 +5,10 @@ from django.db import models
class Bluetooth(models.Model):
spec = models.CharField(max_length=100)
profile = models.CharField(max_length=100)
profiles = models.CharField(max_length=100)
def __str__(self):
return f"Bluetooth: {self.spec}"
return f"Bluetooth: {self.spec - self.profiles}"
class Camera(models.Model):
@ -30,7 +30,7 @@ class Device(models.Model):
architecture = models.CharField(max_length=100)
#before_install = <class 'dict'>
bluetooth = models.ForeignKey(Bluetooth, on_delete=models.CASCADE)
cameras = models.ManyToManyField(Camera)
#cameras = models.ManyToManyField(Camera)
cpu = models.CharField(max_length=100)
codename = models.CharField(max_length=100)
cpu_cores = models.CharField(max_length=100)

View file

@ -6,7 +6,7 @@ from suitablephones.views import BluetoothViewSet, CameraViewSet, DeviceViewSet
router = routers.DefaultRouter()
router.register(r'devices', DeviceViewSet)
router.register(r'bluetooth', BluetoothViewSet)
router.register(r'camera', CameraViewSet)
#router.register(r'camera', CameraViewSet)
urlpatterns = [
path('api/', include(router.urls)),