Merge branch 'refactor' into 'master'
Refactor See merge request benjamyn/shoplist2!3
This commit is contained in:
commit
b5a824c830
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,4 +1,5 @@
|
|||||||
env/
|
env/
|
||||||
.vscode/
|
.vscode/
|
||||||
|
__pycache__/
|
||||||
list.db
|
list.db
|
||||||
.config
|
.config
|
||||||
133
db.py
Normal file
133
db.py
Normal file
@ -0,0 +1,133 @@
|
|||||||
|
import mysql.connector
|
||||||
|
import configparser
|
||||||
|
|
||||||
|
config = configparser.ConfigParser()
|
||||||
|
|
||||||
|
try:
|
||||||
|
config.read(".config")
|
||||||
|
except Exception as E:
|
||||||
|
print(E)
|
||||||
|
|
||||||
|
def dbConnect():
|
||||||
|
mydb = mysql.connector.connect(
|
||||||
|
host=config["mysql"]["Host"],
|
||||||
|
user=config["mysql"]["Username"],
|
||||||
|
passwd=config["mysql"]["Password"],
|
||||||
|
database=config["mysql"]["Database"]
|
||||||
|
)
|
||||||
|
return mydb
|
||||||
|
|
||||||
|
|
||||||
|
def doesTableExist():
|
||||||
|
mydb = dbConnect()
|
||||||
|
mycursor = mydb.cursor()
|
||||||
|
mycursor.execute('''SHOW TABLES''')
|
||||||
|
tables = mycursor.fetchall()
|
||||||
|
if len(tables) == 0:
|
||||||
|
mycursor.execute('''CREATE TABLE USERS (id INT AUTO_INCREMENT PRIMARY KEY, username VARCHAR(255), password VARCHAR(255), admin BOOLEAN)''')
|
||||||
|
mycursor.execute('''CREATE TABLE LISTS (id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(255))''')
|
||||||
|
mycursor.execute('''CREATE TABLE SHOPLIST (id INT AUTO_INCREMENT PRIMARY KEY, item VARCHAR(255), gotten BOOLEAN, user_id INT, list_id INT, FOREIGN KEY (`list_id`) REFERENCES `LISTS`(`id`), FOREIGN KEY (`user_id`) REFERENCES `USERS`(`id`)
|
||||||
|
ON DELETE CASCADE)''')
|
||||||
|
mycursor.execute('''CREATE TABLE USER_META (user_id INT, list_id INT, FOREIGN KEY (`list_id`) REFERENCES `LISTS`(`id`), FOREIGN KEY (`user_id`) REFERENCES `USERS`(`id`)
|
||||||
|
ON DELETE CASCADE)''')
|
||||||
|
mydb.close()
|
||||||
|
|
||||||
|
def runQuery(query, data=None):
|
||||||
|
mydb = dbConnect()
|
||||||
|
c = mydb.cursor()
|
||||||
|
if data is not None:
|
||||||
|
c.execute(query, data)
|
||||||
|
else:
|
||||||
|
c.execute(query)
|
||||||
|
if query.lower().startswith("select"):
|
||||||
|
ret = c.fetchall()
|
||||||
|
else:
|
||||||
|
ret = []
|
||||||
|
mydb.commit()
|
||||||
|
mydb.close()
|
||||||
|
return ret
|
||||||
|
|
||||||
|
def readFromDB():
|
||||||
|
# By default load all shopping lists the user is a part of (Most users will only have one so this this fine)
|
||||||
|
query = '''select SHOPLIST.id, SHOPLIST.item, SHOPLIST.gotten, USERS.username, SHOPLIST.list_id from SHOPLIST inner join USERS on SHOPLIST.user_id = USERS.id inner join USER_META on SHOPLIST.list_id = USER_META.list_id'''
|
||||||
|
return runQuery(query)
|
||||||
|
|
||||||
|
def insertToDB(data):
|
||||||
|
query = "INSERT INTO SHOPLIST (item, gotten, user_id, list_id) VALUES (%s, 0, %s, %s)"
|
||||||
|
data = (data['item'], data['name'], data["list_id"])
|
||||||
|
# print(query)
|
||||||
|
runQuery(query, data)
|
||||||
|
|
||||||
|
|
||||||
|
def deleteRow(rowID):
|
||||||
|
query = "DELETE FROM SHOPLIST WHERE id = %s"
|
||||||
|
data = (rowID, )
|
||||||
|
runQuery(query, data)
|
||||||
|
|
||||||
|
def getItem(rowID):
|
||||||
|
query = "UPDATE SHOPLIST set gotten = 1 where id = %s"
|
||||||
|
data = (rowID, )
|
||||||
|
runQuery(query, data)
|
||||||
|
|
||||||
|
def unGetItem(rowID):
|
||||||
|
query = "UPDATE SHOPLIST set gotten = 0 where id = %s"
|
||||||
|
data = (rowID, )
|
||||||
|
runQuery(query, data)
|
||||||
|
|
||||||
|
def get_users(username=None):
|
||||||
|
if username == None:
|
||||||
|
#return all users
|
||||||
|
query = "select username, admin, id from USERS"
|
||||||
|
return runQuery(query)
|
||||||
|
query = "select username, admin from USERS where username like %s"
|
||||||
|
data = (username, )
|
||||||
|
return runQuery(query, data)
|
||||||
|
|
||||||
|
def add_user(userData):
|
||||||
|
username = userData["username"]
|
||||||
|
password = userData["password"]
|
||||||
|
query = "insert into USERS (username, password, admin) values (%s, md5(%s), False)"
|
||||||
|
data = (username, password)
|
||||||
|
runQuery(query, data)
|
||||||
|
|
||||||
|
def update_pass(user_id, newpass):
|
||||||
|
query = "update USERS set password=md5(%s) where id=%s"
|
||||||
|
data = (newpass, user_id)
|
||||||
|
runQuery(query, data)
|
||||||
|
|
||||||
|
def get_items(user_id, list_id=None):
|
||||||
|
if list_id != None:
|
||||||
|
query = "select SHOPLIST.id, SHOPLIST.item, SHOPLIST.gotten, USERS.username from SHOPLIST inner join USERS on SHOPLIST.user_id = USERS.id inner join USER_META on SHOPLIST.list_id = USER_META.list_id where USER_META.user_id = %s and SHOPLIST.list_id = %s"
|
||||||
|
data = (user_id, list_id)
|
||||||
|
return runQuery(query, data)
|
||||||
|
query = "select SHOPLIST.id, SHOPLIST.item, SHOPLIST.gotten, USERS.username from SHOPLIST inner join USERS on SHOPLIST.user_id = USERS.id inner join USER_META on SHOPLIST.list_id = USER_META.list_id where USER_META.user_id = %s"
|
||||||
|
data = (user_id,)
|
||||||
|
return runQuery(query, data)
|
||||||
|
|
||||||
|
def get_list_ids(user_id):
|
||||||
|
ret = {}
|
||||||
|
if user_id == "admin":
|
||||||
|
query = "SELECT id, name from LISTS;"
|
||||||
|
res = runQuery(query)
|
||||||
|
else:
|
||||||
|
query = "select USER_META.list_id, LISTS.name from USER_META inner join LISTS on LISTS.id = USER_META.list_id where USER_META.user_id = %s"
|
||||||
|
data = (user_id,)
|
||||||
|
res = runQuery(query, data)
|
||||||
|
for lid, name in res:
|
||||||
|
ret[str(lid)] = name
|
||||||
|
return ret
|
||||||
|
|
||||||
|
def addList(list_name):
|
||||||
|
query = "insert into LISTS (name) values (%s)"
|
||||||
|
data = (list_name,)
|
||||||
|
runQuery(query, data)
|
||||||
|
|
||||||
|
def addUserToList(userid, listid):
|
||||||
|
query = "insert into USER_META (user_id, list_id) values (%s, %s)"
|
||||||
|
data = (userid, listid)
|
||||||
|
runQuery(query, data)
|
||||||
|
|
||||||
|
def doLogin(username, password):
|
||||||
|
query = "select id, username, admin from USERS where username = %s and password = md5(%s)"
|
||||||
|
data = (username, password)
|
||||||
|
return runQuery(query, data)
|
||||||
185
shop.py
185
shop.py
@ -1,150 +1,42 @@
|
|||||||
from flask import Flask, render_template, make_response, request, redirect, url_for, session, abort
|
from flask import Flask, render_template, make_response, request, redirect, url_for, session, abort
|
||||||
from pprint import pprint
|
from pprint import pprint
|
||||||
import mysql.connector
|
import db
|
||||||
import configparser
|
|
||||||
import os.path
|
import os.path
|
||||||
|
|
||||||
config = configparser.ConfigParser()
|
|
||||||
MOBILES = ["android", "iphone", "blackberry"]
|
MOBILES = ["android", "iphone", "blackberry"]
|
||||||
|
|
||||||
try:
|
|
||||||
config.read(".config")
|
|
||||||
except Exception as E:
|
|
||||||
print(E)
|
|
||||||
|
|
||||||
def dbConnect():
|
|
||||||
mydb = mysql.connector.connect(
|
|
||||||
host=config["mysql"]["Host"],
|
|
||||||
user=config["mysql"]["Username"],
|
|
||||||
passwd=config["mysql"]["Password"],
|
|
||||||
database=config["mysql"]["Database"]
|
|
||||||
)
|
|
||||||
return mydb
|
|
||||||
|
|
||||||
|
|
||||||
def doesTableExist():
|
|
||||||
mydb = dbConnect()
|
|
||||||
mycursor = mydb.cursor()
|
|
||||||
mycursor.execute('''SHOW TABLES''')
|
|
||||||
tables = mycursor.fetchall()
|
|
||||||
if len(tables) == 0:
|
|
||||||
mycursor.execute('''CREATE TABLE USERS (id INT AUTO_INCREMENT PRIMARY KEY, username VARCHAR(255), password VARCHAR(255), admin BOOLEAN)''')
|
|
||||||
mycursor.execute('''CREATE TABLE LISTS (id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(255))''')
|
|
||||||
mycursor.execute('''CREATE TABLE SHOPLIST (id INT AUTO_INCREMENT PRIMARY KEY, item VARCHAR(255), gotten BOOLEAN, user_id INT, list_id INT, FOREIGN KEY (`list_id`) REFERENCES `LISTS`(`id`), FOREIGN KEY (`user_id`) REFERENCES `USERS`(`id`)
|
|
||||||
ON DELETE CASCADE)''')
|
|
||||||
mycursor.execute('''CREATE TABLE USER_META (user_id INT, list_id INT, FOREIGN KEY (`list_id`) REFERENCES `LISTS`(`id`), FOREIGN KEY (`user_id`) REFERENCES `USERS`(`id`)
|
|
||||||
ON DELETE CASCADE)''')
|
|
||||||
mydb.close()
|
|
||||||
|
|
||||||
def runQuery(query, data=None):
|
|
||||||
mydb = dbConnect()
|
|
||||||
c = mydb.cursor()
|
|
||||||
if data is not None:
|
|
||||||
c.execute(query, data)
|
|
||||||
else:
|
|
||||||
c.execute(query)
|
|
||||||
if query.lower().startswith("select"):
|
|
||||||
ret = c.fetchall()
|
|
||||||
else:
|
|
||||||
ret = []
|
|
||||||
mydb.commit()
|
|
||||||
mydb.close()
|
|
||||||
return ret
|
|
||||||
|
|
||||||
def readFromDB():
|
|
||||||
# By default load all shopping lists the user is a part of (Most users will only have one so this this fine)
|
|
||||||
query = '''select SHOPLIST.id, SHOPLIST.item, SHOPLIST.gotten, USERS.username, SHOPLIST.list_id from SHOPLIST inner join USERS on SHOPLIST.user_id = USERS.id inner join USER_META on SHOPLIST.list_id = USER_META.list_id'''
|
|
||||||
return runQuery(query)
|
|
||||||
|
|
||||||
def insertToDB(data):
|
|
||||||
query = "INSERT INTO SHOPLIST (item, gotten, user_id, list_id) VALUES (%s, 0, %s, %s)"
|
|
||||||
data = (data['item'], data['name'], data["list_id"])
|
|
||||||
# print(query)
|
|
||||||
runQuery(query, data)
|
|
||||||
|
|
||||||
|
|
||||||
def deleteRow(rowID):
|
|
||||||
query = "DELETE FROM SHOPLIST WHERE id = %s"
|
|
||||||
data = (rowID, )
|
|
||||||
runQuery(query, data)
|
|
||||||
|
|
||||||
def getItem(rowID):
|
|
||||||
query = "UPDATE SHOPLIST set gotten = 1 where id = %s"
|
|
||||||
data = (rowID, )
|
|
||||||
runQuery(query, data)
|
|
||||||
|
|
||||||
def unGetItem(rowID):
|
|
||||||
query = "UPDATE SHOPLIST set gotten = 0 where id = %s"
|
|
||||||
data = (rowID, )
|
|
||||||
runQuery(query, data)
|
|
||||||
|
|
||||||
def get_users(username=None):
|
|
||||||
if username == None:
|
|
||||||
#return all users
|
|
||||||
query = "select username, admin, id from USERS"
|
|
||||||
return runQuery(query)
|
|
||||||
query = "select username, admin from USERS where username like %s"
|
|
||||||
data = (username, )
|
|
||||||
return runQuery(query, data)
|
|
||||||
|
|
||||||
def add_user(userData):
|
|
||||||
username = userData["username"]
|
|
||||||
password = userData["password"]
|
|
||||||
query = "insert into USERS (username, password, admin) values (%s, md5(%s), False)"
|
|
||||||
data = (username, password)
|
|
||||||
runQuery(query, data)
|
|
||||||
|
|
||||||
def update_pass(user_id, newpass):
|
|
||||||
query = "update USERS set password=md5(%s) where id=%s"
|
|
||||||
data = (newpass, user_id)
|
|
||||||
runQuery(query, data)
|
|
||||||
|
|
||||||
def get_items(user_id, list_id=None):
|
|
||||||
if list_id != None:
|
|
||||||
query = "select SHOPLIST.id, SHOPLIST.item, SHOPLIST.gotten, USERS.username from SHOPLIST inner join USERS on SHOPLIST.user_id = USERS.id inner join USER_META on SHOPLIST.list_id = USER_META.list_id where USER_META.user_id = %s and SHOPLIST.list_id = %s"
|
|
||||||
data = (user_id, list_id)
|
|
||||||
return runQuery(query, data)
|
|
||||||
query = "select SHOPLIST.id, SHOPLIST.item, SHOPLIST.gotten, USERS.username from SHOPLIST inner join USERS on SHOPLIST.user_id = USERS.id inner join USER_META on SHOPLIST.list_id = USER_META.list_id where USER_META.user_id = %s"
|
|
||||||
data = (user_id,)
|
|
||||||
return runQuery(query, data)
|
|
||||||
|
|
||||||
def get_list_ids(user_id):
|
|
||||||
ret = {}
|
|
||||||
if user_id == "admin":
|
|
||||||
query = "SELECT id, name from LISTS;"
|
|
||||||
res = runQuery(query)
|
|
||||||
else:
|
|
||||||
query = "select USER_META.list_id, LISTS.name from USER_META inner join LISTS on LISTS.id = USER_META.list_id where USER_META.user_id = %s"
|
|
||||||
data = (user_id,)
|
|
||||||
res = runQuery(query, data)
|
|
||||||
for lid, name in res:
|
|
||||||
ret[lid] = name
|
|
||||||
return ret
|
|
||||||
|
|
||||||
def addList(list_name):
|
|
||||||
query = "insert into LISTS (name) values (%s)"
|
|
||||||
data = (list_name,)
|
|
||||||
runQuery(query, data)
|
|
||||||
|
|
||||||
def addUserToList(userid, listid):
|
|
||||||
query = "insert into USER_META (user_id, list_id) values (%s, %s)"
|
|
||||||
data = (userid, listid)
|
|
||||||
runQuery(query, data)
|
|
||||||
|
|
||||||
application = Flask(__name__)
|
application = Flask(__name__)
|
||||||
application.config["DEBUG"] = True
|
application.config["DEBUG"] = True
|
||||||
application.secret_key = b'*$#@U9423jr92jioJKL_)_;dasfj()12'
|
application.secret_key = b'*$#@U9423jr92jioJKL_)_;dasfj()12'
|
||||||
|
|
||||||
|
def createSession(res):
|
||||||
|
list_ids = db.get_list_ids(res[0][0])
|
||||||
|
session["id"] = int(res[0][0])
|
||||||
|
session["username"] = res[0][1]
|
||||||
|
session["isAdmin"] = res[0][2]
|
||||||
|
session["list_ids"] = list_ids
|
||||||
|
session["active_id"] = "0"
|
||||||
|
|
||||||
|
def refreshSession(id):
|
||||||
|
list_ids = db.get_list_ids(int(session["id"]))
|
||||||
|
print(list_ids)
|
||||||
|
session["list_ids"] = None
|
||||||
|
session["list_ids"] = list_ids
|
||||||
|
# print(session["list_ids"])
|
||||||
|
|
||||||
@application.route('/')
|
@application.route('/')
|
||||||
def index():
|
def index():
|
||||||
if session.get('id') is None:
|
if session.get('id') is None:
|
||||||
data = {"title":"Login"}
|
data = {"title":"Login"}
|
||||||
return render_template("auth.html", data=data)
|
return render_template("auth.html", data=data)
|
||||||
|
|
||||||
|
refreshSession(session["id"])
|
||||||
|
|
||||||
if session.get("active_id") == "0":
|
if session.get("active_id") == "0":
|
||||||
res = get_items(session["id"])
|
res = db.get_items(session["id"])
|
||||||
else:
|
else:
|
||||||
res = get_items(session["id"], session["active_id"])
|
res = db.get_items(session["id"], session["active_id"])
|
||||||
data = {"title": "Shopping List", "results": res, "session": session, "list_ids": session["list_ids"]}
|
data = {"title": "Shopping List", "results": res, "session": session, "list_ids": session["list_ids"]}
|
||||||
|
|
||||||
for device in MOBILES:
|
for device in MOBILES:
|
||||||
@ -159,41 +51,34 @@ def handle_data():
|
|||||||
for x in request.form:
|
for x in request.form:
|
||||||
if request.form[x] == '':
|
if request.form[x] == '':
|
||||||
return redirect(url_for('index'))
|
return redirect(url_for('index'))
|
||||||
insertToDB({"item": request.form["item"], "name": session["id"], "list_id": request.form["add2list"]})
|
db.insertToDB({"item": request.form["item"], "name": session["id"], "list_id": request.form["add2list"]})
|
||||||
if "rem" in request.form:
|
if "rem" in request.form:
|
||||||
deleteRow(request.form["rem"])
|
db.deleteRow(request.form["rem"])
|
||||||
|
|
||||||
if "got" in request.form:
|
if "got" in request.form:
|
||||||
getItem(request.form["got"])
|
db.getItem(request.form["got"])
|
||||||
|
|
||||||
if "ungot" in request.form:
|
if "ungot" in request.form:
|
||||||
unGetItem(request.form["ungot"])
|
db.unGetItem(request.form["ungot"])
|
||||||
|
|
||||||
if "loginform" in request.form:
|
if "loginform" in request.form:
|
||||||
query = "select id, username, admin from USERS where username = %s and password = md5(%s)"
|
res = db.doLogin(request.form["username"], request.form["password"])
|
||||||
data = (request.form["username"].lower(), request.form["password"])
|
|
||||||
res = runQuery(query, data)
|
|
||||||
if len(res) != 0:
|
if len(res) != 0:
|
||||||
list_ids = get_list_ids(res[0][0])
|
createSession(res)
|
||||||
session["id"] = res[0][0]
|
|
||||||
session["username"] = res[0][1]
|
|
||||||
session["isAdmin"] = res[0][2]
|
|
||||||
session["list_ids"] = list_ids
|
|
||||||
session["active_id"] = "0"
|
|
||||||
|
|
||||||
if "newuser" in request.form:
|
if "newuser" in request.form:
|
||||||
#first check if the user exists
|
#first check if the user exists
|
||||||
usrCheck = get_users(request.form["username"])
|
usrCheck = db.get_users(request.form["username"])
|
||||||
if len(usrCheck) != 0:
|
if len(usrCheck) != 0:
|
||||||
return "Username Exists"
|
return "Username Exists"
|
||||||
userData = {"username": request.form["username"], "password": request.form["password"]}
|
userData = {"username": request.form["username"], "password": request.form["password"]}
|
||||||
add_user(userData)
|
db.add_user(userData)
|
||||||
return redirect(url_for("admin"))
|
return redirect(url_for("admin"))
|
||||||
|
|
||||||
if "newpass" in request.form:
|
if "newpass" in request.form:
|
||||||
user_id = request.form['updatepass']
|
user_id = request.form['updatepass']
|
||||||
newpass = request.form['newpass']
|
newpass = request.form['newpass']
|
||||||
update_pass(user_id, newpass)
|
db.update_pass(user_id, newpass)
|
||||||
return redirect(url_for("admin"))
|
return redirect(url_for("admin"))
|
||||||
|
|
||||||
if "logout" in request.form:
|
if "logout" in request.form:
|
||||||
@ -204,12 +89,12 @@ def handle_data():
|
|||||||
|
|
||||||
if "addList" in request.form:
|
if "addList" in request.form:
|
||||||
print(request.form["addList"])
|
print(request.form["addList"])
|
||||||
addList(request.form["addList"])
|
db.addList(request.form["addList"])
|
||||||
|
|
||||||
if "add2list" in request.form:
|
if "add2list" in request.form:
|
||||||
userid = request.form["add2list"]
|
userid = request.form["add2list"]
|
||||||
listid = request.form["listID"]
|
listid = request.form["listID"]
|
||||||
addUserToList(userid, listid)
|
db.addUserToList(userid, listid)
|
||||||
|
|
||||||
return redirect(url_for('index'))
|
return redirect(url_for('index'))
|
||||||
|
|
||||||
@ -222,12 +107,12 @@ def admin():
|
|||||||
return redirect(url_for("index"))
|
return redirect(url_for("index"))
|
||||||
|
|
||||||
#get a list of users
|
#get a list of users
|
||||||
userList = get_users()
|
userList = db.get_users()
|
||||||
lists = get_list_ids("admin")
|
lists = db.get_list_ids("admin")
|
||||||
data = {"users": userList, "lists": lists}
|
data = {"users": userList, "lists": lists}
|
||||||
|
|
||||||
return render_template("admin.html", data=data)
|
return render_template("admin.html", data=data)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
doesTableExist()
|
db.doesTableExist()
|
||||||
application.run(host="0.0.0.0")
|
application.run(host="0.0.0.0")
|
||||||
|
|||||||
@ -30,6 +30,11 @@ aside {
|
|||||||
color: azure;
|
color: azure;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.addlist {
|
||||||
|
background-color: #2a2a2a;
|
||||||
|
color: azure;
|
||||||
|
}
|
||||||
|
|
||||||
#logbtn {
|
#logbtn {
|
||||||
left: 10em;
|
left: 10em;
|
||||||
padding-top: 10px;
|
padding-top: 10px;
|
||||||
|
|||||||
@ -7,6 +7,8 @@
|
|||||||
<option type="submit" value="{{listid}}" id="addbox" name="list">{{id[listid]}}</option>
|
<option type="submit" value="{{listid}}" id="addbox" name="list">{{id[listid]}}</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
<div style="text-align: center; padding-bottom: 2px"><input class="btn btn-secondary" type="submit" style="text-align: center" name="addValue" value="Submit"></form>
|
<div style="text-align: center; padding-bottom: 2px"><input class="btn btn-secondary" type="submit"
|
||||||
|
style="text-align: center" name="addValue" value="Submit">
|
||||||
|
</form>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
@ -16,7 +16,12 @@
|
|||||||
<tr scope="row">
|
<tr scope="row">
|
||||||
<td>{{x[0]}}</td>
|
<td>{{x[0]}}</td>
|
||||||
<td>{% if x[1] == 1 %} Yes {% else %} No {% endif %}</td>
|
<td>{% if x[1] == 1 %} Yes {% else %} No {% endif %}</td>
|
||||||
<td align="right"><form action="/post" method="POST"><input style="width: 70%; display: inline;" class="form-control" type="text" name="newpass" id="addbox"><button class="btn btn-secondary" type="submit" name="updatepass" value="{{x[2]}}"> Change Password </button></form></td>
|
<td align="right">
|
||||||
|
<form action="/post" method="POST"><input style="width: 70%; display: inline;"
|
||||||
|
class="form-control" type="text" name="newpass" id="addbox"><button
|
||||||
|
class="btn btn-secondary" type="submit" name="updatepass" value="{{x[2]}}"> Change
|
||||||
|
Password </button></form>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
@ -38,7 +43,8 @@
|
|||||||
<input class="form-control" id="addbox" type="password" name="password" />
|
<input class="form-control" id="addbox" type="password" name="password" />
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group" style="padding-top: 10px; padding-left: 10px;">
|
<div class="form-group" style="padding-top: 10px; padding-left: 10px;">
|
||||||
<input class="btn btn-secondary" id="logbtn" type="submit" name="newuser" value="Create new account" />
|
<input class="btn btn-secondary" id="logbtn" type="submit" name="newuser"
|
||||||
|
value="Create new account" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
@ -47,7 +53,7 @@
|
|||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<label for="addlist" class="col-sm-2 col-form-label">List</label>
|
<label for="addlist" class="col-sm-2 col-form-label">List</label>
|
||||||
<div class="col-sm-10">
|
<div class="col-sm-10">
|
||||||
<input type=text class="form-control" id="addlist" type="text" name="addList" />
|
<input type=text class="form-control addlist" id="addlist" type="text" name="addList" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
@ -66,49 +72,40 @@
|
|||||||
</div>
|
</div>
|
||||||
<h1 class="text-center">Add User To List</h1>
|
<h1 class="text-center">Add User To List</h1>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="form-group row">
|
<div">
|
||||||
<form action="/post" method="POST">
|
<form action="/post" method="POST">
|
||||||
<label for="uesrnamelist" class="col-sm-2 col-form-label">User</label>
|
<div class="form-row">
|
||||||
<select id="usernamelist" name="add2list" class="custom-select custom-select-lg mb-3">
|
<div class="col">
|
||||||
|
<label for="usernamelist" class="addlist">User</label>
|
||||||
|
<select id="usernamelist" name="add2list"
|
||||||
|
class="custom-select custom-select-lg mb-3 form-control addlist">
|
||||||
{% for userid in data["users"] %}
|
{% for userid in data["users"] %}
|
||||||
<option type="submit" value="{{userid[2]}}" id="addbox" name="User2list" class="form-control">{{userid[0].title()}}</option>
|
<option type="submit" value="{{userid[2]}}" id="addbox" name="User2list"
|
||||||
|
class="form-control">{{userid[0].title()}}</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
<label for="listlist" class="col-sm-2 col-form-label">List</label>
|
</div>
|
||||||
<select id="listlist" name="listID" class="custom-select custom-select-lg mb-3">
|
<div class="col">
|
||||||
|
<label for="listlist" class="addlist">List</label>
|
||||||
|
<select id="listlist" name="listID" class="custom-select custom-select-lg mb-3 form-control addlist">
|
||||||
{% for x in data["lists"] %}
|
{% for x in data["lists"] %}
|
||||||
<option type="submit" value="{{x}}" id="addbox" name="User2list" class="form-control">{{data["lists"][x]}}</option>
|
<option type="submit" value="{{x}}" id="addbox" name="User2list" class="form-control">
|
||||||
|
{{data["lists"][x]}}</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
<button class="btn btn-secondary" type="submit" value="x"> Add User To List </button>
|
|
||||||
<!-- <input name="listID" value={{x}} type="hidden">--></form>
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="">
|
||||||
|
<button class="btn btn-secondary" type="submit" value="x"> Add
|
||||||
|
User To List </button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<!-- <table class="table table-striped table-dark table-hover">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th scope="col">Username</th>
|
|
||||||
<th scope="col">User</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
{% for x in data["lists"] %}
|
|
||||||
<tr scope="row">
|
|
||||||
<td>{{data["lists"][x]}}</td>
|
|
||||||
<td><form action="/post" method="POST">
|
|
||||||
<select id="addbox" name="add2list" class="custom-select custom-select-lg mb-3">
|
|
||||||
{% for userid in data["users"] %}
|
|
||||||
<option type="submit" value="{{userid[2]}}" id="addbox" name="User2list">{{userid[0].title()}}</option>
|
|
||||||
{% endfor %}
|
|
||||||
</select> <button class="btn btn-secondary" type="submit" value="x"> Add User To List </button>
|
|
||||||
<input name="listID" value={{x}} type="hidden"></form></td>
|
|
||||||
</tr>
|
|
||||||
{% endfor %}
|
|
||||||
</tbody>
|
|
||||||
</table> -->
|
|
||||||
</div>
|
</div>
|
||||||
{% for x in data["lists"] %}
|
|
||||||
{{data["lists"][x]}}
|
|
||||||
{% endfor %}
|
|
||||||
<!-- jQuery library -->
|
<!-- jQuery library -->
|
||||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
|
||||||
<!-- Popper JS -->
|
<!-- Popper JS -->
|
||||||
|
|||||||
@ -4,7 +4,8 @@
|
|||||||
<h1 class="container" style="text-align: center">{{ data["title"] }}, {{data["session"]["username"].title()}}
|
<h1 class="container" style="text-align: center">{{ data["title"] }}, {{data["session"]["username"].title()}}
|
||||||
<div class="dropdown">
|
<div class="dropdown">
|
||||||
<form action="/post" method="post" id="test">
|
<form action="/post" method="post" id="test">
|
||||||
<button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenu2" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
<button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenu2"
|
||||||
|
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||||
{% set id = session["list_ids"] %}
|
{% set id = session["list_ids"] %}
|
||||||
{% set actid = session["active_id"] %}
|
{% set actid = session["active_id"] %}
|
||||||
{% if actid == "0" %}
|
{% if actid == "0" %}
|
||||||
@ -16,7 +17,7 @@
|
|||||||
<div class="dropdown-menu" aria-labelledby="dropdownMenu2">
|
<div class="dropdown-menu" aria-labelledby="dropdownMenu2">
|
||||||
<button class="dropdown-item" type="submit" value="0" id="" name="list">All</button>
|
<button class="dropdown-item" type="submit" value="0" id="" name="list">All</button>
|
||||||
{% for listid in data["list_ids"] %}
|
{% for listid in data["list_ids"] %}
|
||||||
<button class="dropdown-item" type="submit" value="{{listid}}" id="{{id}}" name="list">{{id[listid]}}</button>
|
<button class="dropdown-item" type="submit" value="{{listid}}" name="list">{{id[listid]}}</button>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
@ -1,9 +1,11 @@
|
|||||||
{% include "header.html" %}
|
{% include "header.html" %}
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<h1 class="container" style="text-align: center">{{ data["title"] }}</h1>
|
<h1 class="container" style="text-align: center">{{ data["title"] }}</h1>
|
||||||
<div class="dropdown">
|
<div class="dropdown">
|
||||||
<form action="/post" method="post" id="test">
|
<form action="/post" method="post" id="test">
|
||||||
<button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenu2" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
<button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenu2" data-toggle="dropdown"
|
||||||
|
aria-haspopup="true" aria-expanded="false">
|
||||||
{% set id = session["list_ids"] %}
|
{% set id = session["list_ids"] %}
|
||||||
{% set actid = session["active_id"] %}
|
{% set actid = session["active_id"] %}
|
||||||
{% if actid == "0" %}
|
{% if actid == "0" %}
|
||||||
@ -15,7 +17,8 @@
|
|||||||
<div class="dropdown-menu" aria-labelledby="dropdownMenu2">
|
<div class="dropdown-menu" aria-labelledby="dropdownMenu2">
|
||||||
<button class="dropdown-item" type="submit" value="0" id="" name="list">All</button>
|
<button class="dropdown-item" type="submit" value="0" id="" name="list">All</button>
|
||||||
{% for listid in data["list_ids"] %}
|
{% for listid in data["list_ids"] %}
|
||||||
<button class="dropdown-item" type="submit" value="{{listid}}" id="{{id}}" name="list">{{id[listid]}}</button>
|
<button class="dropdown-item" type="submit" value="{{listid}}" id="{{id}}"
|
||||||
|
name="list">{{id[listid]}}</button>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
@ -24,11 +27,11 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="container" id="memes">
|
<div class="container" id="memes">
|
||||||
{% include "list.html" %}
|
{% include "list.html" %}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div id="logout">
|
<div id="logout">
|
||||||
<form action="/post" method="POST">
|
<form action="/post" method="POST">
|
||||||
<button type="submit" name="logout" class="btn btn-secondary"><i style="padding-top: 3px;" class="material-icons">
|
<button type="submit" name="logout" class="btn btn-secondary"><i style="padding-top: 3px;"
|
||||||
|
class="material-icons">
|
||||||
exit_to_app
|
exit_to_app
|
||||||
</i></button>
|
</i></button>
|
||||||
</form>
|
</form>
|
||||||
@ -40,14 +43,12 @@
|
|||||||
vpn_key
|
vpn_key
|
||||||
</i></button></a>
|
</i></button></a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- jQuery library -->
|
<!-- jQuery library -->
|
||||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
|
||||||
|
|
||||||
<!-- Popper JS -->
|
<!-- Popper JS -->
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
|
||||||
|
|
||||||
<!-- Latest compiled JavaScript -->
|
<!-- Latest compiled JavaScript -->
|
||||||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
|
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
Loading…
x
Reference in New Issue
Block a user