Skip to content
Snippets Groups Projects
Commit 9cb7ef67 authored by Deleted User's avatar Deleted User
Browse files

Adaptation de la pade d'ajout des elements:

La méthode d'enregistrement des éléments à était modifier pour fonctionner avec le site générique.
parent 08369403
No related branches found
No related tags found
1 merge request!53Repair add tutos
import sqlite3
from sql_request import *
conn = sqlite3.connect('app/bdd_for_labels.db', check_same_thread=False)
c = conn.cursor()
......@@ -18,12 +19,12 @@ def add_title_link_prescriber(title, link, prescriber):
'''Check if the name of the tuto doesn't exist and if
if he doesn't exist, the tuto is add to database.
'''
c.execute("SELECT * FROM tutos WHERE title=? OR link=?", (title, link))
c.execute("SELECT * FROM elements WHERE title=? OR link=?", (title, link))
res = c.fetchall()
print(res)
if (len(res) != 0):
return ("Erreur : Ce tutoriel est déjà répertorié")
c.execute('INSERT INTO tutos(title, link, prescriber) VALUES(?, ?, ?)', (title, link, prescriber))
c.execute('INSERT INTO elements(title, link, prescriber) VALUES(?, ?, ?)', (title, link, prescriber))
conn.commit()
return (1)
......@@ -31,14 +32,16 @@ def update_tuto_labels(link, labels):
''' Add for each label a row in table 'tuto_labels'
that contain [link, id_label].
'''
id_element = send_sql_request('SELECT id FROM elements ORDER BY `id` DESC LIMIT 1')[0][0]
print (id_element)
labels = labels.split(',')
request = []
for label_id in labels:
inter = []
inter.append(link)
inter.append(id_element)
inter.append(label_id)
request.append(inter)
c.executemany("INSERT INTO tutos_labels(link, id_label) VALUES(?, ?)", request)
c.executemany("INSERT INTO elements_labels(id_element, id_label) VALUES(?, ?)", request)
conn.commit()
def add_tuto(title, link, labels, prescriber):
......
......@@ -20,7 +20,7 @@
<div id='hierarchy'>
<span v-for='(value, index) in table'>
<span @click="activate_lo(index)">{{ value[1] }}</span>
<img v-if='is_active[index] % 2 == 1' src="static/checked.png">
<img v-if='is_active[index] % 2 == 1' src="static/img/checked.png">
<br>
</span>
<!-- {{ labels_add }} -->
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment