Compare commits

4 Commits

Author SHA1 Message Date
bbed8c7de1 Update 'README.md' 2022-10-04 16:07:30 +02:00
380b251cc1 Update 'README.md' 2022-10-04 16:03:17 +02:00
53a7c652aa Update 'README.md' 2022-10-04 16:02:45 +02:00
3a26a88114 Modo più semplice per creare il json così da debuggarlo meglio
Dalla riga 90 alla 112, metodo più standard per creare il json (il problema "TypeError: string indices must be integers" sulla serialization di Django c'è ugualmente, ma così il codice è più pulito)
2022-10-04 11:44:40 +02:00
2 changed files with 67 additions and 69 deletions

110
README.md
View File

@@ -1,15 +1,20 @@
# CENANDOODLE
Ordinare cibo con doodle in rete locale o anche no
||| Ordinare cibo con doodle in rete locale o anche no |||
||| Doodle condiviso su rete locale per ordinare e organizzare cibo e bevande (se previste) |||
Doodle condiviso su rete locale per ordinare e organizzare cibo e bevande (se previste)
setup-sh -> installa requisiti (tutti pip3 tra cui jawanndenn)
scrapeJE.py -> scrapa e stora dentro a 4 liste il nome prodotto, la descrizione, il numero dei pezzi(es 5 falefel per x€) e il prezzo. Infine crea jwndn.json che è un formattato leggibile da jawanndenn con il nome del ristorante e il nome dei prodotti.
start.sh -> avvia scrapeJE.py e poi cerca di usare (in vano, nel senso che nonfunziona) la funzione di javanndenn che carica un file json
----------------------------------------
# JAWANNDENN
# JAWANNDENN, UN GIT OPENSOURCE PER DOODLE
Git software da utilizzare
Git
https://github.com/hartwork/jawanndenn
@@ -27,8 +32,6 @@ si lancia
jawanndenn
La tua macchina quindi hosta il doodle all indirizzo 127.0.0.1:8080 e si avvia una copia di questa demo qui https://jawanndenn.de/
----------------------------------------
jawanndenn --help:
--debug Enable debug mode (default: disabled)
--host HOST Hostname or IP address to listen at (dfault 127.0.0.1)
@@ -37,68 +40,75 @@ La tua macchina quindi hosta il doodle all indirizzo 127.0.0.1:8080 e si avvia u
--database-sqlite3 FILE File to write the database to (default: ~/jawanndenn.sqlite3)
--django-secret-key-file FILE File to use for Django secret key data (default: ~/jawanndenn.secret_key)
limit configuration:
--max-polls COUNT Maximum number of polls total (default: 1000)
--max-votes-per-poll COUNT Maximum number of votes per poll (default: 40)
data import/export arguments:
--dumpdata Dump a JSON export of the database to standard output, then quit.
--loaddata FILE.json Load a JSON export of the database from FILE.json, then quit.
----------------------------------------
# GOAL:
Estrapolare nomi dei piatti e formattarli per file json
Da fare:
Estrapola piatti da JustEat,
Estrapola prezzo,
Estrapola descrizione,
formatta i dati.
Funzionalità da aggiungere:
Visualizzare prezzo,
Visualizzare descrizione piatto,
Spesa totale,
Spesa dei singoli,
Visualizzazione del num telefono ristorante,
Eliminare un piatto,
Mostrare che non è disponibile o non mostrare un piatto se non c'è,
Funzionalità da aggiungere secondarie:
Specificare la scelta dell impasto speciale
-----------------------------------------
FILE.json di esempio:
# DA FARE PER IMPLEMENTARE CENANDOODLE:
{
# [AVVIARE JAWANNDENN CON jwndn.json PRECARICATO]
"jawandenn --loaddata file.json" promette di caricare un json precaricato nel doodle ma invece da warnings e errori simili a questi:
"lifetime": "month",
WARNINGS:
jawanndenn.Ballot: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the AppConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.
Operations to perform:
Apply all migrations: admin, auth, contenttypes, jawanndenn, sessions
Running migrations:
No migrations to apply.
Importing JSON dump -- this may take a few seconds...
System check identified some issues:
"equal_width": true,
"title": "Che ti vuoi mangià?",
"options": [
"Piatto Lahme Meshwie",
"Piatto Aleppo",
"Fatayer con Formaggio",
WARNINGS:
jawanndenn.Ballot: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the AppConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.
File "/home/$USER/.local/lib/python3.9/site-packages/django/core/serializers/json.py", line 70, in Deserializer
yield from PythonDeserializer(objects, **options)
File "/home/$USER/.local/lib/python3.9/site-packages/django/core/serializers/python.py", line 103, in Deserializer
Model = _get_model(d["model"])
TypeError: string indices must be integers
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
"/home/$USER/.local/lib/python3.9/site-packages/django/core/serializers/json.py", line 74, in Deserializer
raise DeserializationError() from exc
django.core.serializers.base.DeserializationError: Problem installing fixture '/home/sco/Cenandoodle/jwndn.json':
"Fatayer con Spinaci"
]
}
# [AGGIUNGERE PIU PEZZI DELLO STESSO PRODOTTO PER SINGOLO UTENTE]
scritto dentro a /home/$USER/jawanndenn/jawanndenn/static/js/pool.js c'è:
var VOTED_YES_CLASS = 'votedYes';
var VOTED_NO_CLASS = 'votedNo';
var YET_TO_VOTE_CLASS = 'yetToVote';
stavo cercando di capire come aggiungere un doppio, triplo, quadruplo... voto. In modo da "votare" ovver acquistare/aggiungere ad esempio DUE fatayer al formaggio per singolo user
# [AGGIUNGERE PREZZI DEL PRODOTTO ]
Credo si faccia sempre con /home/$USER/jawanndenn/jawanndenn/static/js/pool.js.
Una possibilità potrebbe essere quella di implementare aggiungendo le liste(prezz o, desc, npezzi) nel javascript facendole comparire tramite un mouseHover. Oppure il prezzo lo si potrebbe aggiungere accanto al nome (e quindi in jwndn.json)
# [GESTIRE LA QUESTIONE DEI PRODOTTI NON DISPONIBILI]
Trovare un modo per determinare quando i prodotti non sono diponibili, eliminandoli dall inclusione del json oppure specificando il "non disponibile"
# [PARSARE IL NUMERO DI TELEFONO]
Per ora so soltanto che alla riga 870 dell html parsato, all interno di uno "< script >" C'è il numero di telefono in forma "allergenPhoneNumber":"3389529446" (o per lo meno così è per Aleppo). Trovare poi un moodo di visualizzarlo, quasi sicuramente nel "title" del json così da visualizzarlo acconto del nome del ristorante.
# [CALCOLARE E VISUALIZZARE IL PREZZO SINGOLO E TOTALE]
Trovare un modo per calcolare il prezzo del singolo user e il prezzo totale da dare al rider

View File

@@ -88,30 +88,18 @@ print("lista prezzi:",len(prezzo)) #sono stringhe ovvero ci sono anche prezzi co
#Crea file json formattato per jawanndenn con la lista dei nomi dei prodotti
#scrive le prime righe del json (uguali ogni volta)
with open('jwndn.json', 'w') as jw:
jw.write("{\n")
jw.write(' "lifetime": "month",\n')
jw.write(' "equal_width": true,\n')
jw.write(' "title":')
jw.write('"')
jw.write(nrist)
jw.write('",')
jw.write("\n")
jw.write(' "options": \n')
#inserisce i nomi dei prodotti dalla lista
def writeListJSONFile(filepathname, lista):
with open('./jwndn.json', 'a+') as f:
json.dump(nome, f)
data = {"lifetime": "month", "equal_width": "true", "title": nrist, "options": nome}
writeListJSONFile('./jwndn.json', nome)
print(json.dumps(data))
#conclude il json con l ultima parentesi graffa
with open('jwndn.json', 'a+') as jw:
jw.write("\n}\n")
def writeListJSONFile(filepathname):
with open('jwndn.json', 'w') as f:
f.write(json.dumps(data))
writeListJSONFile('./jwndn.json')
#
#storare in "tel" il numero di telefono dle ristorante