From f23e31dfaa8818cd823cbc9030be28e86c5676d8 Mon Sep 17 00:00:00 2001 From: jakobsn Date: Mon, 2 Dec 2019 11:46:34 +0100 Subject: [PATCH] polish --- mysql/sql/init.sql | 2 +- src/app/models/database.py | 9 +++- src/app/static/stylesheet.css | 18 ++++++-- src/app/templates/index.html | 61 ++++++++++++++-------------- src/app/templates/login.html | 6 ++- src/app/templates/open_projects.html | 1 + src/app/templates/project.html | 1 + src/app/views/login.py | 7 ++-- 8 files changed, 64 insertions(+), 41 deletions(-) diff --git a/mysql/sql/init.sql b/mysql/sql/init.sql index 438e924..f3fd5f1 100644 --- a/mysql/sql/init.sql +++ b/mysql/sql/init.sql @@ -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"); diff --git a/src/app/models/database.py b/src/app/models/database.py index d3ef6df..317b0f8 100644 --- a/src/app/models/database.py +++ b/src/app/models/database.py @@ -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' ) \ No newline at end of file diff --git a/src/app/static/stylesheet.css b/src/app/static/stylesheet.css index 730db51..9bb8a68 100644 --- a/src/app/static/stylesheet.css +++ b/src/app/static/stylesheet.css @@ -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; +} \ No newline at end of file diff --git a/src/app/templates/index.html b/src/app/templates/index.html index 1f5f5e2..ad069ef 100644 --- a/src/app/templates/index.html +++ b/src/app/templates/index.html @@ -13,38 +13,39 @@ $def with (nav, project_bulk_one, project_bulk_two, projects, categories)

Welcome $session.username!

- Honeybee - $if session.username: - -

What would you like to do today?

- -
-
My Projects
-
Customer Projects
-
Finished Projects
+
+

What would you like to do today?

+ +
+
My Projects
+
Customer Projects
+
Finished Projects
+
+ + $if projects == 'my': +

Your open projects

+ $elif projects == 'customer': +

Customer projects in progress

+ $elif projects == 'finished': +

My finished projects

+ +
+ $for project in project_bulk_one: +

Title:    $project[3]

Description: $project[4]

Category:   $categories[project[1]-1][1]

+
+ + $if projects == 'my': +

Projects in progress

+ $elif projects == 'finished': +

Finished customer projects

+ +
+ $for project in project_bulk_two: +

Title:    $project[3]

Description: $project[4]

Category:   $categories[project[1]-1][1]

+
- - $if projects == 'my': -

Your open projects

- $elif projects == 'customer': -

Customer projects in progress

- $elif projects == 'finished': -

My finished projects

- -
- $for project in project_bulk_one: -

Title:    $project[3]

Description: $project[4]

Category:   $categories[project[1]-1][1]

-
- - $if projects == 'my': -

Projects in progress

- $elif projects == 'finished': -

Finished customer projects

-
- $for project in project_bulk_two: -

Title:    $project[3]

Description: $project[4]

Category:   $categories[project[1]-1][1]

-
+ Honeybee \ No newline at end of file diff --git a/src/app/templates/login.html b/src/app/templates/login.html index c5a4240..e6735d8 100644 --- a/src/app/templates/login.html +++ b/src/app/templates/login.html @@ -1,4 +1,4 @@ -$def with (nav, login_form) +$def with (nav, login_form, message) Beelance2 @@ -20,5 +20,9 @@ $def with (nav, login_form) $else:

Logged in as $session.username

+ +

$:message

+ + Honeybee \ No newline at end of file diff --git a/src/app/templates/open_projects.html b/src/app/templates/open_projects.html index 6589778..b9e1a97 100644 --- a/src/app/templates/open_projects.html +++ b/src/app/templates/open_projects.html @@ -13,6 +13,7 @@ $def with (nav, categories, open_projects)

Open Projects:

+
$for category in categories:
$category[1]
diff --git a/src/app/templates/project.html b/src/app/templates/project.html index 0075c11..3c8284f 100644 --- a/src/app/templates/project.html +++ b/src/app/templates/project.html @@ -26,6 +26,7 @@ $def with (nav, project_form, project, tasks, permissions, categories)
    $for task in tasks: +
  • Task: $task[2]

    Description: $task[3]

    diff --git a/src/app/views/login.py b/src/app/views/login.py index 3f5208d..5a0e3d9 100644 --- a/src/app/views/login.py +++ b/src/app/views/login.py @@ -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): """