示例#1
0
def editprofile(request):
    c = checkpermission(request, request.path)
    if (c == -1):
        return redirect('/')
    elif (c == 0):
        return redirect('/home')
    idd = request.session['user']
    marketerdata = database.child('marketers').child(idd).child(
        'details').get()
    from datetime import date
    data = database.child('mIds').child(
        marketerdata.val()["phone"]).child('createdOn').get().val() / 100
    date = date.fromtimestamp(data)
    l = {
        'id': idd,
        'name': marketerdata.val()["name"],
        'age': marketerdata.val()["age"],
        'city': marketerdata.val()["city"],
        'email': marketerdata.val()["email"],
        'experience': marketerdata.val()["experience"],
        'gen': marketerdata.val()["gen"],
        'phone': marketerdata.val()["phone"],
        'state': marketerdata.val()["state"],
        'createdOn': date
    }
    if (request.method == "POST"):
        currentpassword = request.POST.get("currentpassword")
        newpassword = request.POST.get("newpassword")
        confirmpassword = request.POST.get("confirmpassword")
        print('rahul')
        print(request.FILES)
        if (request.FILES):
            print('rahul')
            storage.child('/marketers/' + idd).put(request.FILES["images"])
            request.session['image'] = getimage(idd)
        if (currentpassword == "" and newpassword == ""
                and confirmpassword == ""):
            return redirect('/home')
        else:
            if (newpassword != confirmpassword or len(newpassword) < 6):
                return render(request, './marketer/editProfile.html', {
                    'data': l,
                    'error': "Check Your Password"
                })
            else:
                current = database.child('mIds').child(
                    marketerdata.val()["phone"]).child('pass').get().val()
                if (getpass(currentpassword)[2:-1] != current):
                    return render(request, './marketer/editProfile.html', {
                        'data': l,
                        'error': "Check Your Current Password"
                    })
                else:
                    database.child('mIds').child(
                        marketerdata.val()["phone"]).update(
                            {'pass': getpass(newpassword)[2:-1]})
                    return redirect('/home')
    else:
        return render(request, './marketer/editProfile.html', {'data': l})
示例#2
0
def addImage(request):
    if request.method == 'POST':
        if (request.FILES):
            free = database.child('imgFree').child(
                'free').shallow().get().val()
            if not free:
                free = 10000000000
            storage.child('/questions/' + str(free)).put(
                request.FILES["images"])
            url = storage.child('/questions/' + str(free)).get_url(1)
            database.child('imgFree').update({'free': free + 1})
            return render(request, 'addQues.html', {'url': url})
        return render(request, 'addQues.html')
示例#3
0
def editProfile(request):
    c = checkpermission(request, request.path)
    if(c == -1):
        return redirect('/')
    elif(c == 0):
        return redirect('/home')
    iduser = request.session['user']
    i = database.child('teachers').child(iduser).child('details').get()
    from datetime import date
    data = database.child('tIds').child(
        i.val()["phone"]).child('createdOn').get().val()/1000
    date = date.fromtimestamp(data)
    
    l = {
        'id': iduser,
        'name': i.val()["name"],
        'age': i.val()["age"],
        'city': i.val()["city"],
        'email': i.val()["email"],
        'experience': i.val()["experience"],
        'gen': i.val()["gen"],
        'phone': i.val()["phone"],
        'state': i.val()["state"],
        'createdOn': date
    }
    if 'reviewLine' in i.val():
        l['reviewL']=i.val()['reviewLine']
    if 'testMsg' in i.val():
        l['testL']=i.val()['testMsg']
    if(request.method == "POST"):
        currentpassword = request.POST.get("currentpassword")
        newpassword = request.POST.get("newpassword")
        confirmpassword = request.POST.get("confirmpassword")
        reviewL = request.POST.get('reviewL')
        testL = request.POST.get('testL')
        if(request.FILES):
            
            storage.child('/teachers/'+iduser).put(request.FILES["images"])
            request.session['image']=getimage(iduser)
        if reviewL:
            database.child('teachers').child(iduser).child('details').update({'reviewLine':reviewL})
        if testL:
            database.child('teachers').child(iduser).child('details').update({'testMsg':testL})

        if (currentpassword != "" or newpassword != "" or confirmpassword != ""):
            if(newpassword != confirmpassword or len(newpassword) < 6):
                return render(request, './teacher/editProfile.html', {'data': l, 'error': "Check Your Password"})
            else:
                current = database.child('tIds').child(
                    i.val()["phone"]).child('pass').get().val()
                if(getpass(currentpassword)[2:-1] != current):
                    return render(request, './teacher/editProfile.html', {'data': l, 'error': "Check Your Current Password"})
                else:
                    database.child('tIds').child(i.val()["phone"]).update(
                        {'pass': getpass(newpassword)[2:-1]})
                    return render(request, './teacher/editProfile.html', {'data': l})
        
        return render(request, './teacher/editProfile.html', {'data': l})
    else:

        return render(request, './teacher/editProfile.html', {'data': l})
示例#4
0
def addBanner(request):
    c = checkpermission(request, request.path)
    if (c == -1):
        return redirect('/')
    elif (c == 0):
        return redirect('/home')
    try:
        url1 = storage.child('banners').child("1").get_url(1)
        url2 = storage.child('banners').child("2").get_url(1)
        url3 = storage.child('banners').child("3").get_url(1)
        url4 = storage.child('banners').child("4").get_url(1)
        url5 = storage.child('banners').child("5").get_url(1)
    except:
        url = "https://firebasestorage.googleapis.com/v0/b/the-proficiency.appspot.com/o/logo%2FProfile%20Pic.png?alt=media&token=f5efb3c0-394e-4c28-9442-d061e1204e9b"
        url1 = url
        url2 = url
        url3 = url
        url4 = url
        url5 = url
    if request.method == "POST":
        if (len(request.FILES) == 5):
            storage.child('banners').child("1").put(request.FILES["img1"])
            storage.child('banners').child("2").put(request.FILES["img2"])
            storage.child('banners').child("3").put(request.FILES["img3"])
            storage.child('banners').child("4").put(request.FILES["img4"])
            storage.child('banners').child("5").put(request.FILES["img5"])
        else:
            error = "Please select all the files."
            return render(
                request, './banners/addBanner.html', {
                    'img1': url1,
                    'img2': url2,
                    'img3': url3,
                    'img4': url4,
                    'img5': url5,
                    'error': error
                })

    return render(request, './banners/addBanner.html', {
        'img1': url1,
        'img2': url2,
        'img3': url3,
        'img4': url4,
        'img5': url5
    })