| @@ -130,7 +130,7 @@ CREATE TABLE task_offer ( | |||
| * Initial data | |||
| */ | |||
| insert into users values (NULL, "admin", "password", "Admin Modsen", "ntnu", 'mail@ntnu.no',"12345678", "street", "trondheim", "trondheim", "1234", "norway"); | |||
| insert into users values (NULL, "admin", "48bead1bb864138c2cafaf1bd41332ab", "Admin Modsen", "ntnu", 'mail@ntnu.no', "street", "trondheim", "trondheim", "1234", "norway"); | |||
| insert into project_category values (NULL, "Gardening"); | |||
| insert into project_category values (NULL, "Programming"); | |||
| @@ -1,10 +1,15 @@ | |||
| import mysql.connector | |||
| """ | |||
| Connect the webserver to the database using the python mysql connecter. | |||
| Change the host address depending on where the mysql server is running. To connect to the | |||
| preconfigured docker container address use the Docker address. The default port is 3306. | |||
| """ | |||
| db = mysql.connector.connect( | |||
| user='root', | |||
| password='root', | |||
| host='10.5.0.5', # Docker address | |||
| #host='0.0.0.0', # Local address | |||
| #host='10.5.0.5', # Docker address | |||
| host='0.0.0.0', # Local address | |||
| database='db' | |||
| ) | |||
| @@ -15,7 +15,8 @@ body { | |||
| } | |||
| .projects * { | |||
| margin: auto; | |||
| margin: auto; | |||
| padding: 2px; | |||
| min-width: 100px; | |||
| margin-top: 5px; | |||
| } | |||
| @@ -78,13 +79,13 @@ nav ul { | |||
| text-decoration: none; | |||
| } | |||
| #user_projects { | |||
| #user_projects, .categories { | |||
| display: flex; /* or inline-flex */ | |||
| flex-direction: row; | |||
| margin: auto; | |||
| } | |||
| .user_projects_category { | |||
| .user_projects_category, .category { | |||
| border: 1px solid gray; | |||
| padding: 5px; | |||
| background-color: lightslategray; | |||
| @@ -92,7 +93,7 @@ nav ul { | |||
| margin: 2px; | |||
| } | |||
| .user_projects_category:hover { | |||
| .user_projects_category:hover, .category:hover { | |||
| background-color: lightskyblue; | |||
| } | |||
| @@ -134,3 +135,12 @@ form { | |||
| button { | |||
| margin: 5px; | |||
| } | |||
| #dashboard { | |||
| display: flex; | |||
| flex-direction: column; | |||
| } | |||
| #dashboard * { | |||
| margin-bottom: 5px; | |||
| } | |||
| @@ -13,38 +13,39 @@ $def with (nav, project_bulk_one, project_bulk_two, projects, categories) | |||
| <h1>Welcome $session.username!</h1> | |||
| <img src="static/honeybee.png" alt="Honeybee"> | |||
| $if session.username: | |||
| <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 id="dashboard"> | |||
| <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> | |||
| $elif projects == 'customer': | |||
| <h3>Customer projects in progress</h3> | |||
| $elif projects == 'finished': | |||
| <h3>My finished projects</h3> | |||
| <div class="projects"> | |||
| $for project in project_bulk_one: | |||
| <div class="project" onclick="location.href='/project?projectid=$project[0]'"><h4>Title:    $project[3]</h4><p>Description: $project[4]</p><p>Category:   $categories[project[1]-1][1]</p></div> | |||
| </div> | |||
| $if projects == 'my': | |||
| <h3>Projects in progress</h3> | |||
| $elif projects == 'finished': | |||
| <h3>Finished customer projects</h3> | |||
| <div class="projects"> | |||
| $for project in project_bulk_two: | |||
| <div class="project" onclick="location.href='/project?projectid=$project[0]'"><h4>Title:    $project[3]</h4><p>Description: $project[4]</p><p>Category:   $categories[project[1]-1][1]</p></div> | |||
| </div> | |||
| </div> | |||
| $if projects == 'my': | |||
| <h3>Your open projects</h3> | |||
| $elif projects == 'customer': | |||
| <h3>Customer projects in progress</h3> | |||
| $elif projects == 'finished': | |||
| <h3>My finished projects</h3> | |||
| <div class="projects"> | |||
| $for project in project_bulk_one: | |||
| <div class="project" onclick="location.href='/project?projectid=$project[0]'"><h4>Title:    $project[3]</h4><p>Description: $project[4]</p><p>Category:   $categories[project[1]-1][1]</p></div> | |||
| </div> | |||
| $if projects == 'my': | |||
| <h3>Projects in progress</h3> | |||
| $elif projects == 'finished': | |||
| <h3>Finished customer projects</h3> | |||
| <div class="projects"> | |||
| $for project in project_bulk_two: | |||
| <div class="project" onclick="location.href='/project?projectid=$project[0]'"><h4>Title:    $project[3]</h4><p>Description: $project[4]</p><p>Category:   $categories[project[1]-1][1]</p></div> | |||
| </div> | |||
| <img src="static/honeybee.png" alt="Honeybee"> | |||
| </body> | |||
| @@ -1,4 +1,4 @@ | |||
| $def with (nav, login_form) | |||
| $def with (nav, login_form, message) | |||
| <head> | |||
| <title>Beelance2</title> | |||
| @@ -20,5 +20,9 @@ $def with (nav, login_form) | |||
| $else: | |||
| <h1>Logged in as $session.username</h1> | |||
| <p>$:message</p> | |||
| <img src="static/honeybee.png" alt="Honeybee"> | |||
| </body> | |||
| @@ -13,6 +13,7 @@ $def with (nav, categories, open_projects) | |||
| <h1 class="title">Open Projects:</h1> | |||
| <div class="categories"> | |||
| $for category in categories: | |||
| <div class="category" onclick="location.href='/open_projects?categoryid=$category[0]'">$category[1]</div> | |||
| @@ -26,6 +26,7 @@ $def with (nav, project_form, project, tasks, permissions, categories) | |||
| <ul> | |||
| $for task in tasks: | |||
| <hr> | |||
| <li id="$task[0]"> | |||
| <h3>Task: $task[2]</h3> | |||
| <p>Description: $task[3]</p> | |||
| @@ -26,7 +26,7 @@ class Login(): | |||
| # Log the user in if the rememberme cookie is set and valid | |||
| self.check_rememberme() | |||
| return render.login(nav, login_form) | |||
| return render.login(nav, login_form, "") | |||
| def POST(self): | |||
| """ | |||
| @@ -44,8 +44,9 @@ class Login(): | |||
| # If there is a matching user/password in the database the user is logged in | |||
| if user: | |||
| self.login(user[1], user[0], data.remember) | |||
| return render.login(nav, login_form) | |||
| raise web.seeother("/") | |||
| else: | |||
| return render.login(nav, login_form, "- User authentication failed") | |||
| def login(self, username, userid, remember): | |||
| """ | |||