'''Capstone template project for FCS Task
This is task 19tge previous capstone project i did and all it's information.
19 Compulsory task 1.
This template provides a skeleton code to start compulsory task 1 only.
Once you have successfully implemented compulsory task 1 it will be easier to
add a code for compulsory task 2 to complete this capstone'''
#=====importing libraries===========
import time
'''This is the section where you will import libraries'''
#====Login Section====
'''Here you will write code that will allow a user to login.
- Your code must read usernames and password from the user.txt file
- You can use a list or dictionary to store a list of usernames and passwords from the file.
- Use a while loop to validate your user name and password.
'''
#importing current date
from datetime import datetime
import csv
#opening user file
user_file = open("user.txt", "r+")
text = user_file.readlines()
login = False
#while login is false,
#if user enters correct credentials, login
#changes to True. Giving exccess
while login == False:
username = input("Enter your username: ")
password = input("Enter your password: ")
for lines in text:
valid_user, valid_password = map(str.strip, lines.split(", "))
if valid_user == username and valid_password == password:
login = True
print("Logging in...")
break
else:
print("Invalid login details")
user_file.seek(0)
#user_file.close()
#choices for the user to choose from
choices = input('''Select option one below:
r - register username
a - add task
va - view all tasks
vm - view my tasks
e - exit
s - stats
''')
#if user selects admin selects "r" he can
#register a user to user_file
if choices == "r":
if username == "admin":
new_userLogin = False
new_usersName = input("Enter username: ")
while new_userLogin == False:
new_userPass = input("Enter password: ")
validate = input("Confirm password: ")
if new_userPass == validate:
new_userLogin = True
if new_userPass != validate:
print("password did not match. Try again")
if new_userPass == validate:
print("password matches. New user created")
append_me = open("user.txt", "a")
append_me.write("\n" + str(new_usersName) + ", " + str(validate))
append_me.close()
if username != "admin":
print("Only admin can add a new user.")
#if user selects "a" he/she will have
#to enter input. input will be written one
#tasks_file
elif choices == "a":
tasks = open("tasks.txt", "a")
assignee = input("Enter the usersname of assignee: ")
title = input("Enter the title of the task: ")
description = input("Enter task description: ")
due_date = input("Enter task due date YYYY-MM-DD: ")
date = datetime.now()
completed = "no"
tasks.write(str(assignee) + ", " + str(title) + ", " + str(description) + ", " + str(due_date)
+ ", " + str(date) + ", " + str(completed) + "\n")
tasks.close()
#if user selects "va" he will be given info
#of every file in an easy to read format
elif choices == "va":
tasks_file = open("tasks.txt", "r+")
#loop to print out details in proper manner
for line in tasks_file:
assignee, title, description, due_date, date, completed = line.split(", ")
print(f'''
Name: {assignee}
Title: {title}
Description: {description}
Due Date: {due_date}
Date Assigned: {date}
Task Complete: {completed}
''')
tasks_file.close()
#if user selects "vm" program
#will desplay specific user task
if choices == "vm":
view = open("tasks.txt", "r")
for line in view:
assignee, title, description, due_date, date, completed = line.split(", ")
if username == assignee:
print(f'''
Name: {assignee}
Title: {title}
Description: {description}
Due Date: {due_date}
Date Assigned: {date}
Task Complete: {completed}
''')
view.close()
#if the user selects "e" program
#breaks
if choices == "e":
print("closing program...")
breakpoint
#if user selects "s". number of tasks and
#number of users are displayed
if choices == "s":
stats_file = open("tasks.txt", "r+")
other_stats = open("tasks.txt", "r+")
if username == "admin":
num_title = 0
num_assignee = 0
for line in stats_file:
assignee, title, description, due_date, date, completed = line.split(", ")
assignee
num_assignee += 1
print(f'''
Total number of users: {num_assignee}
''')
stats_file.close()
for title in other_stats:
assignee, title, description, due_date, date, completed = title.split(", ")
title
num_title += 1
print(f'''
Total number of tasks: {num_title}
''')
other_stats.close()
21:43 < admin, admin john,doe G] 0 user.txt S LTE Share
21:44 <L1T19 Thabang, cleaning, clean your room, 2022-05-24, 2022-06-25, No G] tasks.txt Ntokozo, scrapper, taking data from the internet, 2022-05-24, 2022-06-05, No 0 LTE S Share
ariondev Copyright © 2018 Hyperion Development. All right Compulsory Task 1 Follow these steps: • Create a copy of your previous Capstone project task manager.py) and save it in the Dropbox folder for this project. Also, copy and paste the text files (user.txt and tasks.txt) that accompanied the previous Capstone project to this folder. Modify this program as follows . Modify the code of your previous project so that functions are used Adding functions will improve the modularity of your code. Your program should include at least the following functions o reg.user-that is called when the user selects to register a user o add task-that is called when a user selects of to add a new task o view all-that is called when users type va' to view all the tasks listed in tasks.txt priondev o view mine that is called when users type im' to view all the tasks that have been assigned to them • Modify the function called reg user to make sure that you don't duplicate usernames when you add a new user to user.txt if a user tries to add a username that already exists in user.txt, provide a relevant error message and allow them to try to add a user with a different username Add the following functionality when the user selects vm' to view all the tasks assigned to them: o Display all tasks in a manner that is easy to read. Make sure that each task is displayed with a corresponding number which can be used to identify the task o Allow the user to select either a specific task by entering a number or input to return to the main menu of the user selects a specific task, they should be able to choose to either mark the task as complete or edit the task if the user chooses to mark a task as complete the Yes/No value that describes whether the task has been completed or not should be changed to Yes. When the user chooses to edit a task the username of the person to whom the task is assigned or the due date of the task can be edited. The task can only be edited if it has not yet been completed Copyright © 2018 Hyperion Development. All right
Add an option to generate reports to the main menu of the application The menu for the admin user should now look something like this. Please select one of the following optiona regater pe priondev = &- add tank va- view all tasks v- view my tasks gr-generate reports de display statistics . When the user chooses to generate reports two text files, called task overview.txt and user overview.txt should be generated. Both these text files should output data in a user-friendly, easy to read manner. task overview.txt should contain . The total number of tasks that have been generated and tracked using the task manager.py The total number of completed tasks The total number of uncompleted tasks The total number of tasks that haven't been completed and that are overdue The percentage of tasks that are incomplete The percentage of tasks that are overdue o user overview.txt should contain The total number of users registered with task_manager.py The total number of tasks that have been generated and tracked using the task_manager.py For each user also describe . The total number of tasks assigned to that user What percentage of the total number of tasks have been assigned to that user? What percentage of the tasks assigned to that user have been completed? • What percentage of the tasks assigned to that user must still be completed? What percentage of the tasks assigned to that user have not yet been completed and are overdue? . Modify the menu option that allows the admin to display statistics so that the reports generated are read from task overview.txt and user_overview.txt and displayed on the screen in a user-friendly manner. Copyright © 2018 Hyperion Development. All right If these text files don't exist (because the user hasn't selected to generate them yet), first call the code to generate the text files Rate us Share your thoughts
Hyperione Copyright © 2018 Mon Development At rights reserved Compulsory Task Part 1 Follow these steps in this task you will be creating a program for a small business that can help it to manage tasks assigned to each member of the team. Copy the template program provided Task19template.py and rename it task manager.py in this folder. This template has been p to make this Task a little easier for you your job is to open and then modify the template to achieve the rest of the compulsory Task set out below Demember to save your work as you go along This program will work with two text files userbat and tasks.txt Open each of the files that accompany this project and take note of the following tasks.txt stores a list of all the tacks that the team is working on Open the tasks.txt file that accompanies this project Note that this text file already contains data about seo The data for each task is stored on a separate line in the text file Each line includes the following data about a task in this order The username of the person to whom the task signed The title of the task A description of the task The date that the task was assigned to the use The due date for the task Either a Ves' or No value that specifies if the task has been user.txt stores the username and password for each us that has permission to use your program task manager.py Open the user.txt file that accompanies this project. Note that this text file already contains one default user that has the une admin Copyright © 2018 and the password, adwile the usemame and password for each user must be written to this file in the following format First, the username allowed by a comma a s the password One username and comesponding password per your program should allow your users to do the following Login The user should be prompted to enter a mame and password A list of valid usemames and p are stored in a
Hyperion Hyperionde Copyright © 2018 and the passwort admin the usemame and password for each user must be written to this file in the following format First, the usemme followed by a commaa space and then the password One username and comesponding pasword per lin Your program should allow your users to do the Login The user should be prompted to enteramme and password. A list of valid usernames and passwords are stored in a text file called user txt Display an appropriate message of the user enters a username that is not listed in userbentas vald username but not a valid password the user should repeatedly be asked to enter a valid username and passord until they provide appropriate credentials The following menu should be displayed once the succesfully logged in Fisse site of the following k - all tax regate wing should also the user chooses to registra user the ser should be prompted for a new username and password The be asked to confirm the password if the value entered to confirm the password matches the value of the past the same and password should be written to usertat in the appropriate format the user chooses to add a task, the user should be prompted to enter the username of the person the task is assigned to the title of the task a description of the task and the due date of the task The data about the new task should be writ The date on which the task assigned should be the date asume that whenever you add a new task the value that indicates whether the task has been completed or not if the user chooses vo to view as tasks display the information for each task on the screen in an easy to read format the user chooses to view the tasks that are signed to them only display all the tasks that have been assigned to the user that currently logged in in a user-friendly to read m Compulsory Task Part 2
Hyperion format the user chooses to add a task, the user should be prompted to enter the username of the person the task is assigned to the title of the task a description of the task and the due date of the task The Copyright © 2018 Hyperion Development. Al rights reserved data about the new task should be write to tackstat The date on which the task is assigned should be the current date Also aume that whenever you add a new task, the value that indicates whether the task has been completed or not the user chooses var to view all tasks display the information for each task on the screen in an easy to read format af the user chooses im'to view the tasks that are asigned to them only display all the tasks that have been assigned to the user that is cuently logged-in in a user-friendly, toad manne Compulsory Task Part 2 Now format your program th a Only the user with the usemame ominalowed to register users b. The admin user is provided with a new manu option that allows them to display statistics when this menu option is selected, the total number of talks and the total number of users should be displayed in a user friendly manner. Rate us Share your thoughts Hyperves to provide tetona Think that the content of this task or this co we've done a good job Click here to share your thoughts anonymously Copyright © 2018 Hype D I rights reserve
'''Capstone template project for FCS Task This is task 19tge previous capstone project i did and all it's information. 1
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am