Skip to content

Commit

Permalink
adding profile add to frontend and change button styling
Browse files Browse the repository at this point in the history
  • Loading branch information
ooemperor committed Nov 23, 2023
1 parent 8d98305 commit d3c0f36
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 6 deletions.
15 changes: 14 additions & 1 deletion codeGrader/frontend/admin/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from codeGrader.frontend.admin.handlers import AdminUserLoginHandler, AdminUserSessionHandler, SessionAdminUser, \
UserListHandler, UserHandler, HomeHandler, AdminUserListHandler, AdminUserHandler, ProfileListHandler, \
ProfileHandler, SubjectListHandler, SubjectHandler, TaskHandler, TaskListHandler, ExerciseHandler, \
ExerciseListHandler, AddAdminUserHandler
ExerciseListHandler, AddAdminUserHandler, AddProfileHandler

app = Flask(config.adminAppName, template_folder=templates.__path__[0])

Expand Down Expand Up @@ -170,6 +170,19 @@ def profiles():
return ProfileListHandler(request).get()


@app.route("/addProfile", methods=['GET', 'POST'])
@login_required
def addProfile():
"""
Site to add a Profile
@return: Rendered Profile site or redirect
"""
if request.method == 'GET':
return AddProfileHandler(request).get()
elif request.method == 'POST':
return AddProfileHandler(request).post()


@app.route("/subject/<int:id_>", methods=['GET', 'POST'])
@login_required
def subject(id_):
Expand Down
38 changes: 38 additions & 0 deletions codeGrader/frontend/admin/handlers/Profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,41 @@ def post(self, id_: int):
self.api.put(f"/profile/{id_}", body=profile_data)

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


class AddProfileHandler(BaseHandler):
"""
Class to handle the operations of creating a user.
"""

def __init__(self, request: flask.Request):
"""
Constructor of the AddProfile Handler
@param request: The request from the app route of flask
@type request: flask.Request
"""
super().__init__(request)

def get(self):
"""
Render the template for adding
@return: The rendered page
"""

return render_template("addProfile.html")

def post(self):
"""
Post Operation
get the data out of the request and create the profile in the backend via api
@return: redirect to another page
"""

profile_data = dict()

profile_data["name"] = self.get("name")
profile_data["tag"] = self.get_value("tag")

self.api.post("/addProfile", body=profile_data)

return redirect("profiles")
4 changes: 2 additions & 2 deletions codeGrader/frontend/admin/handlers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
from .User import UserListHandler, UserHandler
from .Home import HomeHandler
from .AdminUser import AdminUserListHandler, AdminUserHandler, AddAdminUserHandler
from .Profile import ProfileHandler, ProfileListHandler
from .Profile import ProfileHandler, ProfileListHandler, AddProfileHandler
from .Subject import SubjectHandler, SubjectListHandler
from .Task import TaskHandler, TaskListHandler
from .Exercise import ExerciseHandler, ExerciseListHandler

__all__ = ["AdminUserLoginHandler", "AdminUserSessionHandler", "SessionAdminUser", "UserListHandler", "UserHandler",
"HomeHandler", "AdminUserHandler", "AdminUserListHandler", "ProfileListHandler", "ProfileHandler",
"SubjectListHandler", "SubjectHandler", "ExerciseListHandler", "ExerciseHandler", "TaskHandler",
"TaskListHandler", "AddAdminUserHandler"]
"TaskListHandler", "AddAdminUserHandler", "AddProfileHandler"]
8 changes: 7 additions & 1 deletion codeGrader/frontend/admin/static/css/styling.css
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,20 @@ body {

/*Buttons btn start*/
.btn {
background-color: #04AA6D; /* Green */
background-color: #04AA6D;
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
color: rgb(32,33,36);
}

.btn:hover {
background-color: #808080;
color: rgb(32,33,36);
}

.btn-menu {
Expand Down
4 changes: 2 additions & 2 deletions codeGrader/frontend/admin/templates/addAdminUser.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
<div id="main" class="main">
<span id="main-menu-button" class="btn-menu" onclick="openNav()">&equiv;</span>
<div>
<h1 class="header1 core_content">Admin User {{ username }}</h1>
<h1 class="header1 core_content">Admin User</h1>
</div>
<p class="core_content">Admin User {{ username }}</p>
<p class="core_content">Admin User</p>

<form action="{{url_for('addAdminUser')}}" method="POST" class="core_content">
<div id="admin_user_data">
Expand Down
34 changes: 34 additions & 0 deletions codeGrader/frontend/admin/templates/addProfile.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{% extends "base.html" %}

{% block core %}
<!-- Add all page content inside this div if you want the side nav to push page content to the right (not used if you only want the sidenav to sit on top of the page -->
<div id="main" class="main">
<span id="main-menu-button" class="btn-menu" onclick="openNav()">&equiv;</span>
<div>
<h1 class="header1 core_content">Profile</h1>
</div>
<p class="core_content">Profile</p>

<form action="{{url_for('addProfile')}}" method="POST" class="core_content">
<div id="profile_data">
<table class="vertical_table">
<tr>
<td class="data">Name</td>
<td class="data">
<input type="text" class="input" id="input_name" name="name" placeholder="Profile Name"">
</td>
</tr>
<tr>
<td class="data">Tag</td>
<td class="data">
<input type="text" class="input" id="input_tag" name="tag" placeholder="Profile Tag">
</td>
</tr>
</table>
</div>
<div id="control_buttons">
<button id="btn_submit" class="btn_submit" type="submit">Submit</button>
</div>
</form>
</div>
{% endblock core %}
7 changes: 7 additions & 0 deletions codeGrader/frontend/admin/templates/profiles.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ <h1 class="header1 core_content">Profile</h1>
</div>
<p class="core_content">Profile</p>

<div>
<form action="{{ url_for('addProfile') }}" method="GET">
<button class="btn btn_create" type="submit">New Profile</button>
</form>

</div>

<table class="core_content table">
<tr>
<th class="head">Name</th>
Expand Down

0 comments on commit d3c0f36

Please sign in to comment.