Пример #1
0
class Sportvue:
    """
    Member Vue
    Members interface features
    """
    def __init__(self, sport_controller):
        self._common = Common()
        self.sport_controller = sport_controller

    def succes_message(self, message: str = ""):
        print("Operation succeeded: %s" % message)

    def search_sport(self):
        name = self._common.ask_name('name')
        member = self.sport_controller.search_sport(name)
        return member

    def add_sport(self):
        data = {}
        data['name'] = self._common.ask_name(key_name="name")
        data['description'] = self._common.ask_name(key_name="description")
        print()
        return self.sport_controller.create_sport(data)

    def update_sport(self):
        sport = self.search_sport()
        data = {}
        print("Update Member")
        print()
        data['name'] = self._common.ask_name(key_name="name",
                                             default=sport['name'])
        data['description'] = self._common.ask_name(
            key_name="description", default=sport['description'])
        print()
        return self.sport_controller.update_sport(sport['id'], data)

    def delete_sport(self):
        sport = self.search_sport()
        self.sport_controller.delete_sport(sport['id'])
        self.succes_message()
        return

    def show_sports(self):
        sports = self.sport_controller.list_sports()

        print("Sports: ")
        for sport in sports:
            print("* %s :%s" % (sport['name'], sport['description']))
Пример #2
0
class ArticleVue:
    """
    Article Vue
    Articles interface features
    """
    def __init__(self, article_controller):
        self._common = Common()
        self._article_controller = article_controller

    def add_article(self):
        # Show subscription formular
        data = {}
        print("Store article Subscription")
        print()
        data['name'] = self._common.ask_namearticle()
        data['description'] = self._common.ask_description()
        data['price'] = self._common.ask_price()
        return self._article_controller.create_article(data)

    def show_article(self, article: dict):
        print("Article information: ")
        print(article['name'].capitalize())
        print("description:", article['description'])

    def error_message(self, message: str):
        print("/!\\ %s" % message.upper())

    def succes_message(self, message: str = ""):
        print("Operation succeeded: %s" % message)

    def show_articles(self):

        articles = self._article_controller.list_articles()

        print("Members: ")
        for article in articles:
            print("* %s %s (%s)" % (article['name'].capitalize(),
                                    article['description'], article['price']))

    def search_article(self):
        name = self._common.ask_name('name')
        article = self._article_controller.search_article(name)
        return article

    def update_article(self):
        article = self.search_article()
        data = {}
        print("Update Article")
        print()
        data['name'] = self._common.ask_namearticle()
        data['description'] = self._common.ask_description(
            default=article['description'])
        data['price'] = self._common.ask_price(default=article['price'])
        print()
        return self._article_controller.update_member(article['id'], data)

    def delete_article(self):
        article = self.search_article()
        self._article_controller.delete_article(article['id'])
        self.succes_message()
Пример #3
0
 def __init__(self, member_controller):
     self._common = Common()
     self._member_controller = member_controller
Пример #4
0
class MemberVue:
    """
    Member Vue
    Members interface features
    """
    def __init__(self, member_controller):
        self._common = Common()
        self._member_controller = member_controller

    def add_member(self):
        # Show subscription formular
        data = {}
        print("BDS Subscription")
        print()
        data['firstname'] = self._common.ask_name(key_name="firstname")
        data['lastname'] = self._common.ask_name(key_name="lastname")
        data['email'] = self._common.ask_email()
        data['password'] = bcrypt.hashpw(
            bytes(self._common.ask_password(), encoding='utf-8'),
            bcrypt.gensalt())
        print()
        return self._member_controller.create_member(data)

    def show_member(self, member: dict):
        print("Member profile: ")
        print(member['firstname'].capitalize(),
              member['lastname'].capitalize())
        print("email:", member['email'])

    def error_message(self, message: str):
        print("/!\\ %s" % message.upper())

    def succes_message(self, message: str = ""):
        print("Operation succeeded: %s" % message)

    def show_members(self):

        members = self._member_controller.list_members()

        print("Members: ")
        for member in members:
            print("* %s %s (%s)" %
                  (member['firstname'].capitalize(),
                   member['lastname'].capitalize(), member['email']))

    def search_member(self):
        firstname = self._common.ask_name('firstname')
        lastname = self._common.ask_name('lastname')
        member = self._member_controller.search_member(firstname, lastname)
        return member

    def update_member(self):
        member = self.search_member()
        data = {}
        print("Update Member")
        print()
        data['firstname'] = self._common.ask_name(key_name="firstname",
                                                  default=member['firstname'])
        data['lastname'] = self._common.ask_name(key_name="lastname",
                                                 default=member['lastname'])
        data['email'] = self._common.ask_email(default=member['email'])
        data['password'] = bcrypt.hashpw(
            bytes(self._common.ask_password(), encoding='utf-8'),
            bcrypt.gensalt())
        print()
        return self._member_controller.update_member(member['id'], data)

    def delete_member(self):
        member = self.search_member()
        self._member_controller.delete_member(member['id'])
        self.succes_message()

    def update_profile(self, member: dict):
        data = {}
        print("Update Member")
        print()
        data['firstname'] = self._common.ask_name(key_name="firstname",
                                                  default=member['firstname'])
        data['lastname'] = self._common.ask_name(key_name="lastname",
                                                 default=member['lastname'])
        data['email'] = self._common.ask_email(default=member['email'])
        data['password'] = bcrypt.hashpw(
            bytes(self._common.ask_password(), encoding='utf-8'),
            bcrypt.gensalt())
        print()
        return self._member_controller.update_member(member['id'], data)
Пример #5
0
class MemberVue:
    """
    Member Vue
    Members interface features
    """
    def __init__(self, member_controller):
        self._common = Common()
        self._member_controller = member_controller

    def add_member(self, user_type):
        # Show subscription formular
        data = {}
        print("Store user Subscription")
        print(user_type)
        print()
        data['firstname'] = self._common.ask_name(key_name="firstname")
        data['lastname'] = self._common.ask_name(key_name="lastname")
        data['email'] = self._common.ask_email()
        if user_type != 'customer':
            data['type'] = self._common.ask_type()
        else:
            data['type'] = user_type
        return self._member_controller.create_member(data)

    def show_member(self, member: dict):
        print("Member profile: ")
        print(member['firstname'].capitalize(),
              member['lastname'].capitalize())
        print("email:", member['email'])
        print("type:", member['type'])

    def error_message(self, message: str):
        print("/!\\ %s" % message.upper())

    def succes_message(self, message: str = ""):
        print("Operation succeeded: %s" % message)

    def show_members(self):

        members = self._member_controller.list_members()

        print("Members: ")
        for member in members:
            print("* %s %s (%s) - %s" % (member['firstname'].capitalize(),
                                         member['lastname'].capitalize(),
                                         member['email'], member['type']))

    def search_member(self):
        firstname = self._common.ask_name('firstname')
        lastname = self._common.ask_name('lastname')
        member = self._member_controller.search_member(firstname, lastname)
        return member

    def update_member(self):
        member = self.search_member()
        data = {}
        print("Update Member")
        print()
        data['firstname'] = self._common.ask_name(key_name="firstname",
                                                  default=member['firstname'])
        data['lastname'] = self._common.ask_name(key_name="lastname",
                                                 default=member['lastname'])
        data['email'] = self._common.ask_email(default=member['email'])
        data['type'] = self._common.ask_type(default=member['type'])
        print()
        return self._member_controller.update_member(member['id'], data)

    def delete_member(self):
        member = self.search_member()
        self._member_controller.delete_member(member['id'])
        self.succes_message()
Пример #6
0
 def __init__(self, sport_controller):
     self._common = Common()
     self.sport_controller = sport_controller
Пример #7
0
 def __init__(self, article_controller):
     self._common = Common()
     self._article_controller = article_controller
Пример #8
0
class MemberVue:
    """
    Member Vue
    Members interface features
    """
    def __init__(self, member_controller):
        self._member_controller = member_controller
        self._common = Common()

    def add_member(self, informations):
        # Show subscription formular
        data = {}
        print("Spotify user information")
        print(informations)
        print()
        data['email'] = informations[0]
        data['pseudo'] = informations[1]
        data['mot_de_passe'] = informations[2]
        data['genre'] = informations[3]
        return self._member_controller.create_member(data)

    def show_member(self, member: dict):
        print("Member profile: ")
        print("email :", member['email'], " et pseudo : ", member['pseudo'])
        print("mot_de_passe:", member['mot_de_passe'])
        print("genre:", member['genre'])

    def error_message(self, message: str):
        print("/!\\ %s" % message.upper())

    def succes_message(self, message: str = ""):
        print("Operation succeeded: %s" % message)

    def show_members(self):
        members = self._member_controller.list_members()

        print("Members: ")
        for member in members:
            print("* %s %s (%s)" %
                  (member['email'], member['pseudo'], member['genre']))

    def search_member(self):
        print("ahh")
        email = self._common.ask_email('email')
        print("oui")
        member = self._member_controller.search_member(email)
        self.show_member(member)
        return member

    # À faire ! Revoir la fonction des musiques
    '''def update_member(self):
        member = self.search_member()
        data = {}
        print("Update Member")
        print()
        data['firstname'] = self._common.ask_name(key_name="firstname", default=member['firstname'])
        data['lastname'] = self._common.ask_name(key_name="lastname", default=member['lastname'])
        data['email'] = self._common.ask_email(default=member['email'])
        data['type'] = self._common.ask_type(default=member['type'])
        print()
        return self._member_controller.update_member(member['id'], data)'''

    def delete_member(self):
        member = self.search_member()
        self._member_controller.delete_member(member['id'])
        self.succes_message()
Пример #9
0
class MemberVue:
    """
    Member Vue
    Members interface features
    """
    def __init__(self, member_controller):
        self._common = Common()
        self._member_controller = member_controller
        self.member = None

    def add_member(self):
        # Show subscription formular
        data = {}
        print("BDS Subscription")
        print()
        data['firstname'] = self._common.ask_name(key_name="firstname")
        data['lastname'] = self._common.ask_name(key_name="lastname")
        data['email'] = self._common.ask_email()
        print()
        return self._member_controller.create_member(data)

    def show_member(self, member: dict):
        print("Member profile: ")
        print("\t" + member['firstname'].capitalize(),
              member['lastname'].capitalize())
        print("\temail:", member['email'])
        print("\tsport ", member['sports'])
        s = "No"
        if member['coach']:
            s = "Yes sport coached %s" % (member['coached'])
        print("\tis coach", s)

    def error_message(self, message: str):
        print("/!\\ %s" % message.upper())

    def succes_message(self, message: str = ""):
        print("Operation succeeded: %s" % message)

    def show_members(self):

        members = self._member_controller.list_members()

        print("Members: ")
        for member in members:
            s = "No"
            if member['coach']:
                s = "Yes"
            c = ""
            if member['coached'].__len__() > 0:
                c = "sport coached:["
                for i in member['coached']:
                    c += i
                    if (member['coached'].index(i) <
                            member['coached'].__len__() - 1):
                        c += ", "
                c += "]"
            print("* %s %s (%s)\n\tsport:%s\n\tcoach:%s %s" %
                  (member['firstname'].capitalize(),
                   member['lastname'].capitalize(), member['email'],
                   member['sports'], s, c))

    def search_member(self):
        firstname = self._common.ask_name('firstname')
        lastname = self._common.ask_name('lastname')
        member = self._member_controller.search_member(firstname, lastname)
        return member

    def update_member(self):
        member = self.search_member()
        data = {}
        print("Update Member")
        print()
        data['firstname'] = self._common.ask_name(key_name="firstname",
                                                  default=member['firstname'])
        data['lastname'] = self._common.ask_name(key_name="lastname",
                                                 default=member['lastname'])
        data['email'] = self._common.ask_email(default=member['email'])
        print()
        return self._member_controller.update_member(member['id'], data)

    def update_self_member(self):
        member = self.member
        data = {}
        print("Update Member")
        print()
        data['firstname'] = self._common.ask_name(key_name="firstname",
                                                  default=member['firstname'])
        data['lastname'] = self._common.ask_name(key_name="lastname",
                                                 default=member['lastname'])
        data['email'] = self._common.ask_email(default=member['email'])
        print()
        self.member = self._member_controller.update_member(member['id'], data)
        return self.member

    def delete_member(self):
        member = self.search_member()
        self._member_controller.delete_member(member['id'])
        self.succes_message()
        return

    def add_sport_to_member(self):
        member = self.search_member()
        sport = self._common.ask_name(key_name="sport name")
        self._member_controller.add_sport(member, sport)
        return

    def remove_sport_to_member(self):
        member = self.search_member()
        sport = self._common.ask_name(key_name="sport name")
        self._member_controller.remove_sport(member, sport)
        return

    def add_coach_to_sport(self):
        sport = self._common.ask_name(key_name="sport name")
        member = self.search_member()
        self._member_controller.add_coach(member, sport)
        return

    def remove_coach_to_sport(self):
        sport = self._common.ask_name(key_name="sport name")
        member = self.search_member()
        self._member_controller.remove_coach(member, sport)
        return

    def add_self_sport(self):
        sport = self._common.ask_name(key_name="sport name")
        self._member_controller.add_sport(self.member, sport)
        return

    def remove_self_sport(self):
        sport = self._common.ask_name(key_name="sport name")
        self._member_controller.remove_sport(self.member, sport)
        return
Пример #10
0
class SportVue:
    """
    Sport Vue
    Sports interface features
    """
    def __init__(self, sport_controller):
        self._common = Common()
        self._sport_controller = sport_controller

    def add_sport(self):
        # Show subscription formular
        data = {}
        print("BDS Subscription")
        print()
        data['name'] = self._common.ask_name(key_name="name")
        print()
        return self._sport_controller.create_sport(data)

    def show_sport(self, sport: dict):
        print("Sport profile: ")
        print(sport['name'].capitalize())

    def error_message(self, message: str):
        print("/!\\ %s" % message.upper())

    def succes_message(self, message: str = ""):
        print("Operation succeeded: %s" % message)

    def show_sports(self):

        sports = self._sport_controller.list_sports()

        print("Sports: ")
        for sport in sports:
            print("* %s " % (sport['name'].capitalize()))

    def search_sport(self):
        name = self._common.ask_name('name')
        sport = self._sport_controller.search_sport(name)
        return sport

    def update_sport(self):
        sport = self.search_sport()
        data = {}
        print("Update Sport")
        print()
        data['name'] = self._common.ask_name(key_name="name",
                                             default=sport['name'])
        print()
        return self._sport_controller.update_sport(sport['id'], data)

    def update_my_sport(self, member: dict):
        data = {}
        sport = self.search_sport()
        print()
        member['id_sport'] = sport['id']
        return self._member_controller.update_member(member['id'], member)

    def delete_sport(self):
        sport = self.search_sport()
        self._sport_controller.delete_sport(sport['id'])
        self.succes_message()

    def set_coach_sport(self, sport, member_id):
        data = {}
        data['name'] = sport['name']
        data['id_coach'] = member_id
        return self._sport_controller.update_sport(sport['id'], data)

    def show_sports(self, member: dict):

        sport = self._sport_controller.get_sport(member['id_sport'])
        print("* %s " % (sport['name'].capitalize()))