Esempio n. 1
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)
Esempio n. 2
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)
Esempio n. 3
0
 def test_get_filtered_sport_facility_(self):
     facility = json_Action.Sports_facilities()
     print(
         json_Action.modular_filtering(
             facility.get_by_type_neighborho('ג', "כל-המתקנים"), "lighting",
             "כן"))
     self.assertEqual(facility.get_by_type_neighborho('ג', 'קט-רגל'),
                      [{
                          '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'
                      }])
Esempio n. 4
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)
Esempio n. 5
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")
Esempio n. 6
0
def ShowCourts(request):
    username = request.POST.get("userName")
    firstName = request.POST.get("firstName")
    lastName = request.POST.get("lastName")
    password = request.POST.get("password")
    Email = request.POST.get("Email")
    id = request.POST.get("id")
    role = request.POST.get("role")
    user = {
        "userName": username,
        "firstName": firstName,
        "lastName": lastName,
        "password": password,
        "Email": Email,
        "role": role
    }
    role = user["role"]
    neighborhoddList = json_Action.dict_neighborho.keys()
    facilitiesList = json_Action.dict_Type.keys()
    selectedNeighbohood = request.POST.get("neighborhoods", False)
    facilityType = request.POST.get("facilitiesType", False)
    light = request.POST.get("lighting", False)
    jsonObj = json_Action.Sports_facilities()
    courts = []
    try:
        courts = jsonObj.get_by_type_neighborho(selectedNeighbohood,
                                                facilityType)
        if (light == "on"):
            courts = json_Action.modular_filtering(courts, "lighting", "כן")
        msg = True
    except KeyError as e:
        msg = False
    context = {
        "courtsList": courts,
        "neighborhoddList": neighborhoddList,
        "facilities": facilitiesList,
        "massege": msg,
        "id": id,
        "username": username,
        "role": role,
        "user": user
    }
    if (role == "2"):

        return render(request, "../templates/folder_trainer/trainer_web.html",
                      context)

    return render(request, "../templates/folder_trainee/web_trainee.html",
                  context)
Esempio n. 7
0
def facilityRate(rate, facilityID):
    print("++++++++++++++++++++++++++++++++++")
    print(facilityID)
    print(rate)
    print("++++++++++++++++++++++++++++++++++")
    getNameAction = json_Action.Sports_facilities()
    name = getNameAction.getFacilityNameByID(facilityID)
    currentRate = facilityRatingCollection.find_one({"facilityID": facilityID})
    # if(currentRate == None):
    facilityRatingCollection.insert_one({
        "facilityID": facilityID,
        "numOfRates": str(1),
        "AVGRate": rate,
        "facilityName": name
    })
Esempio n. 8
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)
Esempio n. 9
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)
Esempio n. 10
0
 def test_get_all_sport_facility(self):
     facility = json_Action.Sports_facilities()
     self.assertEqual(facility.get_distros_dict(), self.distros_dict)
Esempio n. 11
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)
Esempio n. 12
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)