From 8322ac055aab72464506c98d6de1038d8ec32f74 Mon Sep 17 00:00:00 2001 From: jakobsn Date: Thu, 7 Nov 2019 20:09:47 +0100 Subject: [PATCH] Create projects --- mysql/sql/init.sql | 4 ++-- src/app/models/project.py | 8 ++++++++ src/app/templates/my_projects.html | 2 +- src/app/views/project.py | 9 +++------ 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/mysql/sql/init.sql b/mysql/sql/init.sql index b9903fa..8c5a8f4 100644 --- a/mysql/sql/init.sql +++ b/mysql/sql/init.sql @@ -78,8 +78,8 @@ CREATE TABLE projects_users ( CREATE TABLE tasks ( taskid INT UNSIGNED AUTO_INCREMENT, - projectid INT NOT NULL, - teamid INT UNSIGNED NOT NULL, + projectid UNSIGNED INT NOT NULL, + teamid INT UNSIGNED, title VARCHAR(200) NOT NULL, task_description VARCHAR(500), budget INT, diff --git a/src/app/models/project.py b/src/app/models/project.py index 50a67bc..6fd5018 100644 --- a/src/app/models/project.py +++ b/src/app/models/project.py @@ -26,3 +26,11 @@ def get_projects_by_status_and_category(categoryid, project_status): cursor.execute(query) projects = cursor.fetchall() return projects + +def set_waiting_task(projectid, title, task_description, budget): + cursor = db.cursor() + query = ("INSERT INTO tasks (pjojectid, title, task_description, budget) VALUES (\"" + + projectid + "\", \"" + title + "\", \"" + title + "\", \"" + + task_description + "\", \"" + budget + "\")") + cursor.execute(query) + diff --git a/src/app/templates/my_projects.html b/src/app/templates/my_projects.html index c6d7134..199df28 100644 --- a/src/app/templates/my_projects.html +++ b/src/app/templates/my_projects.html @@ -15,7 +15,7 @@ $def with (nav, categories, open_projects)
$for category in categories: -
$category[1]
+
$category[1]
diff --git a/src/app/views/project.py b/src/app/views/project.py index 132bc19..a3b6c7c 100644 --- a/src/app/views/project.py +++ b/src/app/views/project.py @@ -38,7 +38,8 @@ class Project: try: if data["Create Project"]: print("Create") - pass + models.project.set_waiting_task + else: pass except Exception as e: @@ -50,7 +51,7 @@ class Project: def get_task_count(self, data): task_count = 0 - print(len(data)) + # Remove the four other elements from count and divide by the number of variables in one task. task_count = int((len(data) - 4) / 3) """while True: try: @@ -64,18 +65,14 @@ class Project: def compose_form(self, data, add): task_count = self.get_task_count(data) # A task is either added or removed - print("init count", task_count) if not add and task_count >= 1: task_count -= 1 - - print("modded", task_count) project_form_elements = get_project_form_elements(data.project_title, data.project_description, data.category_name) task_form_elements = () old_task_form_element = () for i in range(0, task_count): - print(i, data) old_task_form_element = get_task_form_elements(i, data["task_title_"+str(i)], data["task_description_"+str(i)], data["budget_"+str(i)]) task_form_elements = (task_form_elements + old_task_form_element)