Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

how can i add participant to the same project

So im trying to make a project. when user choose to find project ( Menu number 3. ) they enter their name and then they can choose their job, project name, and enter stages. When user choose show all project (Menu number 1.) it shows the project and also the participant in the project.

What i want is 1 project can have more than 1 participant, so when user find project and they input the same project as other participant, that project can have both of them.

And when user choose Show project ( Menu number 1. ) the project with the same name does not go out twice.

This is the output now:

Output

when i add another participant in the same project it becomes separated:

add other participant

This is what i want it to be:

what i want

Here is my python code:

Project code

import datetime


last_id = 0


class project:

    def __init__(self, job, pname, pstages, participant):
        self.pname = pname
        self.pstages = pstages
        self.job = job
        self.participant = participant
        global last_id
        last_id += 1
        self.id = last_id

    def match(self, filter):

        return filter in self.pname

class notebook:

    def __init__(self):
        self.notes = []

    def new_project(self, job, pname, pstages, participant):
        self.notes.append(project(job, pname, pstages, participant))

    def new_pstages(self, pstages, pname=''):
        self.notes.append(project(pstages, pname))

    def _find_project(self, project_id):
        for project in self.notes:
            if str(project.id) == str(project_id):
                return project

        return None

    def modify_pstages(self, project_id, pstages):
        project = self._find_project(project_id)
        if project:
            project.pstages = pstages
            return True
        return False

    def search(self, filter):
        return [project for project in self.notes if
                project.match(filter)]

Menu Code:

import sys

from softwareP import project, notebook
class Menu:

    def __init__(self):
        self.notebook = notebook()
        self.choices = {
                "1": self.show_notes,
                "2": self.search_notes,
                "3": self.add_project,
                "4": self.modify_pstages,
                "5": self.quit
                }

    def display_menu(self):
        print("""
WELCOME TO SOFTWARE HOUSE

1. Show all project
2. Search project
3. Find Project
4. Edit your pstages
5. Quit
""")
    def run(self):

        while True:
            self.display_menu()
            choice = input("enter an option: ")
            action = self.choices.get(choice)
            if action:
                action()
            else:
                print("{0} is not a valid choice".format(choice))

    def show_notes (self, notes=None):
        if not notes:
            notes = self.notebook.notes
        for project in notes:
            print ("{0}.Project name:{1}\npstages: {2}\nJob: {3}\nParticipant: {4}".format(
                    project.id, project.pname, project.pstages, project.job, project.participant))

    def search_notes(self):
        filter = input ("insert project pname: ")
        notes = self.notebook.search(filter)
        self.show_notes(notes)

    def modify_pstages(self):
        id = input("input your project id: ")
        pstages = input("Enter your stages now: ")
        self.notebook.modify_pstages(id, pstages)

    def add_project(self):
        participant = input("Enter your name: ")    
        choice = None
        while choice not in (1,2):
            print("""YOUR JOB: 
            1. Android Developer
            2. Web Developer""")
            choice = input("Enter your job[1-2]: ")
            choice = int(choice)
            if choice == 1:
                job = ("Android Developer")
                choice2 = None
                while choice2 not in (1,2):
                    print("""AVAILABLE PROJECT FOR ANDROID DEVELOPER: 
                    1. Ticketing: Football match
                    2. ERP: POS""")
                    choice2 = input("Enter your choice[1-2]: ")
                    choice2 = int(choice2)
                    if choice == 1:
                        pname = ("Ticketing: Football match")
                    elif choice == 2:
                        pname = ("ERP: POS")
                    else:
                        print("no such input, please try again")
            elif choice == 2:
                job = ("Web Developer")
                choice2 = None
                while choice2 not in (1,2):
                    print("""AVAILABLE PROJECT FOR WEB DEVELOPER: 
                    1. E-Commerce: Online Shop
                    2. Company profile: Coffee Shop""")
                    choice2 = input("Enter your choice[1-2]: ")
                    choice2 = int(choice2)
                    if choice == 1:
                        pname = ("E-Commerce: Online Shop")
                    elif choice == 2:
                        pname = ("Company profile: Coffee Shop")
                    else:
                        print("no such input, please try again")    
            else:
                print("no such input, please try again")
        pstages = input("Enter your stages: ")      
        self.notebook.new_project(job, pname, pstages, participant)
        print("you are registered to the project")

    def quit(self):
        print("byebye")
        sys.exit(0)
if __name__ == "__main__":
    Menu().run()

Comments