Beispiel #1
0
 def viewhealthdata():
     mstr = Tk()
     listbox = Listbox(mstr, width=100, height=30)
     listbox.pack()
     health_dao = HealthDataDao.HealthDataDao()
     my_friends = business_logic.return_my_friends(username)
     for friend in my_friends:
         if friend.requester_username == username:
             mydatumlist = health_dao.read_datum(friend.requested_username)
             for datum in mydatumlist:
                 listbox.insert(
                     END,
                     'Username of the friend-' + friend.requested_username)
                 listbox.insert(
                     END, 'Property id: ' + str(datum.propertyid) +
                     '     Value: ' + str(datum.value))
         elif friend.requested_username == username:
             mydatumlist = health_dao.read_datum(friend.requester_username)
             for datum in mydatumlist:
                 listbox.insert(
                     END,
                     'Username of the friend-' + friend.requester_username)
                 listbox.insert(
                     END, 'Property id: ' + str(datum.propertyid) +
                     '     Value: ' + str(datum.value))
     listbox.insert(
         END,
         '*************************************************************************************'
     )
     properties = health_dao.read_properties()
     for property in properties:
         listbox.insert(
             END, 'Property id: ' + str(property.propertyid) + ', Name: ' +
             property.name + ', Description: ' + property.description)
Beispiel #2
0
 def display_properties():
     mstr = Tk()
     listbox = Listbox(mstr, width=100, height=50)
     listbox.pack()
     retList = HealthDataDao.HealthDataDao().read_properties()
     for prop in retList:
         listbox.insert(
             END, 'Property ID-' + str(prop.propertyid) + 'Property Name-' +
             prop.name + ' Property description - ' + prop.description)
 def read_end_user(self, myusername):
     my_read_list = []
     try:
         myobj = EndUserDao.EndUserDao().read(myusername)
         my_read_list = HealthDataDao.HealthDataDao().read_datum(myusername)
         if (myobj is None) or (not my_read_list):
             return False
         else:
             myreturnlist = []
             myreturnlist.append(myobj)
             myreturnlist.append(my_read_list)
             return myreturnlist
     except Exception as e:
         raise
Beispiel #4
0
 def add_property():
     flag = 0
     global count1, l_invalid
     if l_invalid is not None:
         l_invalid.grid_forget()
     if e29.get() and e31.get() and count1 > 0:
         try:
             id = int(e29.get())
             val = int(e31.get())
             retList = HealthDataDao.HealthDataDao().read_properties()
             if retList is not None:
                 for ret in retList:
                     if ret.propertyid == id:
                         propidlist.append(id)
                         propvallist.append(val)
                         count1 -= 1
                         flag = 1
                         Label(master,
                               text="count=" + str(count1) + " left").grid(
                                   row=27, column=3)
                         break
                 if flag == 0:
                     l_invalid = Label(master,
                                       text="Invalid property ID",
                                       fg="red")
                     l_invalid.grid(row=30, column=1)
             else:
                 l_invalid = Label(master,
                                   text="Properties not present",
                                   fg="red")
                 l_invalid.grid(row=30, column=1)
         except Exception as e:
             l_invalid = Label(
                 master,
                 text="property id and value must be integers!!",
                 fg="red")
             l_invalid.grid(row=30, column=1)
     if count1 == 0:
         e29.grid_forget()
         e31.grid_forget()
         b1.grid_forget()
         b2.grid_forget()
         l1.grid_forget()
         l2.grid_forget()
         l3.grid_forget()
         l4.grid_forget()
         if l_invalid is not None:
             l_invalid.grid_forget()
 def display():
     mstr = Tk()
     listbox = Listbox(mstr, width=100, height=50)
     listbox.pack()
     retlist = EndUserBL.EndUserBL().read_end_user(username)
     enduserobj = retlist[0]
     datumlist = retlist[1]
     listbox.insert(END,
                    'UserName(cannot be updated)-' + enduserobj.username)
     listbox.insert(END, '1.Password-' + enduserobj.password)
     listbox.insert(END, '2.FirstEmailID-' + enduserobj.email1)
     listbox.insert(END, '3.SecondEmailID-' + enduserobj.email2)
     listbox.insert(END, '4.FirstName-' + enduserobj.firstname)
     listbox.insert(END, '5.LastName-' + enduserobj.lastname)
     listbox.insert(END, '6.AboutYou-' + enduserobj.aboutme)
     listbox.insert(END, '7.URL1-' + enduserobj.photourl1)
     listbox.insert(END, '8.URL2-' + enduserobj.photourl2)
     listbox.insert(END, '9.URL3-' + enduserobj.photourl3)
     listbox.insert(END, '10.StreetNumber-' + enduserobj.streetnumber)
     listbox.insert(END, '11.StreetName-' + enduserobj.streetname)
     listbox.insert(END,
                    '12.MajorMunicipality-' + enduserobj.majormunicipality)
     listbox.insert(END, '13.Gov. District-' + enduserobj.governingdistrict)
     listbox.insert(END, '14.PostalArea-' + enduserobj.postalarea)
     listbox.insert(END, '15.Karma Score-' + str(enduserobj.karma))
     listbox.insert(END, '********** Health Data **********')
     for d in datumlist:
         listbox.insert(
             END, 'Datum Id - ' + str(d.datumid) + ' Property ID-' +
             str(d.propertyid) + ' Value-' + d.value)
     listbox.insert(END, '********** Properties in Database **********')
     myproplist = HealthDataDao.HealthDataDao().read_properties()
     for prop in myproplist:
         listbox.insert(
             END,
             'Property id - ' + str(prop.propertyid) + ' Property name - ' +
             prop.name + ' Property description - ' + prop.description)
Beispiel #6
0
    def register():
        global l_all_properties, l_error
        username_flag = 0
        if e2.get() and e4.get() and e5.get() and e7.get() and e9.get() and e10.get() and e11.get() and e12.get() and \
                e13.get() and e14.get() and e15.get() and e16.get() and e17.get() and e18.get() and e19.get() and e21.get():
            try:
                if l_all_properties is not None:
                    l_all_properties.grid_forget()
                if l_error is not None:
                    l_error.grid_forget()
                if e2.get():
                    if not UserDao.UserDao().check_if_user_exists(e2.get()):
                        Label(master, text="Username is available",
                              fg="green").grid(row=3, column=2)
                    else:
                        Label(master,
                              text="Username already exists!!",
                              fg="red").grid(row=3, column=2)
                        username_flag = 1
                else:
                    Label(master,
                          text="Username field is mandatory!!",
                          fg="red").grid(row=3, column=1)

                if e5.get():
                    if validate_email(e5.get()):
                        Label(master, text="Correct email ID",
                              fg="green").grid(row=6, column=2)
                    else:
                        Label(master,
                              text="primary mail is not correct",
                              fg="red").grid(row=6, column=2)
                else:
                    Label(master,
                          text="EmailID field is mandatory!!",
                          fg="red").grid(row=6, column=1)

                if e7.get():
                    if validate_email(e7.get()):
                        Label(master, text="Correct email ID",
                              fg="green").grid(row=8, column=2)
                    else:
                        Label(master,
                              text="secondaray mail is not correct",
                              fg="red").grid(row=8, column=2)
                else:
                    Label(master,
                          text="EmailID field is mandatory!!",
                          fg="red").grid(row=8, column=1)

                uid = int(e21.get())

                if uid == 1:
                    karma = 0
                    enduserobj = Entities.EndUser(karma, datetime.date.today(),
                                                  e2.get(), e4.get(), e5.get(),
                                                  e7.get(), e9.get(),
                                                  e10.get(), e11.get(),
                                                  e12.get(), e13.get(),
                                                  e14.get(), e15.get(),
                                                  e16.get(), e17.get(),
                                                  e18.get(), e19.get(), uid, 1)
                    proplist = HealthDataDao.HealthDataDao().read_properties()
                    ocount = len(proplist)
                    mcount = ocount
                    datumkey = random.randint(1, 100000)
                    if count1 != 0:
                        l_all_properties = Label(
                            master,
                            text="You have to add all properties!!",
                            fg="red")
                        l_all_properties.grid(row=41, column=1)
                    else:
                        if EndUserBL.EndUserBL().create_end_user(
                                enduserobj) is True:
                            while mcount > 0:
                                datumobj = Entities.Datum(
                                    datumkey, e2.get(),
                                    propidlist[ocount - mcount],
                                    propvallist[ocount - mcount],
                                    datetime.date.today())
                                EndUserBL.EndUserBL(
                                ).create_user_datum_mapping(datumobj)
                                datumkey += 1
                                mcount -= 1
                            Label(master, text="Registered!",
                                  fg="green").grid(row=40, column=1)
                            propvallist.clear()
                            propidlist.clear()
                            master.after(1000, lambda: Tk.destroy(master))
                elif uid == 2:
                    phone = e22.get()
                    modobj = Entities.Moderator(phone, e2.get(), e4.get(),
                                                e5.get(), e7.get(), e9.get(),
                                                e10.get(), e11.get(),
                                                e12.get(), e13.get(),
                                                e14.get(), e15.get(),
                                                e16.get(), e17.get(),
                                                e18.get(), e19.get(), uid, 1)
                    if Moderator_BL.ModeratorBL().create_moderator(
                            modobj, qual_list) is True:
                        Label(master, text="Registered!!",
                              fg="green").grid(row=40, column=1)
                        qual_list.clear()
                        master.after(1000, lambda: Tk.destroy(master))
                elif uid == 3:
                    phone = e22.get()
                    adminobj = Entities.Administrator(phone,
                                                      e2.get(), e4.get(),
                                                      e5.get(), e7.get(),
                                                      e9.get(), e10.get(),
                                                      e11.get(), e12.get(),
                                                      e13.get(), e14.get(),
                                                      e15.get(), e16.get(),
                                                      e17.get(), e18.get(),
                                                      e19.get(), uid, 1)
                    if AdministratorBL.AdministratorBL().create_administrator(
                            adminobj) is True:
                        Label(master, text="Registered!!",
                              fg="green").grid(row=40, column=1)
                        master.after(1000, lambda: Tk.destroy(master))
                else:
                    Label(
                        master,
                        text=
                        "Wrong Choice..should be integer number among (1-3)!!",
                        fg="red").grid(row=41, column=1)
            except Exception as e:
                if username_flag:
                    l_error = Label(master,
                                    text="Username is not unique!!",
                                    fg="red")
                    l_error.grid(row=41, column=1)
                elif "invalid literal for int() with base 10:" in str(e):
                    l_error = Label(master,
                                    text=str(e) + " Enter Integer value!!",
                                    fg="red")
                    l_error.grid(row=41, column=1)
                else:
                    l_error = Label(master, text=str(e), fg="red")
                    l_error.grid(row=41, column=1)
        else:
            Label(master, text="All user fields are mandatory!!",
                  fg="red").grid(row=42, column=1)
Beispiel #7
0
def call():
    global count1, count2, l_invalid, l9, l_unique, l_pmail, l_smail, l_all_properties, choice_type, l_error
    l_error = None
    l_invalid = None
    l_unique = None
    l_pmail = None
    l_smail = None
    l_all_properties = None
    l9 = None
    count1 = len(HealthDataDao.HealthDataDao().read_properties())
    count2 = len(QualificationDao.QualificationDao().readall())
    choice_type = None

    def check_if_unique_username():
        global l_unique
        username = e2.get()
        if l_unique is not None:
            l_unique.grid_forget()
        if e2.get():
            if not UserDao.UserDao().check_if_user_exists(username):
                l_unique = Label(master,
                                 text="Username is available",
                                 fg="green")
                l_unique.grid(row=3, column=2)
            else:
                l_unique = Label(master,
                                 text="Username already exists!!",
                                 fg="red")
                l_unique.grid(row=3, column=2)
        else:
            l_unique = Label(master,
                             text="Username field is mandatory!!",
                             fg="red")
            l_unique.grid(row=3, column=1)

    def check_if_correct_pemail_id():
        global l_pmail
        email_id = e5.get()
        if l_pmail is not None:
            l_pmail.grid_forget()
        try:
            if e5.get():
                if validate_email(email_id):
                    l_pmail = Label(master,
                                    text="Correct email ID",
                                    fg="green")
                    l_pmail.grid(row=6, column=2)
                else:
                    l_pmail = Label(master,
                                    text="primary mail is not correct",
                                    fg="red")
                    l_pmail.grid(row=6, column=2)
            else:
                l_pmail = Label(master,
                                text="EmailID field is mandatory!!",
                                fg="red")
                l_pmail.grid(row=6, column=1)
        except Exception as e:
            l_pmail = Label(master, text=str(e), fg="red")
            l_pmail.grid(row=6, column=2)

    def check_if_correct_semail_id():
        global l_smail
        email_id = e7.get()
        if l_smail is not None:
            l_smail.grid_forget()
        try:
            if e7.get():
                if validate_email(email_id):
                    l_smail = Label(master,
                                    text="Correct email ID",
                                    fg="green")
                    l_smail.grid(row=8, column=2)
                else:
                    l_smail = Label(master,
                                    text="secondaray mail is not correct",
                                    fg="red")
                    l_smail.grid(row=8, column=2)
            else:
                l_smail = Label(master,
                                text="EmailID field is mandatory!!",
                                fg="red")
                l_smail.grid(row=8, column=1)
        except Exception as e:
            l_smail = Label(master, text=str(e), fg="red")
            l_smail.grid(row=8, column=2)

    def display_properties():
        mstr = Tk()
        listbox = Listbox(mstr, width=100, height=50)
        listbox.pack()
        retList = HealthDataDao.HealthDataDao().read_properties()
        for prop in retList:
            listbox.insert(
                END, 'Property ID-' + str(prop.propertyid) + 'Property Name-' +
                prop.name + ' Property description - ' + prop.description)

    def add_property():
        flag = 0
        global count1, l_invalid
        if l_invalid is not None:
            l_invalid.grid_forget()
        if e29.get() and e31.get() and count1 > 0:
            try:
                id = int(e29.get())
                val = int(e31.get())
                retList = HealthDataDao.HealthDataDao().read_properties()
                if retList is not None:
                    for ret in retList:
                        if ret.propertyid == id:
                            propidlist.append(id)
                            propvallist.append(val)
                            count1 -= 1
                            flag = 1
                            Label(master,
                                  text="count=" + str(count1) + " left").grid(
                                      row=27, column=3)
                            break
                    if flag == 0:
                        l_invalid = Label(master,
                                          text="Invalid property ID",
                                          fg="red")
                        l_invalid.grid(row=30, column=1)
                else:
                    l_invalid = Label(master,
                                      text="Properties not present",
                                      fg="red")
                    l_invalid.grid(row=30, column=1)
            except Exception as e:
                l_invalid = Label(
                    master,
                    text="property id and value must be integers!!",
                    fg="red")
                l_invalid.grid(row=30, column=1)
        if count1 == 0:
            e29.grid_forget()
            e31.grid_forget()
            b1.grid_forget()
            b2.grid_forget()
            l1.grid_forget()
            l2.grid_forget()
            l3.grid_forget()
            l4.grid_forget()
            if l_invalid is not None:
                l_invalid.grid_forget()

    def display_qualifications():
        mstr = Tk()
        listbox = Listbox(mstr, width=100, height=50)
        listbox.pack()
        retList = QualificationDao.QualificationDao().readall()
        for qual in retList:
            listbox.insert(
                END, 'Qualification id - ' + str(qual.qualificationid) +
                ' Description - ' + qual.description)

    def add_qualification():
        global count2, l9

        if l9 is not None:
            l9.grid_forget()
        if e36.get() and count2 > 0:
            try:
                qid = int(e36.get())
                retList = QualificationDao.QualificationDao().readall()
                if QualificationDao.QualificationDao().is_present(
                        qid) is False:
                    l9 = Label(master,
                               text='Qualification id - ' + str(qid) +
                               ' not present in Database ',
                               fg="red")
                    l9.grid(row=37, column=1)
                else:
                    for qual in retList:
                        if qual.qualificationid == qid:
                            qual_list.append(qid)
                            count2 -= 1
                            Label(master,
                                  text="count=" + str(count2) + " left").grid(
                                      row=34, column=3)
                            break
            except Exception as e:
                l9 = Label(master,
                           text='Qualification id - ' + str(qid) +
                           ' not present in Database ',
                           fg="red")
                l9.grid(row=37, column=1)
        if count2 == 0:
            e36.grid_forget()
            b3.grid_forget()
            b4.grid_forget()
            l5.grid_forget()
            l6.grid_forget()
            l7.grid_forget()
            l8.grid_forget()

    def register():
        global l_all_properties, l_error
        username_flag = 0
        if e2.get() and e4.get() and e5.get() and e7.get() and e9.get() and e10.get() and e11.get() and e12.get() and \
                e13.get() and e14.get() and e15.get() and e16.get() and e17.get() and e18.get() and e19.get() and e21.get():
            try:
                if l_all_properties is not None:
                    l_all_properties.grid_forget()
                if l_error is not None:
                    l_error.grid_forget()
                if e2.get():
                    if not UserDao.UserDao().check_if_user_exists(e2.get()):
                        Label(master, text="Username is available",
                              fg="green").grid(row=3, column=2)
                    else:
                        Label(master,
                              text="Username already exists!!",
                              fg="red").grid(row=3, column=2)
                        username_flag = 1
                else:
                    Label(master,
                          text="Username field is mandatory!!",
                          fg="red").grid(row=3, column=1)

                if e5.get():
                    if validate_email(e5.get()):
                        Label(master, text="Correct email ID",
                              fg="green").grid(row=6, column=2)
                    else:
                        Label(master,
                              text="primary mail is not correct",
                              fg="red").grid(row=6, column=2)
                else:
                    Label(master,
                          text="EmailID field is mandatory!!",
                          fg="red").grid(row=6, column=1)

                if e7.get():
                    if validate_email(e7.get()):
                        Label(master, text="Correct email ID",
                              fg="green").grid(row=8, column=2)
                    else:
                        Label(master,
                              text="secondaray mail is not correct",
                              fg="red").grid(row=8, column=2)
                else:
                    Label(master,
                          text="EmailID field is mandatory!!",
                          fg="red").grid(row=8, column=1)

                uid = int(e21.get())

                if uid == 1:
                    karma = 0
                    enduserobj = Entities.EndUser(karma, datetime.date.today(),
                                                  e2.get(), e4.get(), e5.get(),
                                                  e7.get(), e9.get(),
                                                  e10.get(), e11.get(),
                                                  e12.get(), e13.get(),
                                                  e14.get(), e15.get(),
                                                  e16.get(), e17.get(),
                                                  e18.get(), e19.get(), uid, 1)
                    proplist = HealthDataDao.HealthDataDao().read_properties()
                    ocount = len(proplist)
                    mcount = ocount
                    datumkey = random.randint(1, 100000)
                    if count1 != 0:
                        l_all_properties = Label(
                            master,
                            text="You have to add all properties!!",
                            fg="red")
                        l_all_properties.grid(row=41, column=1)
                    else:
                        if EndUserBL.EndUserBL().create_end_user(
                                enduserobj) is True:
                            while mcount > 0:
                                datumobj = Entities.Datum(
                                    datumkey, e2.get(),
                                    propidlist[ocount - mcount],
                                    propvallist[ocount - mcount],
                                    datetime.date.today())
                                EndUserBL.EndUserBL(
                                ).create_user_datum_mapping(datumobj)
                                datumkey += 1
                                mcount -= 1
                            Label(master, text="Registered!",
                                  fg="green").grid(row=40, column=1)
                            propvallist.clear()
                            propidlist.clear()
                            master.after(1000, lambda: Tk.destroy(master))
                elif uid == 2:
                    phone = e22.get()
                    modobj = Entities.Moderator(phone, e2.get(), e4.get(),
                                                e5.get(), e7.get(), e9.get(),
                                                e10.get(), e11.get(),
                                                e12.get(), e13.get(),
                                                e14.get(), e15.get(),
                                                e16.get(), e17.get(),
                                                e18.get(), e19.get(), uid, 1)
                    if Moderator_BL.ModeratorBL().create_moderator(
                            modobj, qual_list) is True:
                        Label(master, text="Registered!!",
                              fg="green").grid(row=40, column=1)
                        qual_list.clear()
                        master.after(1000, lambda: Tk.destroy(master))
                elif uid == 3:
                    phone = e22.get()
                    adminobj = Entities.Administrator(phone,
                                                      e2.get(), e4.get(),
                                                      e5.get(), e7.get(),
                                                      e9.get(), e10.get(),
                                                      e11.get(), e12.get(),
                                                      e13.get(), e14.get(),
                                                      e15.get(), e16.get(),
                                                      e17.get(), e18.get(),
                                                      e19.get(), uid, 1)
                    if AdministratorBL.AdministratorBL().create_administrator(
                            adminobj) is True:
                        Label(master, text="Registered!!",
                              fg="green").grid(row=40, column=1)
                        master.after(1000, lambda: Tk.destroy(master))
                else:
                    Label(
                        master,
                        text=
                        "Wrong Choice..should be integer number among (1-3)!!",
                        fg="red").grid(row=41, column=1)
            except Exception as e:
                if username_flag:
                    l_error = Label(master,
                                    text="Username is not unique!!",
                                    fg="red")
                    l_error.grid(row=41, column=1)
                elif "invalid literal for int() with base 10:" in str(e):
                    l_error = Label(master,
                                    text=str(e) + " Enter Integer value!!",
                                    fg="red")
                    l_error.grid(row=41, column=1)
                else:
                    l_error = Label(master, text=str(e), fg="red")
                    l_error.grid(row=41, column=1)
        else:
            Label(master, text="All user fields are mandatory!!",
                  fg="red").grid(row=42, column=1)

    def choice_user_type():
        global choice_type
        if e21.get():
            choice_type = int(e21.get())

    master = Tk()
    Label(master, text="***** SignUp portal *****").grid(row=0, column=1)

    Label(master, text="Enter a unique username ").grid(row=2, column=0)
    e2 = Entry(master)
    e2.grid(row=2, column=1)
    Button(master, text="Check if Unique",
           command=check_if_unique_username).grid(row=2, column=2)

    l_1 = Label(master, text="Enter your password ")
    l_1.grid(row=4, column=0)
    e4 = Entry(master)
    e4.grid(row=4, column=1)
    l_2 = Label(master, text="Enter the first email id ")
    l_2.grid(row=5, column=0)
    e5 = Entry(master)
    e5.grid(row=5, column=1)
    Button(master, text="Check if correct",
           command=check_if_correct_pemail_id).grid(row=5, column=2)

    l_3 = Label(master, text="Enter the second email id ")
    l_3.grid(row=7, column=0)
    e7 = Entry(master)
    e7.grid(row=7, column=1)
    Button(master, text="Check if correct",
           command=check_if_correct_semail_id).grid(row=7, column=2)

    l_4 = Label(master, text="Enter the first name ")
    l_4.grid(row=9, column=0)
    e9 = Entry(master)
    e9.grid(row=9, column=1)
    l_5 = Label(master, text="Enter the last name ")
    l_5.grid(row=10, column=0)
    e10 = Entry(master)
    e10.grid(row=10, column=1)
    l_6 = Label(master, text="Tell us something about yourself ")
    l_6.grid(row=11, column=0)
    e11 = Entry(master)
    e11.grid(row=11, column=1)
    l_7 = Label(master, text="Enter the URL for your first profile photo ")
    l_7.grid(row=12, column=0)
    e12 = Entry(master)
    e12.grid(row=12, column=1)
    l_8 = Label(master, text="Enter the URL for your second profile photo ")
    l_8.grid(row=13, column=0)
    e13 = Entry(master)
    e13.grid(row=13, column=1)
    l_9 = Label(master, text="Enter the URL for your third profile photo ")
    l_9.grid(row=14, column=0)
    e14 = Entry(master)
    e14.grid(row=14, column=1)
    l_10 = Label(master, text="Enter the street number ")
    l_10.grid(row=15, column=0)
    e15 = Entry(master)
    e15.grid(row=15, column=1)
    l_11 = Label(master, text="Enter the street name ")
    l_11.grid(row=16, column=0)
    e16 = Entry(master)
    e16.grid(row=16, column=1)
    l_12 = Label(master, text="Enter the major municipality ")
    l_12.grid(row=17, column=0)
    e17 = Entry(master)
    e17.grid(row=17, column=1)
    l_13 = Label(master, text="Enter the governing district ")
    l_13.grid(row=18, column=0)
    e18 = Entry(master)
    e18.grid(row=18, column=1)
    l_14 = Label(master, text="Enter the postal area ")
    l_14.grid(row=19, column=0)
    e19 = Entry(master)
    e19.grid(row=19, column=1)
    l_15 = Label(master, text="Which type of user do you wish to add?")
    l_15.grid(row=20, column=0)
    l_16 = Label(master, text="1.End User 2.Moderator 3.Administrator")
    l_16.grid(row=21, column=0)
    e21 = Entry(master)
    e21.grid(row=21, column=1)

    l_17 = Label(master,
                 text="*****Property fields are only for End Users and "
                 "qualification fields are only for moderators*****")
    l_17.grid(row=23, column=1)
    b1 = Button(master,
                text="Click here to see Available properties",
                command=display_properties)
    b1.grid(row=26, column=1)

    propidlist = []
    propvallist = []
    l1 = Label(master, text="count=" + str(count1) + " left")
    l1.grid(row=27, column=3)
    l2 = Label(master,
               text="**You have to add values for each property. "
               "If you want to add more to this list, contact the admin..")
    l2.grid(row=27, column=0)
    l3 = Label(master, text="Enter propertyID to be added")
    l3.grid(row=29, column=0)
    e29 = Entry(master)
    e29.grid(row=29, column=1)
    l4 = Label(master, text="Enter value")
    l4.grid(row=31, column=0)
    e31 = Entry(master)
    e31.grid(row=31, column=1)
    b2 = Button(master, text="Add Property", command=add_property)
    b2.grid(row=31, column=2)
    l_18 = Label(
        master,
        text="Emergency Contact Number only for Moderator and Administrator")
    l_18.grid(row=22, column=0)
    e22 = Entry(master)
    e22.grid(row=22, column=1)
    b3 = Button(master,
                text="Click here to see Available qualifications. ",
                command=display_qualifications)
    b3.grid(row=33, column=1)
    qual_list = []
    l5 = Label(master, text="count=" + str(count2) + " left")
    l5.grid(row=34, column=3)
    l6 = Label(master,
               text="**You have to select only from the given qualifications. "
               "If you want to add more to this list, contact the admin..")
    l6.grid(row=34, column=0)
    l8 = Label(master,
               text="Invalid ID will lead to no entry in the database!!")
    l8.grid(row=35, column=1)
    l7 = Label(master, text="Enter qualificationID to be added")
    l7.grid(row=36, column=0)
    e36 = Entry(master)
    e36.grid(row=36, column=1)
    b4 = Button(master, text="Add Qualification", command=add_qualification)
    b4.grid(row=36, column=2)

    b_reg = Button(master, text="Register", command=register)
    b_reg.grid(row=39, column=1)
    master.mainloop()
Beispiel #8
0
 def add_property(self, propobj):
     try:
         return HealthDataDao.HealthDataDao().create_property(propobj)
     except Exception as e:
         raise
def call(username):
    print('Welcome EndUser to SmartHealth')
    #username = input('Enter your username ')
    einput1 = int(
        input(
            'How can we help you? 1.Display my details 2.Update my details 3.Visit friendship portal 4.Visit Discussion Forum'
        ))
    if einput1 == 1:
        retlist = EndUserBL.EndUserBL().read_end_user(username)
        euobj = retlist[0]
        datumlist = retlist[1]
        print('UserName-' + euobj.username + ' Password-' + euobj.password +
              ' FirstEmailID-' + euobj.email1 + ' SecondEmailID-' +
              euobj.email2 + ' FirstName-' + euobj.firstname + ' LastName-' +
              euobj.lastname + ' AboutYou-' + euobj.aboutme + ' URL1-' +
              euobj.photourl1 + ' URL2-' + euobj.photourl2 + ' URL3-' +
              euobj.photourl3 + ' StreetNumber-' + euobj.streetnumber +
              ' StreetName-' + euobj.streetname + ' MajorMunicipality-' +
              euobj.majormunicipality + ' Gov. District-' +
              euobj.governingdistrict + ' PostalArea-' + euobj.postalarea +
              ' Karma-' + str(euobj.karma))
        print('Following is the Activity Mapping with legend..')
        for d in datumlist:
            print('Property ID-' + str(d.propertyid) + ' Value-' + d.value)
        print(
            '*************************************************************************************************************'
        )
        print('Properties in Database-')
        myproplist = HealthDataDao.HealthDataDao().read_properties()
        for prop in myproplist:
            print('Property id - ' + str(prop.propertyid) +
                  ' Property name - ' + prop.name +
                  ' Property description - ' + prop.description)
    elif einput1 == 2:
        retlist = EndUserBL.EndUserBL().read_end_user(username)
        euobj = retlist[0]
        datumlist = retlist[1]
        einput2 = int(
            input('What do you wish to update? 1.Basic details 2.Activities'))
        if einput2 == 1:
            field_no = int(
                input(
                    "Enter the field number that you wish to update:- 1.Password 2.FirstEmailId 3.SecondEmailId 4.FirstName 5.LastName 6.AboutMe 7.Url1 8.Url2 9.Url3 10.StreetNumber 11.StreetName 12.MajorMunicipality 13.GoverningDistrict 14.PostalArea"
                ))
            if field_no == 1:
                var = input("Enter the new value ")
                euobj.password = var
            elif field_no == 2:
                var = input("Enter the new value ")
                euobj.email1 = var
            elif field_no == 3:
                var = input("Enter the new value ")
                euobj.email2 = var
            elif field_no == 4:
                var = input("Enter the new value ")
                euobj.firstname = var
            elif field_no == 5:
                var = input("Enter the new value ")
                euobj.lastname = var
            elif field_no == 6:
                var = input("Enter the new value ")
                euobj.aboutme = var
            elif field_no == 7:
                var = input("Enter the new value ")
                euobj.photourl1 = var
            elif field_no == 8:
                var = input("Enter the new value ")
                euobj.photourl12 = var
            elif field_no == 9:
                var = input("Enter the new value ")
                euobj.photourl13 = var
            elif field_no == 10:
                var = input("Enter the new value ")
                euobj.streetnumber = var
            elif field_no == 11:
                var = input("Enter the new value ")
                euobj.streetname = var
            elif field_no == 12:
                var = input("Enter the new value ")
                euobj.majormunicipality = var
            elif field_no == 13:
                var = input("Enter the new value ")
                euobj.governingdistrict = var
            elif field_no == 14:
                var = input("Enter the new value ")
                euobj.postalarea = var
            if EndUserBL.EndUserBL().update_end_user(euobj) is True:
                print('Updated!')
        elif einput2 == 2:
            retlist = EndUserBL.EndUserBL().read_end_user(username)
            euobj = retlist[0]
            datumlist = retlist[1]
            print('UserName-' + euobj.username + ' Password-' +
                  euobj.password + ' FirstEmailID-' + euobj.email1 +
                  ' SecondEmailID-' + euobj.email2 + ' FirstName-' +
                  euobj.firstname + ' LastName-' + euobj.lastname +
                  ' AboutYou-' + euobj.aboutme + ' URL1-' + euobj.photourl1 +
                  ' URL2-' + euobj.photourl2 + ' URL3-' + euobj.photourl3 +
                  ' StreetNumber-' + euobj.streetnumber + ' StreetName-' +
                  euobj.streetname + ' MajorMunicipality-' +
                  euobj.majormunicipality + ' Gov. District-' +
                  euobj.governingdistrict + ' PostalArea-' + euobj.postalarea +
                  ' Karma-' + str(euobj.karma))
            print('Following is the Activity Mapping with legend..')
            for d in datumlist:
                print('Datum ID-' + str(d.datumid) + ' Property ID-' +
                      str(d.propertyid) + ' Value-' + d.value)
            print(
                '*************************************************************************************************************'
            )
            print('Properties in Database-')
            myproplist = HealthDataDao.HealthDataDao().read_properties()
            for prop in myproplist:
                print('Property id - ' + str(prop.propertyid) +
                      ' Property name - ' + prop.name +
                      ' Property description - ' + prop.description)
            print(
                '*************************************************************************************************************'
            )
            print(
                'To update activity, simply insert the  Datum ID,Property ID and its new value'
            )
            did = int(input('Enter the DatumID'))
            pid = int(input('Enter the PropertyID'))
            val = input('Enter value')
            do = Entities.Datum(did, username, pid, val, datetime.date.today())
            if EndUserBL.EndUserBL().update_datum(do) is True:
                print('Updated!')
    elif einput1 == 3:
        FriendshipMain.call(username)
    elif einput1 == 4:
        EndUserDiscussionForumMain.call(username)
Beispiel #10
0
def call(username):
    print('Manage your friends from here!!')
    business_logic = SocialNetworkingLogic.SocialNetworkingLogic()
    #username = input('Enter your username please: ')
    choice1 = int(
        input(
            '1. Display my friends    2. Send friend request to someone   '
            '3. Display pending requests     4. Accept friend request   5. Decline friend request    '
            ' 6. Un-friend someone      7. View health data of your friend '
            '8. Exit social networking portal'))
    if choice1 == 1:
        my_friends = business_logic.return_my_friends(username)
        i = 0
        print('Following are your friends: ')
        for friend in my_friends:
            i += 1
            if username == friend.requester_username:
                print(str(i) + '. ' + friend.requested_username)
            elif username == friend.requested_username:
                print(str(i) + '. ' + friend.requester_username)
    elif choice1 == 2:
        requested_username = input(
            'Enter username you want to befriend with: ')
        sent = business_logic.send_request(username, requested_username)
        if sent:
            print('Friend request is sent.')
        else:
            print('Either your or yours to be friend'
                  's username is incorrect!!')
    elif choice1 == 3:
        my_pending_requests = business_logic.return_my_friend_requests(
            username)
        i = 0
        for pending_request in my_pending_requests:
            i += 1
            print(str(i) + '. ' + pending_request.requester_username)
    elif choice1 == 4:
        requester_username = input(
            'Enter the username of the person whose friend request you want to accept: '
        )
        accepted = business_logic.accept_request(requester_username, username)
        if accepted:
            print('Friend request accepted!!')
        else:
            print('Request does not exist!!')
    elif choice1 == 5:
        requester_username = input(
            'Enter the username of the person whose friend request you want to reject: '
        )
        rejected = business_logic.decline_request(requester_username, username)
        if rejected:
            print('Friend request rejected!!')
        else:
            print('Request does not exist!!')
    elif choice1 == 6:
        friend_username = input('Enter username of your '
                                'to be ex-friend:'
                                ' ')
        unfriended = business_logic.unfirend(username, friend_username)
        if unfriended:
            print('You are no longer friends with ' + friend_username)
        else:
            print('You already are not friends with ' + friend_username)
    elif choice1 == 7:
        print('Here is the health data of all your active friends: ')
        health_dao = HealthDataDao.HealthDataDao()
        my_friends = business_logic.return_my_friends(username)
        for friend in my_friends:
            if friend.requester_username == username:
                mydatumlist = health_dao.read_datum(friend.requested_username)
                for datum in mydatumlist:
                    print('Property id: ' + str(datum.propertyid) +
                          '     Value: ' + str(datum.value))
            elif friend.requested_username == username:
                mydatumlist = health_dao.read_datum(friend.requester_username)
                for datum in mydatumlist:
                    print('Property id: ' + str(datum.propertyid) +
                          '     Value: ' + str(datum.value))
        print('***********************************************')
        properties = health_dao.read_properties()
        for property in properties:
            print('Property id: ' + str(property.propertyid) + ', Name: ' +
                  property.name + ', Description: ' + property.description)
 def update_datum(self, datumobj):
     try:
         return HealthDataDao.HealthDataDao().update_datum(datumobj)
     except Exception as e:
         raise
 def create_user_datum_mapping(self, datumobj):
     try:
         return HealthDataDao.HealthDataDao().create_datum_mapping(datumobj)
     except Exception as e:
         raise
def call():
    datumkey = random.randint(1, 100000)
    username = input("Enter the username ")
    if not UserDao.UserDao().check_if_user_exists(username):
        password = input('Enter your password ')
        eid_1 = input("Enter the first email id ")
        eid_2 = input("Enter the second email id ")
        fname = input("Enter the first name ")
        lname = input("Enter the last name ")
        about_me = input("Tell us something about yourself ")
        url_1 = input("Enter the URL for your first profile photo ")
        url_2 = input("Enter the URL for your second profile photo ")
        url_3 = input("Enter the URL for your third profile photo ")
        street_num = input("Enter the street number ")
        street_name = input("Enter the street name ")
        major_municipality = input("Enter the major municipality ")
        gov_district = input("Enter the governing district ")
        post_area = input("Enter the postal area ")
        #status = int(input("Enter the status-Should be tinyint.. "))
        print("Which type of user do you wish to add?")
        print("1.End User 2.Moderator 3.Administrator")
        command_var_2 = int(input())
        if command_var_2 == 1:
            user_type_id = 1
            print('Enter the values for the following properties-')
            myproplist = HealthDataDao.HealthDataDao().read_properties()
            mypropidlist = []
            propvallist = []
            if myproplist is not None:
                for prop in myproplist:
                    mypropidlist.append(prop.propertyid)
                    print('Property id - ' + str(prop.propertyid) +
                          ' Property name - ' + prop.name +
                          ' Property description - ' + prop.description)
                looplen = len(myproplist)
                while looplen > 0:
                    propvallist.append(
                        int(input(
                            'Enter the value for the property in order')))
                    looplen -= 1
                karma = 0
                enduserobj = Entities.EndUser(
                    karma, datetime.date.today(), username, password, eid_1,
                    eid_2, fname, lname, about_me, url_1, url_2, url_3,
                    street_num, street_name, major_municipality, gov_district,
                    post_area, user_type_id, 1)
                olooplen = len(myproplist)
                mlooplen = len(myproplist)
                if EndUserBL.EndUserBL().create_end_user(enduserobj) is True:
                    while mlooplen > 0:
                        datumobj = Entities.Datum(
                            datumkey, username,
                            mypropidlist[olooplen - mlooplen],
                            propvallist[olooplen - mlooplen],
                            datetime.date.today())
                        EndUserBL.EndUserBL().create_user_datum_mapping(
                            datumobj)
                        datumkey += 1
                        mlooplen -= 1
                    print("Added!")
            else:
                print("No properties exist! Ask admin to add properties")
        elif command_var_2 == 2:
            user_type_id = 2
            emergency_no = input('Enter your emergency contact number ')
            no_of_qual = int(input('Enter count of the qualifications '))
            myquallist = QualificationDao.QualificationDao().readall()
            myinputlist = []
            if myquallist != None:
                print(
                    'Select from the following qualifications. If you want to add more to this list, contact the admin..'
                )
                for qual1 in myquallist:
                    print('Qualification id - ' + str(qual1.qualificationid) +
                          ' Description - ' + qual1.description)
                while no_of_qual > 0:
                    qualification_id = int(
                        input(
                            'Enter Qualification ID.Invalid ID will not lead to an entry in the database!!'
                        ))
                    if QualificationDao.QualificationDao().is_present(
                            qualification_id) is False:
                        print('Qualification id - ' + str(qualification_id) +
                              ' not present in Database ')
                    else:
                        for qual2 in myquallist:
                            if qual2.qualificationid == qualification_id:
                                myinputlist.append(qual2)
                    no_of_qual -= 1
                modobj = Entities.Moderator(emergency_no, username, password,
                                            eid_1, eid_2, fname, lname,
                                            about_me, url_1, url_2, url_3,
                                            street_num, street_name,
                                            major_municipality, gov_district,
                                            post_area, user_type_id, 1)
                Moderator_BL.ModeratorBL().create_moderator(
                    modobj, myinputlist)
                print("Added!")
            else:
                print(
                    "No qualification found! Ask the admin to add a qualification"
                )
        elif command_var_2 == 3:
            user_type_id = 3
            emergency_no = input("Enter your emergency contact number ")
            adminobj = Entities.Administrator(emergency_no, username, password,
                                              eid_1, eid_2, fname, lname,
                                              about_me, url_1, url_2, url_3,
                                              street_num, street_name,
                                              major_municipality, gov_district,
                                              post_area, user_type_id, 1)
            if AdministratorBL.AdministratorBL().create_administrator(
                    adminobj) is True:
                print("Added!")
    else:
        print('User name already exists! Try again')
        call()