def signIn(request): if request.method == 'POST' and 'btn1' in request.POST: email = request.POST.get('email') passw = request.POST.get('pass') global user try: user = auth.sign_in_with_email_and_password(email, passw) except: message = "Invalid Credentials" return render(request, "signIn.html", {"message": message}) user = auth.refresh(user['refreshToken']) global session_id global user_id session_id = user['idToken'] user_id = auth.get_account_info(user['idToken'])['users'][0]['localId'] request.session['uid'] = str(session_id) email_verify = auth.get_account_info( user['idToken'])['users'][0]['emailVerified'] ph_verify = database.child("users").child(user_id).child( "user_verify").get().val() if ph_verify == "No": return render(request, 'verification.html') if email_verify == False: return redirect(Email) return redirect(news) elif request.method == 'POST' and 'btn2' in request.POST: return render(request, 'signUp.html') return render(request, 'signIn.html')
def profile(request): if request.session['uid'] == str(session_id): idtoken = request.session['uid'] a = auth.get_account_info(idtoken) a = a['users'] a = a[0] a = a['localId'] e = database.child("users").child(a).child("email").get().val() n = database.child("users").child(a).child("name").get().val() g = database.child("users").child(a).child("gender").get().val() p = database.child("users").child(a).child("phone").get().val() c = database.child("users").child(a).child("college").get().val() r = database.child("users").child(a).child("rank").get().val() ac = database.child("users").child(a).child("accBal").get().val() city = database.child("users").child(a).child("city").get().val() return render(request, 'profile.html', { "e": e, "n": n, "g": g, "p": p, "c": c, "r": r, "ac": ac, "city": city }) return render(request, 'homepage.html')
def post_create(request): import time from datetime import datetime, timezone import pytz tz = pytz.timezone('Asia/Kolkata') time_now = datetime.now(timezone.utc).astimezone(tz) millis = int(time.mktime(time_now.timetuple())) print("mili" + str(millis)) work = request.POST.get('work') progress = request.POST.get('progress') url = request.POST.get('url') idtoken = request.session['uid'] a = auth.get_account_info(idtoken) a = a['users'] a = a[0] a = a['localId'] print("info" + str(a)) data = {"work": work, 'progress': progress, 'url': url} database.child('users').child(a).child('reports').child(millis).set(data) database.child('users').child(a).child('reports').child(millis).set(data) name = database.child('users').child(a).child('details').child( 'name').get().val() return render(request, 'welcome.html', {'e': name})
def post_check(request): import datetime time = request.GET.get('z') idtoken = request.session['uid'] a = auth.get_account_info(idtoken) a = a['users'] a = a[0] a = a['localId'] work = database.child('users').child(a).child('reports').child(time).child( 'work').get().val() progress = database.child('users').child(a).child('reports').child( time).child('progress').get().val() img_url = database.child('users').child(a).child('reports').child( time).child('url').get().val() print(img_url) i = float(time) dat = datetime.datetime.fromtimestamp(i).strftime('%H:%M %d-%m-%Y') name = database.child('users').child(a).child('details').child( 'name').get().val() return render(request, 'post_check.html', { 'w': work, 'p': progress, 'd': dat, 'e': name, 'i': img_url })
def fire(request): firebaseConfig = { "apiKey": "AIzaSyCU-h440DmkaDmqb0UEKCpZ8d1W4nzQAEU", "authDomain": "pythondbtest-27bd9.firebaseapp.com", "databaseURL": "https://pythondbtest-27bd9-default-rtdb.firebaseio.com", "projectId": "pythondbtest-27bd9", "storageBucket": "pythondbtest-27bd9.appspot.com", "messagingSenderId": "701887967894", "appId": "1:701887967894:web:32c2d6cac25ebbecef48b7", "measurementId": "G-NZJ4SRZ9BV" } firebase = pyrebase.initialize_app(firebaseConfig) auth = firebase.auth() print('login...') # email = input("PLease Enter the Your Email Address: \n") # password = getpass("please Your passowrd: \n") try: email = request.POST["textq"] password = request.POST["passa"] login = auth.sign_in_with_email_and_password(email, password) print("succesfully loggin") auth.get_account_info(login['idToken']) a = auth.current_user['localId'] user = authenticate(request, username=email, password=password) if user is not None: login(request, user) print("login") else: print("bye") # Return an 'invalid login' error message. context = { 'filenames': login, } return render(request, 'result.html') except: print("invalid email password") return render(request, 'firebase.html')
def full_price(request): idtoken = request.session['uid'] full_price = 'FULL PRICE' a = auth.get_account_info(idtoken) a = a['users'] a = a[0] a = a['localId'] print("info" + str(a)) data = {'FULL PRICE': a} database.child('users').child(a).child('Subscriptions').child( full_price).set(data) name = database.child('users').child(a).child('details').child( 'name').get().val() return render(request, 'fullprice_events.html', {'e': name})
def discounted(request): idtoken = request.session['uid'] discounted_sub = 'DISCOUNTED' a = auth.get_account_info(idtoken) a = a['users'] a = a[0] a = a['localId'] print("info" + str(a)) data = {'DISCOUNTED': a} database.child('users').child(a).child('Subscriptions').child( discounted_sub).set(data) name = database.child('users').child(a).child('details').child( 'name').get().val() return render(request, 'discounted_events.html', {'e': name})
def signIn(request): if request.method == 'POST': email = request.POST.get('email') passw = request.POST.get('pass') try: user = auth.sign_in_with_email_and_password(email, passw) except: message = "invalid credentials" return render(request, "signIn.html", {"message": message}) #print(user['idToken']) user = auth.refresh(user['refreshToken']) global session_id session_id = user['idToken'] print(auth.get_account_info(user['idToken'])) request.session['uid'] = str(session_id) return redirect('profile') return render(request, 'signIn.html')
def specific_event(request): import datetime time = request.GET.get('z') e_type = request.GET.get('e') idtoken = request.session['uid'] a = auth.get_account_info(idtoken) a = a['users'] a = a[0] a = a['localId'] event_name = database.child('events').child(e_type).child(time).child( 'event_name').get().val() description = database.child('events').child(e_type).child(time).child( 'description').get().val() event_type = database.child('events').child(e_type).child(time).child( 'event_type').get().val() date_time = database.child('events').child(e_type).child(time).child( 'date_time').get().val() event_tag = database.child('events').child(e_type).child(time).child( 'event_tag').get().val() location = database.child('events').child(e_type).child(time).child( 'location').get().val() img_url = database.child('events').child(e_type).child(time).child( 'url').get().val() i = str(time) name = database.child('users').child(a).child('details').child( 'name').get().val() return render( request, 'specific_event.html', { 'l': location, 'en': event_name, 'desc': description, 'et': event_type, 'dt': date_time, 'e_tag': event_tag, 'i': img_url })
def check(request): import datetime idtoken = request.session['uid'] a = auth.get_account_info(idtoken) a = a['users'] a = a[0] a = a['localId'] timestamps = database.child('users').child(a).child( 'reports').shallow().get().val() lis_time = [] for i in timestamps: lis_time.append(i) lis_time.sort(reverse=True) print(lis_time) work = [] for i in lis_time: wor = database.child('users').child(a).child('reports').child(i).child( 'work').get().val() work.append(wor) print(work) date = [] for i in lis_time: i = float(i) dat = datetime.datetime.fromtimestamp(i).strftime('%H:%M %d-%m-%Y') date.append(dat) print(date) comb_lis = zip(lis_time, date, work) name = database.child('users').child(a).child('details').child( 'name').get().val() return render(request, 'check.html', {'comb_lis': comb_lis, 'e': name})
def post_create(request): import time from datetime import datetime, timezone import pytz event_name = request.POST.get('event_name') location = request.POST.get('location') description = request.POST.get('description') event_type = request.POST.get('event_type') date_time = request.POST.get('date_time') event_tag = request.POST.get('event_tag') tz = pytz.timezone('America/Chicago') time_now = datetime.now(timezone.utc).astimezone(tz) millis = int(time.mktime(time_now.timetuple())) print("mili" + str(millis)) url = request.POST.get('url') idtoken = request.session['uid'] a = auth.get_account_info(idtoken) a = a['users'] a = a[0] a = a['localId'] print("info" + str(a)) data = { 'event_name': event_name, 'location': location, 'event_type': event_type, 'description': description, 'date_time': date_time, 'event_tag': event_tag, 'url': url, 'user': a, 'lat': '30.267153', 'long': '-97.743061' } database.child('events').child(event_type).child(millis).set(data) name = database.child('users').child(a).child('details').child( 'name').get().val() return render(request, 'events.html', {'e': name})
def fullprice_page(request): if request.method == 'GET' and 'csrfmiddlewaretoken' in request.GET: search = request.GET.get('search') search = search.lower() uid = request.GET.get('uid') print(search) print(uid) timestamps = database.child('events').child('full_price').get().val() et_id = [] for i in timestamps: e_tag = database.child('events').child('full_price').child( i).child('event_tag').shallow().get().val() et_split = e_tag.split(',') et_split = [x.strip(' ') for x in et_split] print(et_split) print(search) if search in et_split: et_id.append(i) print(et_id) location = [] for i in et_id: loc = database.child('events').child('full_price').child(i).child( 'location').get().val() location.append(loc) print(location) event_tag = [] for i in et_id: et = database.child('events').child('full_price').child(i).child( 'event_tag').get().val() event_tag.append(et) print(event_tag) event_type = [] for i in et_id: et = database.child('events').child('full_price').child(i).child( 'event_type').get().val() event_type.append(et) print(event_type) event_name = [] for i in et_id: en = database.child('events').child('full_price').child(i).child( 'event_name').get().val() event_name.append(en) print(event_name) date_time = [] for i in et_id: dt = database.child('events').child('full_price').child(i).child( 'date_time').get().val() date_time.append(dt) print(date_time) description = [] for i in et_id: desc = database.child('events').child('full_price').child(i).child( 'description').get().val() description.append(desc) print(description) url = [] for i in et_id: desc = database.child('events').child('full_price').child(i).child( 'url').get().val() url.append(desc) print(url) comb_lis = zip(et_id, event_name, date_time, event_type, location, description, event_tag, url) name = database.child('users').child(uid).child('details').child( 'name').get().val() return render(request, 'fullprice_events.html', { 'comb_lis': comb_lis, 'e': name }) else: idtoken = request.session['uid'] a = auth.get_account_info(idtoken) a = a['users'] a = a[0] a = a['localId'] timestamps = database.child('events').child( 'full_price').shallow().get().val() lis_time = [] for i in timestamps: lis_time.append(i) lis_time.sort(reverse=True) print(lis_time) location = [] for i in lis_time: loc = database.child('events').child('full_price').child(i).child( 'location').get().val() location.append(loc) print(location) event_type = [] for i in lis_time: et = database.child('events').child('full_price').child(i).child( 'event_type').get().val() event_type.append(et) print(event_type) event_name = [] for i in lis_time: en = database.child('events').child('full_price').child(i).child( 'event_name').get().val() event_name.append(en) print(event_name) date_time = [] for i in lis_time: dt = database.child('events').child('full_price').child(i).child( 'date_time').get().val() date_time.append(dt) print(date_time) event_tag = [] for i in lis_time: e_tag = database.child('events').child('full_price').child( i).child('event_tag').get().val() event_tag.append(e_tag) print(event_tag) description = [] for i in lis_time: desc = database.child('events').child('full_price').child(i).child( 'description').get().val() description.append(desc) print(description) url = [] for i in lis_time: desc = database.child('events').child('full_price').child(i).child( 'url').get().val() url.append(desc) print(url) comb_lis = zip(lis_time, event_name, date_time, event_type, location, description, event_tag, url) name = database.child('users').child(a).child('details').child( 'name').get().val() return render(request, 'fullprice_events.html', { 'comb_lis': comb_lis, 'e': name, 'uid': a })
def my_events(request): if request.method == 'GET' and 'csrfmiddlewaretoken' in request.GET: search = request.GET.get('search') search = search.lower() uid = request.GET.get('uid') idtoken = request.session['uid'] a = auth.get_account_info(idtoken) a = a['users'] a = a[0] a = a['localId'] print(search) print(idtoken) discounted_type = database.child('events').child( 'discounted').get().val() free_type = database.child('events').child('free').get().val() full_type = database.child('events').child('full_price').get().val() something = [] for i in discounted_type: something.append(i) print(something) for i in free_type: something.append(i) print(something) for i in full_type: something.append(i) print(something) my_split = [] for i in something: d_try = database.child('events').child('discounted').child( i).child('user').get().val() f_try = database.child('events').child('free').child(i).child( 'user').get().val() ft_try = database.child('events').child('full_price').child( i).child('user').get().val() if a == d_try: my_split.append(i) elif a == f_try: my_split.append(i) elif a == ft_try: my_split.append(i) else: pass print(my_split) my_list = [] for i in my_split: free_tag = database.child('events').child('free').child(i).child( 'event_tag').shallow().get().val() discounted_tag = database.child('events').child( 'discounted').child(i).child( 'event_tag').shallow().get().val() full_tag = database.child('events').child('full_price').child( i).child('event_tag').shallow().get().val() free_split = free_tag.split(',') discounted_split = discounted_tag.split(',') full_split = full_tag.split(',') free_split = [x.strip(' ') for x in free_split] discounted_split = [x.strip(' ') for x in discounted_split] full_split = [x.strip(' ') for x in full_split] print(free_split) print(discounted_split) print(full_split) print(search) if search in free_split: my_list.append(i) elif search in discounted_split: my_list.append(i) elif search in full_split.append(i): my_list.append(i) print(my_list) location = [] for i in my_list: loc = database.child('events').child('free').child(i).child( 'location').get().val() location.append(loc) loc_2 = database.child('events').child('discounted').child( i).child('location').get().val() location.append(loc_2) loc_3 = database.child('events').child('full_price').child( i).child('location').get().val() location.append(loc_3) location = [i for i in location if i is not None] print(location) event_type = [] for i in my_list: et = database.child('events').child('free').child(i).child( 'event_type').get().val() event_type.append(et) et_2 = database.child('events').child('discounted').child(i).child( 'event_type').get().val() event_type.append(et_2) et_3 = database.child('events').child('full_price').child(i).child( 'event_type').get().val() event_type.append(et_3) event_type = [i for i in event_type if i is not None] print(event_type) event_name = [] for i in my_list: en = database.child('events').child('free').child(i).child( 'event_name').get().val() event_name.append(en) en_2 = database.child('events').child('discounted').child(i).child( 'event_name').get().val() event_name.append(en_2) en_3 = database.child('events').child('full_price').child(i).child( 'event_name').get().val() event_name.append(en_3) event_name = [i for i in event_name if i is not None] print(event_name) date_time = [] for i in my_list: dt = database.child('events').child('free').child(i).child( 'date_time').get().val() date_time.append(dt) dt_2 = database.child('events').child('discounted').child(i).child( 'date_time').get().val() date_time.append(dt_2) dt_3 = database.child('events').child('full_price').child(i).child( 'date_time').get().val() date_time.append(dt_3) date_time = [i for i in date_time if i is not None] print(date_time) event_tag = [] for i in my_list: e_tag = database.child('events').child('free').child(i).child( 'event_tag').get().val() event_tag.append(e_tag) tag_2 = database.child('events').child('discounted').child( i).child('event_tag').get().val() event_tag.append(tag_2) tag_3 = database.child('events').child('full_price').child( i).child('event_tag').get().val() event_tag.append(tag_3) event_tag = [i for i in event_tag if i is not None] print(event_tag) description = [] for i in my_list: desc = database.child('events').child('free').child(i).child( 'description').get().val() description.append(desc) desc_2 = database.child('events').child('discounted').child( i).child('description').get().val() description.append(desc_2) desc_3 = database.child('events').child('full_price').child( i).child('description').get().val() description.append(desc_3) description = [i for i in description if i is not None] print(description) url = [] for i in my_list: urls = database.child('events').child('free').child(i).child( 'url').get().val() url.append(urls) urls_2 = database.child('events').child('discounted').child( i).child('url').get().val() url.append(urls_2) urls_3 = database.child('events').child('full_price').child( i).child('url').get().val() url.append(urls_3) url = [i for i in url if i is not None] print(url) comb_lis = zip(my_list, event_name, date_time, event_type, location, description, event_tag, url) name = database.child('users').child(a).child('details').child( 'name').get().val() return render(request, 'my_events.html', { 'comb_lis': comb_lis, 'e': name, 'uid': a }) else: idtoken = request.session['uid'] a = auth.get_account_info(idtoken) a = a['users'] a = a[0] a = a['localId'] discounted_type = database.child('events').child( 'discounted').get().val() free_type = database.child('events').child('free').get().val() full_type = database.child('events').child('full_price').get().val() something = [] for i in discounted_type: something.append(i) print(something) for i in free_type: something.append(i) print(something) for i in full_type: something.append(i) print(something) my_list = [] for i in something: d_try = database.child('events').child('discounted').child( i).child('user').get().val() f_try = database.child('events').child('free').child(i).child( 'user').get().val() ft_try = database.child('events').child('full_price').child( i).child('user').get().val() if a == d_try: my_list.append(i) elif a == f_try: my_list.append(i) elif a == ft_try: my_list.append(i) else: pass print(my_list) location = [] for i in my_list: loc = database.child('events').child('free').child(i).child( 'location').get().val() location.append(loc) loc_2 = database.child('events').child('discounted').child( i).child('location').get().val() location.append(loc_2) loc_3 = database.child('events').child('full_price').child( i).child('location').get().val() location.append(loc_3) location = [i for i in location if i is not None] print(location) event_type = [] for i in my_list: et = database.child('events').child('free').child(i).child( 'event_type').get().val() event_type.append(et) et_2 = database.child('events').child('discounted').child(i).child( 'event_type').get().val() event_type.append(et_2) et_3 = database.child('events').child('full_price').child(i).child( 'event_type').get().val() event_type.append(et_3) event_type = [i for i in event_type if i is not None] print(event_type) event_name = [] for i in my_list: en = database.child('events').child('free').child(i).child( 'event_name').get().val() event_name.append(en) en_2 = database.child('events').child('discounted').child(i).child( 'event_name').get().val() event_name.append(en_2) en_3 = database.child('events').child('full_price').child(i).child( 'event_name').get().val() event_name.append(en_3) event_name = [i for i in event_name if i is not None] print(event_name) date_time = [] for i in my_list: dt = database.child('events').child('free').child(i).child( 'date_time').get().val() date_time.append(dt) dt_2 = database.child('events').child('discounted').child(i).child( 'date_time').get().val() date_time.append(dt_2) dt_3 = database.child('events').child('full_price').child(i).child( 'date_time').get().val() date_time.append(dt_3) date_time = [i for i in date_time if i is not None] print(date_time) event_tag = [] for i in my_list: e_tag = database.child('events').child('free').child(i).child( 'event_tag').get().val() event_tag.append(e_tag) tag_2 = database.child('events').child('discounted').child( i).child('event_tag').get().val() event_tag.append(tag_2) tag_3 = database.child('events').child('full_price').child( i).child('event_tag').get().val() event_tag.append(tag_3) event_tag = [i for i in event_tag if i is not None] print(event_tag) description = [] for i in my_list: desc = database.child('events').child('free').child(i).child( 'description').get().val() description.append(desc) desc_2 = database.child('events').child('discounted').child( i).child('description').get().val() description.append(desc_2) desc_3 = database.child('events').child('full_price').child( i).child('description').get().val() description.append(desc_3) description = [i for i in description if i is not None] print(description) url = [] for i in my_list: urls = database.child('events').child('free').child(i).child( 'url').get().val() url.append(urls) urls_2 = database.child('events').child('discounted').child( i).child('url').get().val() url.append(urls_2) urls_3 = database.child('events').child('full_price').child( i).child('url').get().val() url.append(urls_3) url = [i for i in url if i is not None] print(url) comb_lis = zip(my_list, event_name, date_time, event_type, location, description, event_tag, url) name = database.child('users').child(a).child('details').child( 'name').get().val() return render(request, 'my_events.html', { 'comb_lis': comb_lis, 'e': name, 'uid': a })