Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 31 additions & 1 deletion formapp/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ def logFile(type, message):
sD.settings['perms']['sfx'] = data[3]
sD.settings['perms']['bgm'] = data[4]
sD.settings['perms']['api'] = data[5]
sD.settings['perms']['tags'] = data[9]
sD.settings['locked'] = data[6]
sD.settings['blind'] = data[7]
sD.settings['showinc'] = data[8]
Expand Down Expand Up @@ -225,7 +226,7 @@ def newStudent(remote, username, bot=False):
for user in sD.studentDict:
if sD.studentDict[user]['perms'] == 0:
teacher = True

#Login bots as guest
if bot:
logFile("Info", "Bot successful login. Made them a guest: " + username)
Expand All @@ -251,8 +252,10 @@ def newStudent(remote, username, bot=False):
if username in user:
if not teacher:
sD.studentDict[remote]['perms'] = sD.settings['perms']['admin']
if tags = True
else:
sD.studentDict[remote]['perms'] = int(user[3])
sD.studentDict[remote]['tags'] = json.loads(user[13])
Comment on lines +255 to +258

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does this not cause a huge error?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ive been trying to fix this, it only breaks when making a new user, but i have no idea where else to put this, it needs this to load the tags for users. if i remove this, the tags stop working


socket_.emit('alert', json.dumps(packMSG('all', 'server', sD.studentDict[request.remote_addr]['name'] + " logged in...")), namespace=chatnamespace)
playSFX("sfx_up02")
Expand Down Expand Up @@ -2691,10 +2694,12 @@ def endpoint_users():
else:
action = request.args.get('action')
user = '';
print(request.args.get('name'))
Comment thread
cboldtsus marked this conversation as resolved.
if request.args.get('name'):
for key, value in sD.studentDict.items():
if request.args.get('name') == sD.studentDict[key]['name']:
user = key
print(user)
Comment thread
cboldtsus marked this conversation as resolved.
break
if action == 'delete':
db = sqlite3.connect(os.path.dirname(os.path.abspath(__file__)) + '/data/database.db')
Expand All @@ -2717,6 +2722,25 @@ def endpoint_users():
return render_template("message.html", message = "Password reset.")
else:
return render_template("message.html", message = "New password reqired.")

# http://localhost:420/users?name=u1&action=addtag&tag=urmum
if action == 'addtag':
addTag = request.args.get('tag')
db = sqlite3.connect(os.path.dirname(os.path.abspath(__file__)) + '/data/database.db')
dbcmd = db.cursor()
sD.studentDict[user]['tags'].append(addTag)
dbcmd.execute("UPDATE users SET tags=:tags WHERE username=:uname", {"uname": request.args.get('name'), "tags": json.dumps(sD.studentDict[user]['tags'])})
db.commit()
db.close()
# http://localhost:420/users?name=u1&action=removetag&tag=urmum
if action == 'removetag':
remTag = request.args.get('tag')
db = sqlite3.connect(os.path.dirname(os.path.abspath(__file__)) + '/data/database.db')
dbcmd = db.cursor()
sD.studentDict[user]['tags'].remove(remTag)
dbcmd.execute("UPDATE users SET tags=:tags WHERE username=:uname", {"uname": request.args.get('name'), "tags": json.dumps(sD.studentDict[user]['tags'])})
db.commit()
db.close()
if not user:
return render_template("message.html", message = "That user was not found by their name.")
if request.args.get('ip'):
Expand Down Expand Up @@ -3065,6 +3089,12 @@ def ttt(message):
logFile("Error", str(e))


@socket_.on('chat', namespace=chatnamespace)
def sound():
try:
print('work')
except Exception as e:
print("[error] " + 'Error: ' + str(e))
Comment thread
cboldtsus marked this conversation as resolved.

# ███████ ██ ███ ██ █████ ██ ██████ ██████ ██████ ████████
# ██ ██ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
Expand Down
Binary file modified formapp/data/database_template.db
Binary file not shown.
3 changes: 3 additions & 0 deletions formapp/debug.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[1017/105201.979:ERROR:registration_protocol_win.cc(106)] CreateFile: The system cannot find the file specified. (0x2)
[1017/111806.752:ERROR:registration_protocol_win.cc(106)] CreateFile: The system cannot find the file specified. (0x2)
[1017/111809.960:ERROR:registration_protocol_win.cc(106)] CreateFile: The system cannot find the file specified. (0x2)
Comment thread
cboldtsus marked this conversation as resolved.
4 changes: 4 additions & 0 deletions formapp/index.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import json

tag = ["grade", "team"]
print(json.dumps(tag))
Comment thread
cboldtsus marked this conversation as resolved.
9 changes: 7 additions & 2 deletions formapp/templates/chat.html
Original file line number Diff line number Diff line change
Expand Up @@ -661,9 +661,14 @@ <h2 id="ulHeading">Online</h2>
// args = text.split(" ");
// args.shift();
chatSocket.emit("help", packMSG(receiver, username, text));
} else {
} else if (text.startsWith("!#sound")) {
// text.splice(0, 2);
// args = text.split(" ");
// args.shift();
chatSocket.emit("sound", packMSG(receiver, username, { command: 'bgm', file: 'rickroll.mp3'}));}
else {
chatSocket.emit("message", packMSG(receiver, username, text));
}
}
Comment on lines +664 to +671

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be in a different PR/branch.

boxes.inputBox.value = "";
boxes.inputBox.focus();
}
Expand Down
15 changes: 13 additions & 2 deletions formapp/templates/controlpanel.html
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ <h2>Users</h2>
<button id="collapseButton" class="inline popOut hidden">Collapse all</button>

<div id="students">
<%sD.studentDict[request.remote_addr]['help']['message'] = request.args.get('message')-%>

</div>

<h2>Restart session</h2>
Expand Down Expand Up @@ -706,8 +706,12 @@ <h2>Clear data</h2>
if (student['help'].type) icons += `<img src="{{ url_for('static', filename='img/controlpanel/help.png') }}" class="icon" title="Help ticket">`;

if (student['complete']) icons += `<img src="{{ url_for('static', filename='img/controlpanel/complete.png') }}" class="icon" title="Complete">`;

//Show tags if student has any
let tags = `<span style="font-weight: lighter; font-size: 13px;" >${student['tags']}</span>`

newStudent.innerHTML = pictureIcon + icons + student.name;

newStudent.innerHTML = pictureIcon + icons + student.name + ' ' + tags;
let newDetails = document.createElement('span');
newDetails.classList.add('user');
if (collapsed) newDetails.classList.add("hidden");
Expand Down Expand Up @@ -867,6 +871,13 @@ <h2>Clear data</h2>
}
}, 1000);


// function addTag(name, tag) {
// request.open("GET", `/users?action=addtag&name=${name}&tag=${tag}`);
// request.send();
// }
Comment thread
cboldtsus marked this conversation as resolved.


function removeTicket(name) {
request.open("GET", `/users?action=removeTicket&name=${name}`);
request.send();
Expand Down
7 changes: 7 additions & 0 deletions formapp/templates/users.html
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ <h1>User accounts</h1>
let users = "{{ users }}".replaceAll("&#39;", "'").replaceAll("(", "[").replaceAll(")", "]").replaceAll("b'", "'").replaceAll("None", null);
users = eval(users);
let permNames = ['Teacher', 'Mod', 'Student', 'Guest'];
let tagNames = ['12th/Senior', '11th/Junior'];
let usersBox = document.getElementById("users");

usersBox.innerHTML = "";
Expand Down Expand Up @@ -109,6 +110,12 @@ <h1>User accounts</h1>
<option value="/updateuser?name=${user[1]}&field=permissions&value=3" ${userPerms === 3 ? "selected" : ""}>${permNames[3]}</option>
</select>
`;
let userTags = user[3];
newDetails.innerHTML += `
<select onchange="updateTag(this)" id="userTagsDrop" name="userTagsDrop">
<option value="/updateuser?name=${user[1]}&field=tags&value=0" ${userTags === 0 ? "selected" : ""}>${tagNames[0]}</option>
<option value="/updateuser?name=${user[1]}&field=tags&value=1" ${userTags === 1 ? "selected" : ""}>${tagNames[1]}</option>
`;
Comment thread
cboldtsus marked this conversation as resolved.
usersBox.appendChild(newStudent)
usersBox.appendChild(newDetails)
let name = user[1];
Expand Down