Skip to content

Commit

Permalink
adding first draft of profile support on the admin user
Browse files Browse the repository at this point in the history
  • Loading branch information
ooemperor committed Nov 21, 2023
1 parent ddf5df4 commit df79f1f
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
5 changes: 4 additions & 1 deletion codeGrader/frontend/admin/handlers/AdminUser.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ def get(self, id_: int):
admin_types = self.api.get(f"/adminTypes")
admin["types"] = admin_types["admin_type"]

profiles = self.api.get(f"/profiles")
admin["profiles"] = profiles["profile"]

return render_template("adminUser.html", **admin)

def post(self, id_: int):
Expand All @@ -76,7 +79,7 @@ def post(self, id_: int):
admin_data["email"] = self.get_value("email")
admin_data["tag"] = self.get_value("tag")
admin_data["admin_type"] = self.get_value("admin_type")
print(admin_data)



self.api.put(f"/adminUser/{id_}", body=admin_data)
Expand Down
20 changes: 20 additions & 0 deletions codeGrader/frontend/admin/handlers/Task.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,23 @@ def post(self, id_: int):
self.api.put(f"/task/{id_}", body=task_data)

return redirect(url_for("task", id_=id_))

def create(self):
"""
Create a User in the database
@return:
"""
user_data = dict()

user_data["username"] = self.get_value("username")
user_data["first_name"] = self.get_value("first_name")
user_data["last_name"] = self.get_value("last_name")
user_data["email"] = self.get_value("email")
user_data["tag"] = self.get_value("tag")
user_data["profile"] = self.get_value("profile")

response_text = self.api.post("/addUser", body=user_data)

id_ = response_text["response"]["id"]

return redirect(url_for("user", id_=id_))
18 changes: 18 additions & 0 deletions codeGrader/frontend/admin/templates/adminUser.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,24 @@ <h1 class="header1 core_content">Admin User {{ username }}</h1>
</select>
</td>
</tr>
<tr>
<td class="data">Admin Profile</td>
<td class="data">
<select id="sel_profile" name="profile">
{% for prof in profiles %}
{% if prof['id'] == profile['id'] %}
<option value="{{ prof['id'] }}" selected>
{{ prof['name'] }}
</option>
{% else %}
<option value="{{ prof['id'] }}">
{{ prof['name'] }}
</option>
{% endif %}
{% endfor %}
</select>
</td>
</tr>
</table>
</div>
<div id="control_buttons">
Expand Down

0 comments on commit df79f1f

Please sign in to comment.