Skip to content

Commit c3d27cd

Browse files
committed
save the number of collabs and prefill
1 parent cf03967 commit c3d27cd

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

api/API/collaborators.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,19 @@ def get_collaborator(project_id, username):
9595
else:
9696
return None
9797

98-
98+
def delete_all_collaborators(project_id):
99+
""" deletes all of the currect collaborators
100+
101+
Args:
102+
project_id (int): the id of the project that the collaborators belong to
103+
104+
Returns:
105+
int: the number of rows affected
106+
"""
107+
return(Collaborators.delete()
108+
.where(Collaborators.pID == project_id)).execute()
109+
110+
99111
def delete_non_collaborators(project_id, *collaborators):
100112
""" deletes the current collaborators that are not in the list provided
101113

api/pages/people.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from api.everything import *
22
from ..API.projects import getProject
3+
from ..API.collaborators import delete_all_collaborators, getCollaborators
34

45
@app.route("/people", methods = ["GET"])
56
def people_GET ():
@@ -8,12 +9,16 @@ def people_GET ():
89

910
if proj.status == cfg["projectStatus"]["Pending"]:
1011
return redirect(url_for('main'))
12+
13+
collabs = getCollaborators(g.user.username)
14+
1115

1216
return render_template ( "pages/people.html",
1317
proj = proj,
1418
username = g.user.username,
1519
cfg = cfg,
1620
ldap = g.user,
21+
collabs = collabs
1722
)
1823

1924

@@ -40,10 +45,13 @@ def people_POST ():
4045
proj.numberStudents = numStu
4146
proj.save()
4247
if numCollab > 0:
48+
collabs = getCollaborators(g.user.username)
4349
return render_template ( "pages/bnumbers.html",
4450
username = g.user.username,
4551
cfg = cfg,
46-
numCollab = numCollab
52+
numCollab = numCollab,
53+
collabs = collabs
4754
)
4855
else:
56+
delete_all_collaborators(proj.pID)
4957
return redirect(url_for('history_GET'))

api/templates/pages/bnumbers.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ <h4>Collaborator #{{id + 1}}</h4>
3232
type = 'text'
3333
class = 'form-control'
3434
placeholder = 'B012345678'
35+
value =
36+
"{% if collabs is not none and id < collabs|length %}{{collabs[id].username.bnumber}}{% endif %}"
3537
required
3638
/>
3739

0 commit comments

Comments
 (0)