7 Commits

Author SHA1 Message Date
cda12028c1 make Makefile
Every project should have a Makefile ;)
2024-06-10 20:23:57 +02:00
7ea0a7ddb7 fix typo 2024-06-10 20:23:08 +02:00
a2ec1aeebd fix typo 2024-02-14 00:25:59 +01:00
004b1a1c37 Merge branch 'fix/relative-path-and-docs' 2024-02-14 00:05:04 +01:00
48e98cbfc3 add more user input santitation 2024-02-14 00:04:00 +01:00
e632ca23a5 Merge pull request 'Changed to relative path and updated the documentation' (#6) from fix/relative-path-and-docs into master
Reviewed-on: #6
2024-01-28 19:50:48 +00:00
coja
6739e997bc Changed to relative path and updated the documentation 2024-01-21 13:16:44 +01:00
4 changed files with 38 additions and 6 deletions

19
Makefile Normal file
View File

@@ -0,0 +1,19 @@
VENV = venv
PYTHON = $(VENV)/bin/python3
PIP = $(VENV)/bin/pip
run: $(VENV)/bin/activate
$(PYTHON) init_db.py
$(PYTHON) run.py
$(VENV)/bin/activate: requirements.txt
python3 -m venv $(VENV)
$(PIP) install -r requirements.txt
clean:
rm -rf __pycache__
rm -rf $(VENV)
rm -r taskmanager/__pycache__/
rm instance/taskmanager.db

View File

@@ -10,12 +10,21 @@ Install python and pip on local machine
pip install virtualenv
python -m venv venv #/path/to/new/virtual/environment
source venv/bin/activate #activate virtual env
pip install -r requirements.txt
pip install -r requirments.txt
python3 ./init_db.py #initialize database
python3 ./run.py #run project
```
# On database changes
Delete file `/instance/taskmanager.db`
And reinit the db
```shell
python3 ./init_db.py
```
# Build app
```bash

View File

@@ -1,10 +1,14 @@
import configparser
import os
from flask import render_template, request, redirect
from taskmanager import app, db
from taskmanager.functions import *
from taskmanager.models import *
import configparser
CONFIG_PATH = "/var/taskmanager/taskmanager/config.ini"
PROJECT_PATH = os.path.abspath(os.path.dirname(__file__))
CONFIG_PATH = os.path.join(PROJECT_PATH, "config.ini")
config = configparser.ConfigParser()
config.read(CONFIG_PATH)
@@ -25,7 +29,7 @@ def addtask():
username = request.form['username']
# Input sanitation
# Task name
if not taskname.isprintable():
if not taskname.isprintable() or ("<" in taskname and ">" in taskname):
return render_template('pages/response.html', response = "Task name has to be made only of letters or numbers.")
if len(taskname) < 1 or len(taskname) > 40:
return render_template('pages/response.html', response = "Task name lenght invalid, only smaller then 40 charachters allowed")
@@ -43,7 +47,7 @@ def addtask():
# Task descripton
if taskdesc != '':
if not taskdesc.isprintable():
if not taskdesc.isprintable() or ("<" in taskdesc and ">" in taskdesc):
return render_template('pages/response.html', response = "Task description has to be made of printable characters.")
if len(taskdesc) > 2000:
return render_template('pages/response.html', response = "Task description lenght invalid, only smaller then 2000 charachters allowed")
@@ -72,7 +76,7 @@ def register():
# Contact
if contact != '':
if not contact.isprintable():
if not contact.isprintable() or ("<" in contact and ">" in contact):
return render_template('pages/response.html', response = "Contact information has to be made of printable characters.")
if len(contact) > 100:
return render_template('pages/response.html', response = "Contact lenght invalid, only smaller then 100 charachters allowed")