From 90d48324882023fe1fe0a2b8615f3d3151cb7117 Mon Sep 17 00:00:00 2001 From: Matteo Parrucci Date: Tue, 3 Jan 2023 11:28:00 +0100 Subject: [PATCH] working + docs --- .gitignore | 3 ++ Readme.md | 12 ++++- mysuitablephone/urls.py | 2 +- requirements.txt | 5 ++ suitablephones/admin.py | 17 ++++++- suitablephones/migrations/0001_initial.py | 62 +++++++++++++++++++++++ suitablephones/models.py | 12 ++--- 7 files changed, 104 insertions(+), 9 deletions(-) create mode 100644 requirements.txt create mode 100644 suitablephones/migrations/0001_initial.py diff --git a/.gitignore b/.gitignore index 7c18db4..0797d16 100644 --- a/.gitignore +++ b/.gitignore @@ -60,3 +60,6 @@ docs/_build/ # PyBuilder target/ +# Virtualenv +bin/ +pyvenv.cfg diff --git a/Readme.md b/Readme.md index 258222d..7b1a788 100644 --- a/Readme.md +++ b/Readme.md @@ -14,4 +14,14 @@ Yaml file descripting all devices are in _"lineage_wiki/_data/devices/"_ Set the proper path in var _LINEAGEWIKI_ -TODO: choose where to set _LINEAGEWIKI_ \ No newline at end of file +TODO: choose where to set _LINEAGEWIKI_ + +Installation: +``` + +git clone https://git.lattuga.net/d0c/suitablephones.git +virtualenv . +bin/pip install -r requirements.txt +bin/python manage.py migrate +bin/python manage.py createsuperuser +bin/python manage.py startserver diff --git a/mysuitablephone/urls.py b/mysuitablephone/urls.py index 584b9e3..20929b9 100644 --- a/mysuitablephone/urls.py +++ b/mysuitablephone/urls.py @@ -17,7 +17,7 @@ from django.contrib import admin from django.urls import include, path urlpatterns = [ - path('', include('suitablephones.urls')), + path('api-auth/', include('rest_framework.urls')), path('admin/', admin.site.urls), ] diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..7ed7ebe --- /dev/null +++ b/requirements.txt @@ -0,0 +1,5 @@ +Django +pyyaml +djangorestframework +markdown +django-filter diff --git a/suitablephones/admin.py b/suitablephones/admin.py index 8c38f3f..64bb077 100644 --- a/suitablephones/admin.py +++ b/suitablephones/admin.py @@ -1,3 +1,18 @@ from django.contrib import admin -# Register your models here. +from suitablephones.models import Bluetooth, Camera, Device + + +@admin.register(Camera) +class AdminCamera(admin.ModelAdmin): + pass + + +@admin.register(Bluetooth) +class AdminBluetooth(admin.ModelAdmin): + pass + + +@admin.register(Device) +class AdminDevice(admin.ModelAdmin): + pass diff --git a/suitablephones/migrations/0001_initial.py b/suitablephones/migrations/0001_initial.py new file mode 100644 index 0000000..35d26e6 --- /dev/null +++ b/suitablephones/migrations/0001_initial.py @@ -0,0 +1,62 @@ +# Generated by Django 4.1.5 on 2023-01-03 10:24 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='Bluetooth', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('spec', models.CharField(max_length=100)), + ('profile', models.CharField(max_length=100)), + ], + ), + migrations.CreateModel( + name='Camera', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('megapixel', models.DecimalField(decimal_places=1, max_digits=5)), + ('flash', models.CharField(choices=[('L', 'Led'), ('DL', 'Double Led')], max_length=100)), + ], + ), + migrations.CreateModel( + name='Device', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('architecture', models.CharField(max_length=100)), + ('cpu', models.CharField(max_length=100)), + ('codename', models.CharField(max_length=100)), + ('cpu_cores', models.CharField(max_length=100)), + ('cpu_freq', models.CharField(max_length=100)), + ('download_boot', models.CharField(max_length=100)), + ('dimensions', models.CharField(max_length=100)), + ('gpu', models.CharField(max_length=100)), + ('image', models.CharField(max_length=100)), + ('install_method', models.CharField(max_length=100)), + ('kernel', models.CharField(max_length=100)), + ('name', models.CharField(max_length=100)), + ('recovery_boot', models.CharField(max_length=100)), + ('ram', models.CharField(max_length=100)), + ('recovery_reboot', models.CharField(max_length=100)), + ('release', models.CharField(max_length=100)), + ('storage', models.CharField(max_length=100)), + ('soc', models.CharField(max_length=100)), + ('tree', models.CharField(max_length=100)), + ('type', models.CharField(max_length=100)), + ('vendor', models.CharField(max_length=100)), + ('vendor_short', models.CharField(max_length=100)), + ('wifi', models.CharField(max_length=100)), + ('bluetooth', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='suitablephones.bluetooth')), + ('cameras', models.ManyToManyField(to='suitablephones.camera')), + ], + ), + ] diff --git a/suitablephones/models.py b/suitablephones/models.py index 493891d..8db3650 100644 --- a/suitablephones/models.py +++ b/suitablephones/models.py @@ -4,17 +4,17 @@ from django.db import models class Bluetooth(models.Model): - spec = models.CharField(max_lengh=100) - profile = models.CharField(max_lengh=100) + spec = models.CharField(max_length=100) + profile = models.CharField(max_length=100) class Camera(models.Model): - class FLASHES(models.TextChoices: + class FLASHES(models.TextChoices): LED = 'L', 'Led' DUAL_LED = 'DL', 'Double Led' - megapixel = models.DecimalField() - flash = models.CharField(max_lengh=100, choices=FLASH) + megapixel = models.DecimalField(max_digits=5, decimal_places=1) + flash = models.CharField(max_length=100, choices=FLASHES.choices) #Devices.object.filter(flash=Camera.FLASEHS.LED) @@ -23,7 +23,7 @@ class Device(models.Model): #battery = architecture = models.CharField(max_length=100) #before_install = - bluetooth = modle.ForeingKey(Bluetooth) + bluetooth = models.ForeignKey(Bluetooth, on_delete=models.CASCADE) cameras = models.ManyToManyField(Camera) cpu = models.CharField(max_length=100) codename = models.CharField(max_length=100)