Task Manager 📝📤📆
Tags: python, mongodb
Published: 2023-01-08 11:19:58


I've been working on a personal project since finishing a Software Engineering Bootcamp with HyperionDev. The program is based on a task manager that I built as a capstone project in the bootcamp, but I wanted to take it a step further and build a GUI that would make the backend more user-friendly.

Initially, the program was built around reading and writing text files that contained user login information, tasks assigned to users, and reports on the status of those tasks (you can find the program [here](https://github.com/siwhelan/taskManager)). While these text files were fine for a small practice project, they are unrealistic for real-world applications (especially for storing user passwords). I've since replaced the text files with a [MongoDB ](https://www.mongodb.com/)database.

I'm building the GUI using [CustomTkinter](https://github.com/TomSchimansky/CustomTkinter), which is a custom version of [tkinter](https://docs.python.org/3/library/tkinter.html) that offers a more modern look for the app, as well as additional features like the ability to set the appearance mode and default color theme.


![main window light mode](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/arcdus3bj3i9vxmpe0ir.JPG)

I'm encrypting user login passwords using SHA-256 and storing them in the database. This isn't a perfect solution, but using something like bcrypt seemed like overkill for a project like this. When a user logs in, their inputted password is hashed and compared against the stored password in the database.


![login window](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b1ktqhukko51hvonqt8o.JPG)


When registering new users, the password is hashed before the user is added to the database, and all password input fields show '*' when typing, so there are no cleartext/visible passwords at any point.

Upon successful login, the main window is opened, presenting the user with several options such as 'Add User', 'Add/View Tasks', 'Generate Reports', and a search field.


![main_window](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u45bccl94v28aduexakw.JPG)


When the 'Add User' button is clicked, the script gets the values entered in the username and password entry widgets and checks if they are empty strings. If either of them are empty, it displays a window with a message saying 'Incorrect info, please try again'. If both the username and password are non-empty, the script hashes the password using SHA-256 and stores the username and hashed password in a MongoDB database. It then displays a message saying 'User added successfully' and closes the window.


![add_user window](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6wt3qnnw2g7xet2euecy.JPG)


The 'Generate Reports' button performs the following:

   -> Connects to the MongoDB server using the MongoClient function.
   -> Retrieves the 'login_info' collection from the 'task_manager' database and counts the number of unique usernames in the collection.
   -> Retrieves the 'tasks' collection from the 'task_manager' database and counts the number of tasks in the collection.
   -> Counts the number of tasks that are completed and not completed.
   -> Finds the tasks that are overdue and not completed by searching for tasks with a due date earlier than the current date and that are not completed.
   -> Calculates the percentage of tasks that are incomplete and overdue.
   -> Outputs the report to a textbox widget in the main window.


![reports](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tbhb2wjn5nw6uflv1853.JPG)


This is a work in progress, and there is still more to do:

   -> Implement Add/View Tasks
   -> Implement a search feature to search tasks assigned to a particular person and/or by date/completed status
   -> Create 'Edit Tasks' to change the user assigned, due dates, and mark tasks as completed
   -> Increase error handling
   -> Tidy up/refactor/streamline code (it's currently a mess back here!)

Optional:

   -> Increase security with bcrypt password protection
   -> Add specific password conditions, i.e. length, including numbers/characters etc

I'll post the full project on [GitHub](https://github.com/siwhelan) once it's finished, and as always I'm happy to take any feedback.

Thanks for reading 👋