| @@ -27,6 +27,23 @@ def get_projects_by_status_and_category(categoryid, project_status): | |||||
| projects = cursor.fetchall() | projects = cursor.fetchall() | ||||
| return projects | return projects | ||||
| def get_projects_by_status_and_owner(userid, project_status): | |||||
| cursor = db.cursor() | |||||
| query = ("SELECT * FROM projects WHERE project_status = \"" + | |||||
| project_status + "\" AND userid = \"" + userid + "\"") | |||||
| cursor.execute(query) | |||||
| projects = cursor.fetchall() | |||||
| return projects | |||||
| def get_projects_by_participant_and_status(userid, project_status): | |||||
| cursor = db.cursor() | |||||
| query = ("SELECT * FROM projects, projects_users WHERE projects.project_status = \"" + | |||||
| project_status + "\" AND projects_users.userid = \"" + userid + | |||||
| "\" AND projects_users.projectid = projects.projectid") | |||||
| cursor.execute(query) | |||||
| projects = cursor.fetchall() | |||||
| return projects | |||||
| def set_waiting_task(projectid, title, task_description, budget): | def set_waiting_task(projectid, title, task_description, budget): | ||||
| cursor = db.cursor() | cursor = db.cursor() | ||||
| query = ("INSERT INTO tasks (pjojectid, title, task_description, budget) VALUES (\"" + | query = ("INSERT INTO tasks (pjojectid, title, task_description, budget) VALUES (\"" + | ||||
| @@ -27,7 +27,7 @@ body { | |||||
| margin: auto; | margin: auto; | ||||
| } | } | ||||
| h1 { | |||||
| h1, h3 { | |||||
| margin: auto; | margin: auto; | ||||
| } | } | ||||
| @@ -69,4 +69,14 @@ nav ul { | |||||
| text-align: center; | text-align: center; | ||||
| padding: 14px 16px; | padding: 14px 16px; | ||||
| text-decoration: none; | text-decoration: none; | ||||
| } | |||||
| #user_projects { | |||||
| display: flex; /* or inline-flex */ | |||||
| flex-direction: row; | |||||
| margin: auto; | |||||
| } | |||||
| .user_projects_category { | |||||
| border: 1px solid black; | |||||
| } | } | ||||
| @@ -1,4 +1,4 @@ | |||||
| $def with (nav) | |||||
| $def with (nav, project_bulk_one, project_bulk_two, projects) | |||||
| <head> | <head> | ||||
| <title>Beelance2</title> | <title>Beelance2</title> | ||||
| @@ -11,8 +11,33 @@ $def with (nav) | |||||
| $:nav | $:nav | ||||
| <h1>Welcome $session.username!</h1> | |||||
| <img src="static/honeybee.png" alt="Honeybee"> | <img src="static/honeybee.png" alt="Honeybee"> | ||||
| <h3>What would you like to do today?</h3> | |||||
| <div id="user_projects"> | |||||
| <div class="user_projects_category" onclick="location.href='/?projects=my'">My Projects</div> | |||||
| <div class="user_projects_category" onclick="location.href='/?projects=customer'">Customer Projects</div> | |||||
| <div class="user_projects_category" onclick="location.href='/?projects=finished'">Finished Projects</div> | |||||
| </div> | |||||
| $if projects == 'my': | |||||
| <h3>Your open projects</h3> | |||||
| <div class="projects"> | |||||
| $for project in project_bulk_one: | |||||
| <div class="project"><h4>$project[3]</h4><p>$project[4]</p></div> | |||||
| </div> | |||||
| $if projects == 'my': | |||||
| <h3>Projects in progress</h3> | |||||
| <div class="projects"> | |||||
| $for project in project_bulk_two: | |||||
| <div class="project"><h4>$project[3]</h4><p>$project[4]</p></div> | |||||
| </div> | |||||
| </body> | </body> | ||||
| @@ -7,6 +7,7 @@ from views.register import Register | |||||
| from views.admin import Admin | from views.admin import Admin | ||||
| from views.project import Project | from views.project import Project | ||||
| from views.my_projects import My_projects | from views.my_projects import My_projects | ||||
| import models.project | |||||
| # Define application routes | # Define application routes | ||||
| urls = ( | urls = ( | ||||
| @@ -48,4 +49,17 @@ class Index: | |||||
| # Get main page | # Get main page | ||||
| def GET(self): | def GET(self): | ||||
| nav = get_nav_bar(session) | nav = get_nav_bar(session) | ||||
| return render.index(nav) | |||||
| data = web.input(projects=None) | |||||
| project_bulk_one = [] | |||||
| project_bulk_two = [] | |||||
| if data.projects == 'my': | |||||
| project_bulk_one = models.project.get_projects_by_status_and_owner(str(session.userid), "open") | |||||
| project_bulk_two = models.project.get_projects_by_status_and_owner(str(session.userid), "in progress") | |||||
| elif data.projects == 'customer': | |||||
| project_bulk_one = models.project.get_projects_by_participant_and_status(str(session.userid), "open") | |||||
| project_bulk_two = models.project.get_projects_by_participant_and_status(str(session.userid), "in progress") | |||||
| elif data.projects == 'finished': | |||||
| project_bulk_one = models.project.get_projects_by_status_and_owner(str(session.userid), "finished") | |||||
| project_bulk_two = models.project.get_projects_by_participant_and_status(str(session.userid), "finished") | |||||
| return render.index(nav, project_bulk_one, project_bulk_two, data.projects) | |||||