diff --git a/.gitignore b/.gitignore index d1323dc..87fe0d8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +### Database file +database.db + ### Python template # Byte-compiled / optimized / DLL files __pycache__/ diff --git a/.idea/BellScheduler.iml b/.idea/BellScheduler.iml index d0876a7..5d478fb 100644 --- a/.idea/BellScheduler.iml +++ b/.idea/BellScheduler.iml @@ -1,8 +1,10 @@ - - + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 7ba73c2..70c51bb 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,4 +1,7 @@ - + + + \ No newline at end of file diff --git a/app.py b/app.py new file mode 100644 index 0000000..d407ad0 --- /dev/null +++ b/app.py @@ -0,0 +1,53 @@ +import os +from flask import Flask, render_template, request, redirect, url_for +from flask_sqlalchemy import SQLAlchemy + +basedir = os.path.abspath(os.path.dirname(__file__)) + +app = Flask(__name__) +app.config['SQLALCHEMY_DATABASE_URI'] =\ + 'sqlite:///' + os.path.join(basedir, 'database.db') +app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False + + +db = SQLAlchemy(app) + +class Period(db.Model): + period = db.Column(db.Integer, primary_key=True) + periodTime = db.Column(db.Integer) + weekendSchedule = db.Column(db.Boolean) + + def __repr__(self): + return f'' + +class Task(db.Model): + id = db.Column(db.Integer, primary_key=True) + title = db.Column(db.String(100)) + description = db.Column(db.Text) + created_timestamp = db.Column(db.Integer) + due_timestamp = db.Column(db.Integer) + + def __repr__(self): + return f'' + +class Event(db.Model): + id = db.Column(db.Integer, primary_key=True) + scheduled_date = db.Column(db.String(100)) + period = db.relationship(Period, backref='events') + tasks = db.relationship(Task, backref='events') + period_num = db.Column(db.Integer, db.ForeignKey('period.period')) + task_id = db.Column(db.Integer, db.ForeignKey('task.id')) + + def __repr__(self): + return f'' + + +@app.route('/') +def index(): + events = Event.query.all() + return render_template('index.html', events=events) + +@app.route('/task//') +def task(task_id): + task = Task.query.get_or_404(task_id) + return render_template('task.html', task=task) \ No newline at end of file diff --git a/init_db.py b/init_db.py new file mode 100644 index 0000000..64ac6d7 --- /dev/null +++ b/init_db.py @@ -0,0 +1,65 @@ +from app import db, Period, Task, Event + + +period1 = Period(period=1, periodTime='08:30:00', weekendSchedule=True) +period2 = Period(period=2, periodTime='09:00:00', weekendSchedule=True) +period3 = Period(period=3, periodTime='09:30:00', weekendSchedule=True) +period4 = Period(period=4, periodTime='10:30:00', weekendSchedule=True) +period5 = Period(period=5, periodTime='11:00:00', weekendSchedule=True) +period6 = Period(period=6, periodTime='12:30:00', weekendSchedule=False) +period7 = Period(period=7, periodTime='13:45:00', weekendSchedule=False) +period8 = Period(period=8, periodTime='14:30:00', weekendSchedule=False) +period9 = Period(period=9, periodTime='15:30:00', weekendSchedule=False) + +task1 = Task(id=1, + title="Sexy ERP time", + description="Be the dominant partner and fuck so much XD", + created_timestamp='1668278862', due_timestamp='') +task2 = Task(id=2, title="Test task", + description="Test", + created_timestamp='1668278862', + due_timestamp='') +task3 = Task(id=3, title="La Nager", + description="Francis stuff", + created_timestamp='1668278862', + due_timestamp='') +task4 = Task(id=4, title="Ops/Tech Meeting", + description="HEIL GEORGE!", + created_timestamp='1668278862', + due_timestamp='') +task5 = Task(id=5, title="Tech Team Meeting", + description="Awkward AF", + created_timestamp='1668278862', + due_timestamp='') +task6 = Task(id=6, title="Write BellScheduler", + description="heh", + created_timestamp='1668278862', + due_timestamp='') +task7 = Task(id=7, title="Fap to cunny porn", + description="FBI OPEN UP!", + created_timestamp='1668278862', + due_timestamp='') +task8 = Task(id=8, title="Go on vrchat", + description="Mmm... virtual headpats!", + created_timestamp='1668278862', + due_timestamp='') +task9 = Task(id=9, title="Brush teeth", + description="Ya dont do that more often, ya gross fuck", + created_timestamp='1668278862', + due_timestamp='') + +event1 = Event(id=1, scheduled_date='11-12-2022', period_num=1, task_id=4) +event2 = Event(id=2, scheduled_date='11-12-2022', period_num=2, task_id=2) +event3 = Event(id=3, scheduled_date='11-12-2022', period_num=3, task_id=5) +event4 = Event(id=4, scheduled_date='11-12-2022', period_num=4, task_id=6) +event5 = Event(id=5, scheduled_date='11-12-2022', period_num=5, task_id=1) +event6 = Event(id=6, scheduled_date='11-12-2022', period_num=6, task_id=3) +event7 = Event(id=7, scheduled_date='11-12-2022', period_num=7, task_id=7) +event8 = Event(id=8, scheduled_date='11-12-2022', period_num=8, task_id=8) +event9 = Event(id=9, scheduled_date='11-12-2022', period_num=9, task_id=9) + +db.session.add_all([period1, period2, period3, period4, period5, period6, period7, period8, period9]) +db.session.add_all([task1, task2, task3, task4, task5, task6, task7, task8, task9]) +db.session.add_all([event1, event2, event3, event4, event5, event6, event7, event8, event9]) + +db.session.commit() \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..76bbfaf --- /dev/null +++ b/requirements.txt @@ -0,0 +1,22 @@ +# This file is used by pip to install required python packages +# Usage: pip install -r requirements.txt + +# Flask Framework +click==8.1.3 +Flask==2.2.2 +itsdangerous==2.1.2 +Jinja2==3.1.2 +MarkupSafe==2.1.1 +Werkzeug==2.2.2 + +# Flask Packages +Flask-Login==0.6.2 +Flask-Migrate==3.1.0 +Flask-Script==2.0.6 +Flask-SQLAlchemy==3.0.2 +Flask-WTF==1.0.1 +Flask-User==1.0.2.2 + +# Automated tests +pytest==7.2.0 +pytest-cov==4.0.0 diff --git a/templates/base.html b/templates/base.html new file mode 100644 index 0000000..9cd0b24 --- /dev/null +++ b/templates/base.html @@ -0,0 +1,52 @@ + + + + + {% block title %} {% endblock %} - BellScheduler + + + + +
+
+ {% block content %} {% endblock %} +
+ + \ No newline at end of file diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 0000000..792a1f1 --- /dev/null +++ b/templates/index.html @@ -0,0 +1,23 @@ +{% extends 'base.html' %} + +{% block content %} +

{% block title %} Events {% endblock %}

+
+ {% for event in events %} +
+

Period {{ event.period_num }}

+ +

+ + {{ event.tasks.title }} + +

+
+
+

{{ event.tasks.description }}

+
+
+
+ {% endfor %} +
+{% endblock %} \ No newline at end of file diff --git a/templates/task.html b/templates/task.html new file mode 100644 index 0000000..a0ddef6 --- /dev/null +++ b/templates/task.html @@ -0,0 +1,17 @@ +{% extends 'base.html' %} + +{% block content %} +

{% block title %} {{ task.title }} {% endblock %}

+
+
+

#{{ task.id }}

+ +

{{ task.title }}

+
+
+

{{ task.description }}

+
+
+
+
+{% endblock %} \ No newline at end of file