-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding first draft of a big part of the templates and handlers
- Loading branch information
Showing
15 changed files
with
488 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
""" | ||
Handlers for the rendering of exercise | ||
@author: mkaiser | ||
""" | ||
|
||
import flask | ||
from flask import request, render_template, redirect, url_for | ||
from .Base import BaseHandler | ||
|
||
|
||
class ExerciseListHandler(BaseHandler): | ||
def __init(self, request: flask.Request): | ||
""" | ||
Constructor of the exerciseListHandler | ||
Will Render the HTML Template for all the exercises. | ||
""" | ||
super().__init__(request) | ||
|
||
def get(self): | ||
""" | ||
Renders the template for the exercises site. | ||
@return: The rendered template | ||
@rtype: HTML | ||
""" | ||
exercises = self.api.get("/exercises") | ||
return render_template("exercises.html", **exercises) | ||
|
||
|
||
class ExerciseHandler(BaseHandler): | ||
""" | ||
Handles the operation on a single exercise | ||
""" | ||
|
||
def __init__(self, request: flask.Request): | ||
""" | ||
Constructor of the exercise Handler | ||
@param request: The request from the app route of flask | ||
@type request: flask.Request | ||
""" | ||
super().__init__(request) | ||
|
||
def get(self, id_: int): | ||
""" | ||
Get and render the page for a given exercise by its id | ||
@param id_: The id of the exercise | ||
@type id_: int | ||
@return: The rendered page of the exercise | ||
@rtype: HTML | ||
""" | ||
exercise = self.api.get(f"/exercise/{id_}") | ||
return render_template("exercise.html", **exercise) | ||
|
||
def post(self, id_: int): | ||
""" | ||
Handler for the update of an exercise | ||
@param id_: The identifier of the exercise | ||
@return: | ||
""" | ||
assert self.request.form is not None | ||
exercise_data = dict() | ||
|
||
exercise_data["name"] = self.get_value("name") | ||
exercise_data["tag"] = self.get_value("tag") | ||
|
||
# getting the data from the form provided in the request | ||
self.api.put(f"/exercise/{id_}", body=exercise_data) | ||
|
||
return redirect(url_for("exercise", id_=id_)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
""" | ||
Handlers for the rendering of Subjects | ||
@author: mkaiser | ||
""" | ||
|
||
import flask | ||
from flask import request, render_template, redirect, url_for | ||
from .Base import BaseHandler | ||
|
||
|
||
class SubjectListHandler(BaseHandler): | ||
def __init(self, request: flask.Request): | ||
""" | ||
Constructor of the SubjectListHandler | ||
Will Render the HTML Template for all the subjects. | ||
""" | ||
super().__init__(request) | ||
|
||
def get(self): | ||
""" | ||
Renders the template for the Subjects site. | ||
@return: The rendered template | ||
@rtype: HTML | ||
""" | ||
subjects = self.api.get("/subjects") | ||
return render_template("subjects.html", **subjects) | ||
|
||
|
||
class SubjectHandler(BaseHandler): | ||
""" | ||
Handles the operation on a single Subject | ||
""" | ||
|
||
def __init__(self, request: flask.Request): | ||
""" | ||
Constructor of the Subject Handler | ||
@param request: The request from the app route of flask | ||
@type request: flask.Request | ||
""" | ||
super().__init__(request) | ||
|
||
def get(self, id_: int): | ||
""" | ||
Get and render the page for a given subject by its id | ||
@param id_: The id of the subject | ||
@type id_: int | ||
@return: The rendered page of the subject | ||
@rtype: HTML | ||
""" | ||
subject = self.api.get(f"/subject/{id_}") | ||
return render_template("subject.html", **subject) | ||
|
||
def post(self, id_: int): | ||
""" | ||
Handler for the update of a subject | ||
@param id_: The identifier of the subject | ||
@return: | ||
""" | ||
assert self.request.form is not None | ||
subject_data = dict() | ||
|
||
subject_data["name"] = self.get_value("name") | ||
subject_data["tag"] = self.get_value("tag") | ||
|
||
# getting the data from the form provided in the request | ||
self.api.put(f"/subject/{id_}", body=subject_data) | ||
|
||
return redirect(url_for("subject", id_=id_)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
""" | ||
Handlers for the rendering of Task | ||
@author: mkaiser | ||
""" | ||
|
||
import flask | ||
from flask import request, render_template, redirect, url_for | ||
from .Base import BaseHandler | ||
|
||
|
||
class TaskListHandler(BaseHandler): | ||
def __init(self, request: flask.Request): | ||
""" | ||
Constructor of the TaskListHandler | ||
Will Render the HTML Template for all the tasks. | ||
""" | ||
super().__init__(request) | ||
|
||
def get(self): | ||
""" | ||
Renders the template for the tasks site. | ||
@return: The rendered template | ||
@rtype: HTML | ||
""" | ||
tasks = self.api.get("/tasks") | ||
return render_template("tasks.html", **tasks) | ||
|
||
|
||
class TaskHandler(BaseHandler): | ||
""" | ||
Handles the operation on a single task | ||
""" | ||
|
||
def __init__(self, request: flask.Request): | ||
""" | ||
Constructor of the task Handler | ||
@param request: The request from the app route of flask | ||
@type request: flask.Request | ||
""" | ||
super().__init__(request) | ||
|
||
def get(self, id_: int): | ||
""" | ||
Get and render the page for a given task by its id | ||
@param id_: The id of the task | ||
@type id_: int | ||
@return: The rendered page of the task | ||
@rtype: HTML | ||
""" | ||
task = self.api.get(f"/task/{id_}") | ||
return render_template("task.html", **task) | ||
|
||
def post(self, id_: int): | ||
""" | ||
Handler for the update of a task | ||
@param id_: The identifier of the task | ||
@return: | ||
""" | ||
assert self.request.form is not None | ||
task_data = dict() | ||
|
||
task_data["name"] = self.get_value("name") | ||
task_data["tag"] = self.get_value("tag") | ||
|
||
# getting the data from the form provided in the request | ||
self.api.put(f"/task/{id_}", body=task_data) | ||
|
||
return redirect(url_for("task", id_=id_)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()">≡</span> | ||
<div> | ||
<h1 class="header1 core_content">Exercise {{ name }}</h1> | ||
</div> | ||
<p class="core_content">Exercise {{ name }}</p> | ||
|
||
<form action="{{url_for('exercise', id_ = id)}}" method="POST" class="core_content"> | ||
<div id="exercise_data"> | ||
<table class="vertical_table"> | ||
<tr> | ||
<td class="data">Name</td> | ||
<td class="data"> | ||
<input type="text" id="input_name" name="name" value="{{ name }}"> | ||
</td> | ||
</tr> | ||
<tr> | ||
<td class="data">Tag</td> | ||
<td class="data"> | ||
<input type="text" id="input_tag" name="tag" value="{{ 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 %} |
Oops, something went wrong.