def give_rating_to_post(self, rating_object):
     rating_given = False
     rating_dao = RatingDAO.RatingDAO()
     post_dao = PostDAO.PostDAO()
     user_dao = UserDao.UserDao()
     post_existing = post_dao.read(rating_object.post_username, rating_object.post_timecreated)
     if post_existing != None:
         if (user_dao.check_if_user_exists(rating_object.rater_username) == True):
             rating_given = rating_dao.create(rating_object)
     return rating_given
 def create_comment(self, comment_object):
     comment_created = False
     comment_dao = CommentDAO.CommentDAO()
     post_dao = PostDAO.PostDAO()
     user_dao = UserDao.UserDao()
     post_existing = post_dao.read(comment_object.post_username, comment_object.post_timeCreated)
     if post_existing != None:
         if (user_dao.check_if_user_exists(comment_object.commenter_username) == True):
             comment_created = comment_dao.create(comment_object)
     return comment_created
 def create_post(self, post_object):
     post_created = False
     forum_dao = ForumDAO.ForumDAO()
     post_dao = PostDAO.PostDAO()
     user_dao = UserDao.UserDao()
     forum_existing = forum_dao.read(post_object.forumid)
     if forum_existing != None:
         if (user_dao.check_if_user_exists(post_object.username) == True):
             post_created = post_dao.create(post_object)
     return post_created
Exemple #4
0
def login():
    username = user_name.get()
    password_text = password.get()
    user_type = UserDao.UserDao().login(username, password_text)
    if user_type == 1:
        EndUserGUI.call(username)
    elif user_type == 2:
        ModGUI.call(username)
    elif user_type == 3:
        AdminGUI.call(username)
    else:
        Label(master, text="Invalid user name or password!!").grid(row=6, column=2)
Exemple #5
0
 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)
Exemple #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)
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()