Skip to content

Commit e1fdd15

Browse files
committed
got the collabs to work and submit to next page
1 parent 52a20a8 commit e1fdd15

File tree

5 files changed

+46
-25
lines changed

5 files changed

+46
-25
lines changed

api/API/collaborators.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,15 +133,17 @@ def delete_non_collaborators(project_id, *collaborators):
133133

134134

135135
def add_collaborators(project_id, *collaborator_usernames):
136-
""" add the collaborators from collaborator bnumbers
136+
""" add the collaborators from collaborator usernames
137137
138138
Args:
139139
project_id (int): the id of the project that the collabors belong to
140140
collaborator_bnumbers (splat): the collaborators that will be the current collaborators
141141
"""
142+
# print(collaborator_usernames)
143+
# print(type(collaborator_usernames))
144+
# print(list(collaborator_usernames))
142145

143-
faculty = getLDAPFaculty(collaborator_usernames)
144-
145-
for professor in faculty:
146-
if get_collaborator(project_id, professor.username) is None:
147-
Collaborators(pID = project_id, username = professor.username).save()
146+
for collab in list(collaborator_usernames)[0]:
147+
print(str(collab))
148+
Collaborators(pID = project_id, username = getLDAPFaculty(str(collab))).save()
149+

api/pages/collaborations.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,24 @@
44
from ..API.faculty import getLDAPFaculty
55

66

7+
@app.route("/insertcollaborators", methods = ["POST"])
8+
@login_required
9+
def insert_collaborators ():
10+
# endpoint for inserting collaborators from collaborations.html
11+
12+
proj = getProject(g.user.username)
13+
newCollab = request.form.getlist("getCollabUsernames") #get all users but list includes
14+
#(request.form["getCollabUsernames"]) # only gets one collab #1?
15+
print(newCollab)
16+
# request.data.getlist("getCollabUsernames") # gets the data from the form
17+
# TODO: Insert the collaborators to the DB for this PID
18+
add_collaborators(proj.pID, newCollab)
19+
return redirect(url_for('irbyn_GET'))
20+
21+
22+
23+
24+
725
@app.route("/collaborations", methods = ["POST"])
826
@login_required
927
def people_POST ():
@@ -34,12 +52,10 @@ def people_POST ():
3452

3553
if numCollab > 0:
3654
delete_all_collaborators(proj.pID)
37-
collabs = getCollaborators(g.user.username)
3855
return render_template ("pages/collaborations.html",
3956
username = g.user.username,
4057
cfg = cfg,
4158
numCollab = numCollab,
42-
collabs = collabs,
4359
allFaculty = allFaculty
4460
)
4561
else:

api/pages/people.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,14 @@
22
from ..API.projects import getProject
33
from ..API.collaborators import delete_all_collaborators, getCollaborators
44

5-
@app.route("/deleteCollabs", methods = ["POST", "GET"])
6-
@login_required
7-
def deleteCollabs():
8-
#Function made solely to delete collaborators
9-
10-
delete_all_collaborators(proj.pID)
11-
return redirect(url_for("collaborations_GET"))
12-
135

146
@app.route("/people", methods = ["GET"])
7+
@login_required
158
def people_GET ():
169
# All of our queries
1710
proj = getProject(g.user.username)
18-
11+
print(proj.pID)
12+
delete_all_collaborators(proj.pID)
1913
if proj.status == cfg["projectStatus"]["Pending"]:
2014
flash("Application has already been submited.")
2115
return redirect(url_for("main_with_username", username = g.user.username))

api/static/js/pages/collaborations.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,12 @@ function checkValidUsername (id) {
6161
.on ('success', setUsernameStatus(id) )
6262
.go();
6363

64+
};
65+
66+
67+
function submitData() {
68+
console.log($("#collabForm"));
69+
/* Ajax the data to /budget */
70+
$("#collabForm")[0].submit();
71+
//console.log("Submitted");
6472
};

api/templates/pages/collaborations.html

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{% extends "base.html" %}
22
{% block title %} Collaborations {% endblock %}
3-
{% set currentPage = "Collaborations" %}
3+
{% set currentPage = "collaborations" %}
44

55
{% block body %}
66

@@ -18,7 +18,8 @@ <h1>Faculty Collaborator(s) </h1>
1818
</div>
1919

2020
<form class = "form-horizontal"
21-
action = "/collaborations"
21+
id = "collabForm"
22+
action = "/insertcollaborators"
2223
method = "POST"
2324
>
2425

@@ -37,7 +38,7 @@ <h4> <b> Collaborator #{{id + 1}} </b> </h4>
3738
{% for faculty in allFaculty %}
3839
{% if faculty.lastname != "" %} <!-- needed to remove test users -->
3940
{% if faculty.username != g.user.username %}
40-
<option title={{faculty.username}} value="{{faculty.fID}}">{{faculty.username}}; {{faculty.firstname}} {{faculty.lastname}}</option>
41+
<option title={{faculty.username}} value="{{faculty.username}}">{{faculty.username}}; {{faculty.firstname}} {{faculty.lastname}}</option>
4142
{% endif %}
4243
{% endif %}
4344
{% endfor %}
@@ -54,11 +55,11 @@ <h4> <b> Collaborator #{{id + 1}} </b> </h4>
5455
</div>
5556

5657

57-
<div class = "col-sm-offset-9 col-sm-2" id = "submitButton">
58-
<button id = "submit"
59-
type = "submit"
60-
class="btn btn-block btn-success form-control"
61-
type="submit"
58+
<div class = "col-sm-offset-9 col-sm-2" id = "submit_Button">
59+
<button id = "submitbutton"
60+
type = "button"
61+
class="btn btn-block btn-success"
62+
onclick= "submitData()"
6263
/>
6364
Submit
6465
</button>

0 commit comments

Comments
 (0)