Exemple #1
0
def afterFacilityRate(request, facilityID, userName):
    some_var = request.POST.getlist('checks[]')
    for i in range(1, 6):
        rb = "radio{}".format(i)
        print("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$")
        print(rb)
        print("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$")
        if rb in request.POST:
            print(
                "8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888"
            )
            DB_Action.facilityRate(i, facilityID)
    user = DB_Action.get_user_by_userName(userName)

    neighborhoddList = json_Action.dict_neighborho.keys()
    facilitiesList = json_Action.dict_Type.keys()
    user["Email"] = user["E-mail"]
    context = {
        "user": user,
        "neighborhoddList": neighborhoddList,
        "facilities": facilitiesList,
        "id": user['_id'],
        "username": userName,
        "role": "3"
    }
    return render(request, "../templates/folder_trainee/web_trainee.html",
                  context)
Exemple #2
0
def register(request):
    regex = '^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$'
    uname = request.POST.get('usernameSignUp', False)
    firstpwd = request.POST.get('firstPasswordSignUp', False)
    secpwd = request.POST.get('secondPasswordSignUp', False)
    fullName = request.POST.get('fullName', False)
    email = request.POST.get('emailAdressSignUp', False)
    views = request.POST.get('fullName', False)
    if (firstpwd != secpwd):
        messages.info(request, 'please enter same password')
        return render(request, "../templates/registration/sign-up.html")
    elif (DB_Action.checkUserNameExistence(uname)):
        messages.info(request, 'user name already Exist')
        return render(request, "../templates/registration/sign-up.html")
    elif (DB_Action.checkEmailExistence(email)):
        messages.info(request, 'email address already exist')
        return render(request, "../templates/registration/sign-up.html")
    elif (not re.search(regex, email)):
        messages.info(request, 'ilegal email address')
        return render(request, "../templates/registration/sign-up.html")
    elif (" " not in fullName):
        messages.info(request, 'ilegal name')
        return render(request, "../templates/registration/sign-up.html")
    else:
        DB_Action.insert_user(uname, firstpwd,
                              fullName.split(" ")[0],
                              fullName.split(" ")[1], '1', email)
        return render(request, "../templates/registration/sign-in.html")
Exemple #3
0
 def test_get_user_by_userName(self):
     self.assertEqual(DB_Action.get_user_by_userName("tz"), None)
     self.assertEqual(
         DB_Action.get_user_by_userName("admin89"), {
             "_id": "389",
             "userName": "******",
             "password": "******",
             "firstName": "bar",
             "lastName": "butler",
             "role": "1",
             "E-mail": "*****@*****.**"
         })
Exemple #4
0
def loginBtn(request):
    uname = request.POST.get('username', False)
    pwd = request.POST.get('password', False)
    user = DB_Action.get_user_by_userName(uname)
    if (user != None and uname != None and pwd != None):
        user["Email"] = user["E-mail"]
        if (user['password'] == pwd):
            if (user['role'] == '1'):
                allusers = DB_Action.getAllUsers()
                facilities = json_Action.Sports_facilities()
                user["Email"] = user["E-mail"]
                context = {
                    "user": user,
                    "object_List": allusers,
                    "facilities": facilities.distros_dict
                }
                return render(request, "admin2.html", context)
            if (user['role'] == '2'):
                neighborhoddList = json_Action.dict_neighborho.keys()
                facilitiesList = json_Action.dict_Type.keys()
                user["Email"] = user["E-mail"]
                context = {
                    "user": user,
                    "neighborhoddList": neighborhoddList,
                    "facilities": facilitiesList,
                    "id": user['_id'],
                    "username": uname,
                    "role": "2"
                }
                return render(request,
                              "../templates/folder_trainer/trainer_web.html",
                              context)
            if (user['role'] == '3'):
                neighborhoddList = json_Action.dict_neighborho.keys()
                facilitiesList = json_Action.dict_Type.keys()
                user["Email"] = user["E-mail"]
                context = {
                    "user": user,
                    "neighborhoddList": neighborhoddList,
                    "facilities": facilitiesList,
                    "id": user['_id'],
                    "username": uname,
                    "role": "3"
                }
                return render(request,
                              "../templates/folder_trainee/web_trainee.html",
                              context)
    else:
        messages.info(request, 'username or password are inccorect')
        return render(request, "../templates/registration/sign-in.html")
Exemple #5
0
def adminAfterUpdate(request):
    id = request.POST.get('ID')
    userName = request.POST.get('userName')
    pwd = request.POST.get('password')
    Email = request.POST.get('Email')
    fullName = request.POST.get('fullName')
    role = request.POST.get('role')
    fullNameSplited = fullName.split(' ')
    firstName = fullNameSplited[0]
    lasttName = fullNameSplited[1]
    DB_Action.updateUser(id, firstName, lasttName, pwd, userName, Email, role)
    allusers = DB_Action.getAllUsers()
    facilities = json_Action.Sports_facilities()
    context = {"object_List": allusers, "facilities": facilities.distros_dict}
    return render(request, "admin2.html", context)
Exemple #6
0
def afterFacilityUpdate(request, origName, origType, origOwner,
                        origNeighborhood, origOperator, origOpenHours):
    name = request.POST.get('name')
    type = request.POST.get("type")
    neighborhood = request.POST.get("neighborhood")
    Operator = request.POST.get("Operator")
    Owner = request.POST.get("Owner")
    OpenHours = request.POST.get("OpenHours")
    facilityToUpdate = {
        "Type": type,
        "Name": name,
        "Operator": Operator,
        "Owner": Owner,
        "neighborho": neighborhood,
        "OpenHours": OpenHours
    }
    originalFacility = {
        "Type": origType,
        "Name": origName,
        "Operator": origOperator,
        "Owner": origOwner,
        "neighborho": origNeighborhood
    }
    facilities = json_Action.Sports_facilities()
    facilities.updateFacility(originalFacility, facilityToUpdate)
    allusers = DB_Action.getAllUsers()
    facilities = json_Action.Sports_facilities()
    context = {"object_List": allusers, "facilities": facilities.distros_dict}
    return render(request, "admin2.html", context)
Exemple #7
0
def deleteFacility(request, facilityId):
    jsonAct = json_Action.Sports_facilities()
    # faciltyToDelete = {"Type": facilityType,"Name":facilityName , "neighborho":facilityNeighborhood,"Operator": facilityOperator, "Owner": facilityOwner}
    jsonAct.delete_facility(facilityId)
    allusers = DB_Action.getAllUsers()
    facilities = json_Action.Sports_facilities()
    context = {"object_List": allusers, "facilities": facilities.distros_dict}
    return render(request, "admin2.html", context)
Exemple #8
0
def showUpdateUser(request, UserID):
    context = DB_Action.get_user_by_ID(UserID)
    context['firstName'] = "{} {}".format(context['firstName'],
                                          context['lastName'])
    context['id'] = context['_id']
    context['Email'] = context['E-mail']
    return render(request, "../templates/registration/update.html",
                  {"user": context})
Exemple #9
0
def afterverify(request, ans, userName):
    if (ans == "0"):
        DB_Action.insertcoachToRate(userName)
    user = DB_Action.get_user_by_userName(userName)
    neighborhoddList = json_Action.dict_neighborho.keys()
    facilitiesList = json_Action.dict_Type.keys()
    user["Email"] = user["E-mail"]
    context = {
        "user": user,
        "neighborhoddList": neighborhoddList,
        "facilities": facilitiesList,
        "id": user['_id'],
        "username": user["userName"],
        "role": "2"
    }
    return render(request, "../templates/folder_trainer/trainer_web.html",
                  context)
Exemple #10
0
def afterCoachRate(request, coachID, rate, userName):
    #flagFile = open("../static/flag.txt", "r")
    #flag = flagFile.read()
    coach = DB_Action.get_user_by_ID(coachID)
    DB_Action.insertCoachRate(rate, coach)
    user = DB_Action.get_user_by_userName(userName)
    neighborhoddList = json_Action.dict_neighborho.keys()
    facilitiesList = json_Action.dict_Type.keys()
    user["Email"] = user["E-mail"]
    context = {
        "user": user,
        "neighborhoddList": neighborhoddList,
        "facilities": facilitiesList,
        "id": user['_id'],
        "username": userName,
        "role": "3"
    }
    return render(request, "../templates/folder_trainee/web_trainee.html",
                  context)
Exemple #11
0
def showFacilityInMap(request, facilityId):
    # facilityToUpdate = {"Type": facilityType,"Name":facilityName , "neighborho":facilityNeighborhood,"Operator": facilityOperator, "Owner": facilityOwner}
    users = DB_Action.getAllUsers()
    tmp = json_Action.Sports_facilities()
    tmp = tmp.distros_dict
    s = {}
    for obf in tmp:
        if (obf["id"] == facilityId):
            s = obf
            break
    context = {"myFacility": s, "users": users}
    return render(request, "map.html", context)
Exemple #12
0
def watchTrainers(request, userName):
    allcoaches = list(DB_Action.usersCollection.find({"role": "2"}))
    allrates = DB_Action.getAllCoachRates()
    for coach in allcoaches:
        coach["numOfRates"] = 0
        coach["AVGrate"] = 0
        coach["Email"] = coach["E-mail"]
        coach["coachID"] = coach["_id"]
    for rate in allrates:
        rate["coachID"] = rate["coach_id"]
        for coach in allcoaches:
            if (rate["coach_id"] == coach["_id"]):
                coach["numOfRates"] = rate["numOfrates"]
                coach["AVGrate"] = rate["AVGrate"]
    context = {"coachRates": allrates, "user": userName}
    return render(request, "../templates/folder_trainee/watchTrainers.html",
                  context)
Exemple #13
0
    def test_get_filtered_sport_facility_by_ligth(self):
        user_name = "admin89"
        if (DB_Action.checkUserNameExistence(user_name) == False):
            raise Exception("this user name {} not exist".format(user_name))

        user = DB_Action.get_user_by_userName(user_name)
        if (json_Action.check_permission(user) == False):
            raise Exception(
                "this user {} do not have permission".format(user_name))

        facilities_result = [{
            'Type': "מגרש ספורט משולב – 43X32 מ'",
            'Name': 'רמב"ם',
            'street': 'קדושי בגדד',
            'HouseNumbe': '1.0',
            'neighborho': "ג'",
            'Operator': 'ניהול עצמי',
            'Seats': '0.0',
            'Activity': 'פתוח ללא הגבלה',
            'fencing': 'קיים גידור',
            'lighting': 'קיימת תאורה',
            'handicappe': 'נגיש לנכים',
            'condition': 'תקין ופעיל',
            'Owner': 'עיריית באר שבע',
            'ForSchool': 'רמב"ם',
            'associatio': '',
            'SportType': '',
            'lat': '31.252959540000063',
            'lon': '34.77930799000006',
            'id': '20'
        }, {
            'Type': "אצטדיון/מסלול אתלטיקה קלה – 6-4 מסלולים, 250 או 300 מ'",
            'Name': "מקיף א'",
            'street': 'דרך השלום',
            'HouseNumbe': '15.0',
            'neighborho': "ג'",
            'Operator': 'כיוונים',
            'Seats': '0.0',
            'Activity': 'פתוח ללא הגבלה',
            'fencing': 'קיים גידור',
            'lighting': 'קיימת תאורה',
            'handicappe': 'נגיש לנכים',
            'condition': 'תקין ופעיל',
            'Owner': 'עיריית באר שבע',
            'ForSchool': "מקיף א'",
            'associatio': '',
            'SportType': '',
            'lat': '31.252697283000032',
            'lon': '34.801092856000025',
            'id': '59'
        }, {
            'Type': "מגרש כדורגל – 45X90 מ'",
            'Name': 'טאובל',
            'street': 'בן גוריון',
            'HouseNumbe': '0.0',
            'neighborho': "ג'",
            'Operator': 'כיוונים',
            'Seats': '0.0',
            'Activity': 'בתיאום בלבד',
            'fencing': 'קיים גידור',
            'lighting': 'קיימת תאורה',
            'handicappe': 'נגיש לנכים',
            'condition': 'תקין ופעיל',
            'Owner': 'עיריית באר שבע',
            'ForSchool': '',
            'associatio': '',
            'SportType': '',
            'lat': '31.253835614000025',
            'lon': '34.813499412000056',
            'id': '66'
        }, {
            'Type': 'מגרש טניס',
            'Name': 'טאובל',
            'street': 'בן גוריון',
            'HouseNumbe': '0.0',
            'neighborho': "ג'",
            'Operator': 'כיוונים',
            'Seats': '0.0',
            'Activity': 'פתוח ללא הגבלה',
            'fencing': 'קיים גידור',
            'lighting': 'קיימת תאורה',
            'handicappe': 'נגיש לנכים',
            'condition': 'תקין ופעיל',
            'Owner': 'עיריית באר שבע',
            'ForSchool': '',
            'associatio': '',
            'SportType': '',
            'lat': '31.255589585000052',
            'lon': '34.812797157000034',
            'id': '67'
        }, {
            'Type': "מגרש כדורסל – 19X32 מ'",
            'Name': 'נטעים',
            'street': 'גולומב',
            'HouseNumbe': '0.0',
            'neighborho': "ג'",
            'Operator': 'ניהול עצמי',
            'Seats': '0.0',
            'Activity': 'פתוח ללא הגבלה',
            'fencing': 'קיים גידור',
            'lighting': 'קיימת תאורה',
            'handicappe': 'נגיש לנכים',
            'condition': 'תקין ופעיל',
            'Owner': 'עיריית באר שבע',
            'ForSchool': 'נטעים',
            'associatio': '',
            'SportType': '',
            'lat': '31.25481152900005',
            'lon': '34.80434551500008',
            'id': '77'
        }, {
            'Type': "אולם ספורט קטן – 20x10 מ'",
            'Name': 'נטעים',
            'street': 'גולומב',
            'HouseNumbe': '0.0',
            'neighborho': "ג'",
            'Operator': 'ניהול עצמי',
            'Seats': '0.0',
            'Activity': 'בתיאום בלבד',
            'fencing': 'קיים גידור',
            'lighting': 'קיימת תאורה',
            'handicappe': 'נגיש לנכים',
            'condition': 'תקין ופעיל',
            'Owner': 'עיריית באר שבע',
            'ForSchool': 'נטעים',
            'associatio': '',
            'SportType': '',
            'lat': '31.254599988000052',
            'lon': '34.80413410500006',
            'id': '78'
        }, {
            'Type': "מגרש כדורסל – 19X32 מ'",
            'Name': 'אולפנת אמי"ת',
            'street': 'וינגייט',
            'HouseNumbe': '0.0',
            'neighborho': "ג'",
            'Operator': 'כיוונים',
            'Seats': '0.0',
            'Activity': 'פתוח ללא הגבלה',
            'fencing': 'קיים גידור',
            'lighting': 'קיימת תאורה',
            'handicappe': 'נגיש לנכים',
            'condition': 'תקין ופעיל',
            'Owner': 'עיריית באר שבע',
            'ForSchool': 'אמי"ת',
            'associatio': '',
            'SportType': '',
            'lat': '31.254698034000057',
            'lon': '34.801090842000065',
            'id': '88'
        }, {
            'Type': "אולם ספורט בינוני – 32x19 מ'",
            'Name': 'אולפנת אמי"ת',
            'street': 'וינגייט',
            'HouseNumbe': '0.0',
            'neighborho': "ג'",
            'Operator': 'כיוונים',
            'Seats': '100.0',
            'Activity': 'בתיאום בלבד',
            'fencing': 'קיים גידור',
            'lighting': 'קיימת תאורה',
            'handicappe': 'נגיש לנכים',
            'condition': 'תקין ופעיל',
            'Owner': 'עיריית באר שבע',
            'ForSchool': 'אמי"ת',
            'associatio': 'מכבי דרום',
            'SportType': 'התעמלות אומנותית',
            'lat': '31.254729720000057',
            'lon': '34.800717803000055',
            'id': '89'
        }, {
            'Type': "אולם ספורט קטן – 20x10 מ'",
            'Name': 'דגניה',
            'street': "ז'בוטינסקי",
            'HouseNumbe': '17.0',
            'neighborho': "ג'",
            'Operator': 'ניהול עצמי',
            'Seats': '0.0',
            'Activity': 'בתיאום בלבד',
            'fencing': 'קיים גידור',
            'lighting': 'קיימת תאורה',
            'handicappe': 'נגיש לנכים',
            'condition': 'תקין ופעיל',
            'Owner': 'עיריית באר שבע',
            'ForSchool': '',
            'associatio': '',
            'SportType': '',
            'lat': '31.24996042300006',
            'lon': '34.80812192500008',
            'id': '98'
        }, {
            'Type': "אולם ספורט קטן – 15x24 מ'",
            'Name': 'חזון עובדיה',
            'street': 'גוש עציון',
            'HouseNumbe': '13.0',
            'neighborho': "ג'",
            'Operator': 'ניהול עצמי',
            'Seats': '0.0',
            'Activity': 'בתיאום בלבד',
            'fencing': 'קיים גידור',
            'lighting': 'קיימת תאורה',
            'handicappe': 'נגיש לנכים',
            'condition': 'תקין ופעיל',
            'Owner': 'עיריית באר שבע',
            'ForSchool': '',
            'associatio': '',
            'SportType': '',
            'lat': '31.253308584000024',
            'lon': '34.80797698500004',
            'id': '102'
        }, {
            'Type': "מגרש ספורט משולב – 43X32 מ'",
            'Name': 'טאובל',
            'street': 'בן גוריון',
            'HouseNumbe': '0.0',
            'neighborho': "ג'",
            'Operator': 'כיוונים',
            'Seats': '0.0',
            'Activity': 'פתוח ללא הגבלה',
            'fencing': 'קיים גידור',
            'lighting': 'קיימת תאורה',
            'handicappe': 'נגיש לנכים',
            'condition': 'תקין ופעיל',
            'Owner': 'עיריית באר שבע',
            'ForSchool': '',
            'associatio': '',
            'SportType': '',
            'lat': '31.255115363000073',
            'lon': '34.813026809000064',
            'id': '103'
        }, {
            'Type': "אולם ספורט בינוני – 32x19 מ'",
            'Name': "מקיף א'",
            'street': 'דרך השלום',
            'HouseNumbe': '15.0',
            'neighborho': "ג'",
            'Operator': 'כיוונים',
            'Seats': '0.0',
            'Activity': 'בתיאום בלבד',
            'fencing': 'קיים גידור',
            'lighting': 'קיימת תאורה',
            'handicappe': 'נגיש לנכים',
            'condition': 'תקין ופעיל',
            'Owner': 'עיריית באר שבע',
            'ForSchool': "מקיף א'",
            'associatio': 'ניקה,מכבי, כיוונים',
            'SportType': 'ריקודים, כדורסל, נכים',
            'lat': '31.252473181000028',
            'lon': '34.80021493900006',
            'id': '116'
        }, {
            'Type': "מגרש ספורט משולב – 43X32 מ'",
            'Name': "מקיף א'",
            'street': 'דרך השלום',
            'HouseNumbe': '15.0',
            'neighborho': "ג'",
            'Operator': 'כיוונים',
            'Seats': '0.0',
            'Activity': 'פתוח ללא הגבלה',
            'fencing': 'קיים גידור',
            'lighting': 'קיימת תאורה',
            'handicappe': 'נגיש לנכים',
            'condition': 'תקין ופעיל',
            'Owner': 'עיריית באר שבע',
            'ForSchool': "מקיף א'",
            'associatio': '',
            'SportType': '',
            'lat': '31.252804155000035',
            'lon': '34.80168226600006',
            'id': '120'
        }, {
            'Type': 'קט רגל וינגייט',
            'Name': '',
            'street': 'וינגייט',
            'HouseNumbe': '0.0',
            'neighborho': 'ג',
            'Operator': 'כיוונים',
            'Seats': '0.0',
            'Activity': '',
            'fencing': '',
            'lighting': 'כן',
            'handicappe': '',
            'condition': 'טוב מאוד',
            'Owner': '',
            'ForSchool': '',
            'associatio': 'לא',
            'SportType': '',
            'lat': '31.256328799000073',
            'lon': '34.802853764000076',
            'id': '142'
        }, {
            'Type': 'מתקן אימון כושר גופני',
            'Name': 'פארק מרמלדה',
            'street': "שד' בן גוריון",
            'HouseNumbe': '0.0',
            'neighborho': "שכונה ג'",
            'Operator': 'כיוונים',
            'Seats': '0.0',
            'Activity': 'כן',
            'fencing': 'כן',
            'lighting': 'כן',
            'handicappe': '',
            'condition': '',
            'Owner': '',
            'ForSchool': '',
            'associatio': '',
            'SportType': '',
            'lat': '31.259607209000023',
            'lon': '34.81121359200006',
            'id': '165'
        }]
        facility = json_Action.Sports_facilities()
        filtered_facilities = facility.get_by_type_neighborho(
            'ג', "כל-המתקנים")
        self.assertEqual(
            json_Action.modular_filtering(filtered_facilities, "lighting",
                                          "כן"), facilities_result)
Exemple #14
0
 def test_update_user_by_ID(self):
     with self.assertRaisesRegex(Exception, "this username is taken"):
         DB_Action.update_user_by_ID("389", "userName", "admin89")
     with self.assertRaisesRegex(Exception, "this ID is taken"):
         DB_Action.update_user_by_ID("001", "id", "389")
Exemple #15
0
def delete_user(request, userID):
    DB_Action.removeUserByID(userID)
    allusers = DB_Action.getAllUsers()
    facilities = json_Action.Sports_facilities()
    context = {"object_List": allusers, "facilities": facilities.distros_dict}
    return render(request, "../templates/admin2.html", context)
Exemple #16
0
 def test_insert_to_DB(self):
     with self.assertRaisesRegex(
             Exception,
             "this username is taken"):  ##username already in the DB
         DB_Action.insert_user("user0", "1234", "admin89", "maymon", "1",
                               "*****@*****.**")
Exemple #17
0
def rateCoach(request, coachID, userName):
    coach = DB_Action.get_user_by_ID(coachID)
    coach["coachID"] = coach["_id"]
    context = {"coach": coach, "userName": userName}
    return render(request, "../templates/folder_trainee/rateCoach.html",
                  context)
Exemple #18
0
def backtoAdmin(request):
    allusers = DB_Action.getAllUsers()
    facilities = json_Action.Sports_facilities()
    context = {"object_List": allusers, "facilities": facilities.distros_dict}
    return render(request, "admin2.html", context)