mirror of
https://codeberg.org/Mo8it/AdvLabDB.git
synced 2024-11-08 21:21:06 +00:00
Added some routes, untils.py, some initial html pages and Bootsrap
This commit is contained in:
parent
3db3f20fb2
commit
d06edf7e9c
13 changed files with 115 additions and 8 deletions
|
@ -1,5 +1,38 @@
|
||||||
from advlabdb import app
|
from advlabdb import app
|
||||||
|
from flask import render_template, request, url_for
|
||||||
|
from advlabdb.utils import *
|
||||||
|
|
||||||
@app.route("/")
|
@app.route("/")
|
||||||
def index():
|
def index():
|
||||||
return "Welcome on AdvLabDB!"
|
page = "index"
|
||||||
|
return render_template(page + ".html", navbarItems=navbarItems(page))
|
||||||
|
|
||||||
|
@app.route("/students")
|
||||||
|
def students():
|
||||||
|
page = "students"
|
||||||
|
return render_template(page + ".html", navbarItems=navbarItems(page))
|
||||||
|
|
||||||
|
@app.route("/assistants")
|
||||||
|
def assistants():
|
||||||
|
page = "assistants"
|
||||||
|
return render_template(page + ".html", navbarItems=navbarItems(page))
|
||||||
|
|
||||||
|
@app.route("/experiments")
|
||||||
|
def experiments():
|
||||||
|
page = "experiments"
|
||||||
|
return render_template(page + ".html", navbarItems=navbarItems(page))
|
||||||
|
|
||||||
|
@app.route("/appointments")
|
||||||
|
def appointments():
|
||||||
|
page = "appointments"
|
||||||
|
return render_template(page + ".html", navbarItems=navbarItems(page))
|
||||||
|
|
||||||
|
@app.route("/groups")
|
||||||
|
def groups():
|
||||||
|
page = "groups"
|
||||||
|
return render_template(page + ".html", navbarItems=navbarItems(page))
|
||||||
|
|
||||||
|
@app.route("/users")
|
||||||
|
def users():
|
||||||
|
page = "users"
|
||||||
|
return render_template(page + ".html", navbarItems=navbarItems(page))
|
||||||
|
|
3
advlabdb/templates/appointments.html
Normal file
3
advlabdb/templates/appointments.html
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
{% extends "layout.html" %}
|
||||||
|
{% block content %}
|
||||||
|
{% endblock content %}
|
3
advlabdb/templates/assistants.html
Normal file
3
advlabdb/templates/assistants.html
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
{% extends "layout.html" %}
|
||||||
|
{% block content %}
|
||||||
|
{% endblock content %}
|
3
advlabdb/templates/experiments.html
Normal file
3
advlabdb/templates/experiments.html
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
{% extends "layout.html" %}
|
||||||
|
{% block content %}
|
||||||
|
{% endblock content %}
|
3
advlabdb/templates/groups.html
Normal file
3
advlabdb/templates/groups.html
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
{% extends "layout.html" %}
|
||||||
|
{% block content %}
|
||||||
|
{% endblock content %}
|
4
advlabdb/templates/index.html
Normal file
4
advlabdb/templates/index.html
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
{% extends "layout.html" %}
|
||||||
|
{% block content %}
|
||||||
|
Welcome on AdvLabDB!
|
||||||
|
{% endblock content %}
|
36
advlabdb/templates/layout.html
Normal file
36
advlabdb/templates/layout.html
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<!-- Required meta tags -->
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
|
||||||
|
<!-- Bootstrap CSS -->
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BmbxuPwQa2lc/FVzBcNJ7UAyJxM6wuqIj61tLrc4wSX0szH/Ev+nYRRuWlolflfl" crossorigin="anonymous">
|
||||||
|
|
||||||
|
{% if title %}
|
||||||
|
<title>{{title}}</title>
|
||||||
|
{% else %}
|
||||||
|
<title>AdvLabDB</title>
|
||||||
|
{% endif %}
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<nav class="navbar navbar-expand-lg navbar-light bg-light">
|
||||||
|
<div class="container-fluid">
|
||||||
|
<a class="navbar-brand" href="{{url_for('index')}}">AdvLabDB</a>
|
||||||
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNavAltMarkup" aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation">
|
||||||
|
<span class="navbar-toggler-icon"></span>
|
||||||
|
</button>
|
||||||
|
<div class="collapse navbar-collapse" id="navbarNavAltMarkup">
|
||||||
|
<div class="navbar-nav">
|
||||||
|
{{navbarItems|safe}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
{% block content %}{% endblock content %}
|
||||||
|
|
||||||
|
<!-- Bootstrap Bundle with Popper -->
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta2/dist/js/bootstrap.bundle.min.js" integrity="sha384-b5kHyXgcpbZJO/tY9Ul7kGkf1S0CWuKcCD38l8YkeH8z8QjE0GmW1gYU5S9FOnJ0" crossorigin="anonymous"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
3
advlabdb/templates/students.html
Normal file
3
advlabdb/templates/students.html
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
{% extends "layout.html" %}
|
||||||
|
{% block content %}
|
||||||
|
{% endblock content %}
|
3
advlabdb/templates/users.html
Normal file
3
advlabdb/templates/users.html
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
{% extends "layout.html" %}
|
||||||
|
{% block content %}
|
||||||
|
{% endblock content %}
|
10
advlabdb/utils.py
Normal file
10
advlabdb/utils.py
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
def navbarItems(activePage):
|
||||||
|
pages = ["Students", "Assistants", "Experiments", "Appointments", "Groups", "Users"]
|
||||||
|
items = ""
|
||||||
|
for page in pages:
|
||||||
|
active = ""
|
||||||
|
lowerPage = page.lower().replace(" ", "_")
|
||||||
|
if lowerPage == activePage:
|
||||||
|
active = " active"
|
||||||
|
items += '<a class="nav-link' + active + '" href="' + lowerPage + '">' + page + '</a>\n'
|
||||||
|
return items
|
4
poetry.lock
generated
4
poetry.lock
generated
|
@ -101,8 +101,8 @@ watchdog = ["watchdog"]
|
||||||
|
|
||||||
[metadata]
|
[metadata]
|
||||||
lock-version = "1.1"
|
lock-version = "1.1"
|
||||||
python-versions = "^3.9"
|
python-versions = "^3.8"
|
||||||
content-hash = "6bef6d6f4639eb91713858a87c48769c41232753299fd7b5846e7b18f3950ddd"
|
content-hash = "8462227db94bf1e53825a934934960f64010d387c302dc71a359123acdff0be9"
|
||||||
|
|
||||||
[metadata.files]
|
[metadata.files]
|
||||||
click = [
|
click = [
|
||||||
|
|
|
@ -5,7 +5,7 @@ description = "DB for the advanced physics lab on JGU-Mainz."
|
||||||
authors = ["Mohamad Bitar <mohamad.bit@protonmail.com>"]
|
authors = ["Mohamad Bitar <mohamad.bit@protonmail.com>"]
|
||||||
|
|
||||||
[tool.poetry.dependencies]
|
[tool.poetry.dependencies]
|
||||||
python = "^3.9"
|
python = "^3.8"
|
||||||
Flask = "^1.1.2"
|
Flask = "^1.1.2"
|
||||||
Flask-SQLAlchemy = "^2.4.4"
|
Flask-SQLAlchemy = "^2.4.4"
|
||||||
SQLAlchemy = "<1.4"
|
SQLAlchemy = "<1.4"
|
||||||
|
|
14
testDB.py
14
testDB.py
|
@ -1,4 +1,4 @@
|
||||||
from advlabdb import *
|
from advlabdb import db
|
||||||
from advlabdb.models import *
|
from advlabdb.models import *
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
|
@ -37,9 +37,11 @@ db.session.add(ps1)
|
||||||
db.session.add(ps2)
|
db.session.add(ps2)
|
||||||
db.session.add(ps3)
|
db.session.add(ps3)
|
||||||
|
|
||||||
ex1 = Experiment(name="exp", room="123", building="phy", responsibility="none", duration_in_days=2, oral_weighting=0.5, protocol_weighting=0.5, final_weighting=1)
|
ex1 = Experiment(name="exp", room="123", building="phy", responsibility="none", duration_in_days=2,
|
||||||
|
oral_weighting=0.5, protocol_weighting=0.5, final_weighting=1)
|
||||||
|
|
||||||
ex2 = Experiment(name="exp2", room="123", building="phy", responsibility="none", duration_in_days=2, oral_weighting=0.5, protocol_weighting=0.5, final_weighting=1)
|
ex2 = Experiment(name="exp2", room="123", building="phy", responsibility="none", duration_in_days=2,
|
||||||
|
oral_weighting=0.5, protocol_weighting=0.5, final_weighting=1)
|
||||||
|
|
||||||
db.session.add(ex1)
|
db.session.add(ex1)
|
||||||
db.session.add(ex2)
|
db.session.add(ex2)
|
||||||
|
@ -62,9 +64,13 @@ us2 = User(email="test2@test.com", password_hash="h2")
|
||||||
db.session.add(us1)
|
db.session.add(us1)
|
||||||
db.session.add(us2)
|
db.session.add(us2)
|
||||||
|
|
||||||
as1 = Assistant(first_name="As1", last_name="l", email="test@test.com", phone_number="012333212", mobile_phone_number="012334123", user=us1)
|
as1 = Assistant(first_name="As1", last_name="l", email="test@test.com", phone_number="012333212",
|
||||||
|
mobile_phone_number="012334123", user=us1)
|
||||||
as2 = Assistant(first_name="As2", last_name="l", email="test2@test.com", user=us1)
|
as2 = Assistant(first_name="As2", last_name="l", email="test2@test.com", user=us1)
|
||||||
|
|
||||||
|
as1.part_experiments.append(px1)
|
||||||
|
as2.part_experiments.append(px2)
|
||||||
|
|
||||||
db.session.add(as1)
|
db.session.add(as1)
|
||||||
db.session.add(as2)
|
db.session.add(as2)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue