def login(request): form = NewUserForm() if request.method == "POST": form = NewUserForm(request.POST) if form.is_valid(): user = form.cleaned_data['user'] password = form.cleaned_data['password'] con = 1 dataRes_1 = [] dataRes_2 = [] dataRes_3 = [] dataRes_4 = [] dataRes_5 = [] dataRes_6 = [] dataRes = {'user': user, 'password': password,'dataRes_uno':dataRes_1,'dataRes_dos':dataRes_2,'dataRes_tres':dataRes_3,'dataRes_cuatro':dataRes_4,'dataRes_cinco':dataRes_5,'dataRes_seis':dataRes_6} if userValid(user,password): return render(request,'basicapp/workPage.html',context=dataRes) else: data = {'user': '******', 'password': '******'} form = NewUserForm(data) form.is_valid() return render(request,'basicapp/pageError.html') return render(request,'basicapp/login.html',{'form':form})
def form_page(request): # form = forms.FormName() # # if request.method == 'POST': # form = forms.FormName(request.POST) # # if form.is_valid(): # print('VALIDATION SUCCESS!') # print("Name: " + form.cleaned_data['name']) # print("Email: " + form.cleaned_data['email']) # print("Text: " + form.cleaned_data['text']) # # return render(request, 'first_app/form_page.html',{'form':form}) form = NewUserForm() if request.method == "POST": form = NewUserForm(request.POST) if form.is_valid(): form.save(commit=True) return index(request) else: print('ERROR FORM INVALID') return render(request, 'first_app/form_page.html', {'form': form})
def form(request): registered = False if request.method == "POST": user_form = NewUserForm(request.POST) extra_form = ExtendedUserForm(request.POST) if user_form.is_valid() and extra_form.is_valid(): # add the new user to the list user = user_form.save() user.set_password(user.password) user.save() ext_user = extra_form.save(commit=False) ext_user.user = user if 'profile_pic' in request.FILES: ext_user.profile_pic = request.FILES['profile_pic'] ext_user.save() registered = True context = { "user_form": NewUserForm(), "extra_form": ExtendedUserForm(), "registered": registered } return render(request, "first_app/form_page.html", context=context)
def index(request): acc_list = info_table.objects.order_by('rollno') form = NewUserForm() if request.method == 'POST': form = NewUserForm(request.POST) if form.is_valid(): form.save() my_dir = {'info_table': acc_list, 'form': form} return render(request, 'first_app/index.html', context=my_dir)
def myform(request): form = NewUserForm() if request.method == 'POST': form = NewUserForm(request.POST) if form.is_valid(): form.save() return index(request) return render(request, 'first_app/forms.html', context={'form': form})
def new_user(request): form = NewUserForm() if request.method == 'POST': form = NewUserForm(request.POST) if form.is_valid(): form.save(commit=True) return users(request) else: print('ERROR form invalid') return render(request, 'first_app/new_user.html', {'form': form})
def index(request): form = NewUserForm if request.method == "POST": form = NewUserForm(request.POST) if form.is_valid(): form.save(commit=True) else: print("form invalid") return user(request) return render(request, 'first_app/indexog.html', {'form': form})
def newUser(req): form = NewUserForm() if (req.method == 'POST'): form = NewUserForm(req.POST) if form.is_valid(): form.save(commit=True) return index(req) else: print('Error form invalid') return render(req, 'app/signUp.html', {'form': form})
def users(request): form = NewUserForm() if request.method == "POST": form = NewUserForm(request.POST) if form.is_valid(): form.save(commit = True) return index(request) else: print("Error") return render(request, 'first_app/users.html', {'form' : form})
def addUser(request): form = NewUserForm() #print("form="+form) if request.method == "POST": form= NewUserForm(request.POST) if form.is_valid(): form.save(commit=True) return index(request) else: print("ERROR FORM INVALID") return render(request,'first_app/user.html',{'form':form})
def users(request): userform = NewUserForm() if request.method == "POST": userform = NewUserForm(request.POST) if userform.is_valid(): userform.save(commit=True) return index(request) else: print("ERROR FORM INVALID!") return render(request, 'users.html', {'form': userform})
def userregister(request): form = NewUserForm() if request.method == 'POST': form = NewUserForm(request.POST) if form.is_valid(): form.save(commit=True) return index(request) else: print('ERROR! FORM IS NOT VALID') return render(request, 'first_app/userregister.html', context={'form': form})
def logup(request): form = NewUserForm() if request.method == "POST": form = NewUserForm(request.POST) if form.is_valid(): form.save(commit=True) return render(request, 'basicapp/successPage.html') else: print('ERROR FORM INVALID') return render(request, 'basicapp/logup.html', {'form': form})
def users_sign_up(request): form = NewUserForm() if request.method == "POST": form = NewUserForm(request.POST) if form.is_valid(): form.save(commit=True) return index_users(request) else: print("ERROR form invalid") return render(request, 'login/users.html', {'form': form})
def signup(request): form = NewUserForm() if request.method == 'POST': form = NewUserForm(request.POST) if form.is_valid(): form.save(commit=True) return index(request) else: print('Error From Invalid') form_content = {'form': form} return render(request, 'first_app/signup.html', context=form_content)
def register(request): form = NewUserForm() if request.method == "POST": form = NewUserForm(request.POST) if form.is_valid(): form.save(commit=True) return users(request) else: print("ERROR! FORM INVALID!") return render(request, 'first_app/register.html', {'form': form})
def users(request): user_list = User.objects.order_by('first_name') user_dict = {"users_records":user_list} form = NewUserForm() if request.method == "POST": form = NewUserForm(request.POST) if form.is_valid(): form.save(commit=True) return index(request) else: print('ERROR FORM INVALID') return render(request,'first_app/users.html',{'form':form, "users_records":user_list})
def signup_form(request) : form=NewUserForm() if request.method=="POST" : form=NewUserForm(request.POST) if form.is_valid() : form.save(commit=True) return index(request) else : print('Error from invalid') return render(request,'first_app/form_page.html',context={'form':form})
def users(request): form = NewUserForm() if request.method == 'POST': form = NewUserForm(request.POST) # check validation of if form.is_valid(): form.save(commit=True) # save to database return index(request) else: print('error form invalid') # if form post is incorrect return render(request, 'first_app/users.html', {'form': form})
def users(request): form = NewUserForm() if request.method == "POST": form = NewUserForm(request.POST) #save it to the database commit=True persist it Also can do custom validation here if form.is_valid(): form.save(commit=True) #return to homepage return index(request) #can raise an error else: print('Error Form invalid') return render(request, 'first_app/users.html', {'form': form})
def users(request): form = NewUserForm() if request.method == "POST": form = NewUserForm(request.POST) if form.is_valid(): form.save(commit=True) return index(request) else: print("ERROR FORM INVALID") return render(request, "first_app/form_page.html", {"form": form})
def signup(request): newform = NewUserForm() if request.method == "POST": form = NewUserForm(request.POST) if form.is_valid(): form.save(commit=True) return users(request) else: print("ERROR FROM INVALID") return render(request, 'first_app/signup.html', {'form': newform})
def users(request): form = forms.NewUserForm() if request.method == "POST": return index(request) form = NewUserForm(request.POST) if form.is_valid(): form.save(commit=True) return index(request) else: print('ERROR FORM INvALID') return render(request, 'first_app/sign_up.html', {'form': form})
def users(request): form = NewUserForm() if request.method == 'POST': form = NewUserForm(request.POST) # to commit to database if form.is_valid(): form.save(commit=True) return index(request) else: print('ERROR FROM INVALID FORM') return render(request, 'first_app/users.html', {'signup_form': form}) user_list = User.objects.order_by('first_name') user_dict = {'users': user_list} return render(request, 'first_app/users.html', context=user_dict)
def login(request): form = NewUserForm() if request.method == "POST": form = NewUserForm(request.POST) if form.is_valid(): user = form.cleaned_data['user'] password = form.cleaned_data['password'] #rs() predictions = Prediction.objects.filter(user_id=password, mark='True')[:10] con = 1 dataRes_1 = [] dataRes_2 = [] dataRes_3 = [] dataRes_4 = [] dataRes_5 = [] dataRes_6 = [] if (not predictions): busines_ = business.objects.filter()[:10] for busines in busines_: if (con <= 3): try: dataRes_1.append(busines.name) con = con + 1 except: print('error') else: if (con <= 6): try: dataRes_2.append(busines.name) con = con + 1 except: print('error') else: if (con <= 9): try: dataRes_3.append(busines.name) con = con + 1 except: print('error') else: break else: for prediction in predictions: busines = business.objects.filter( business_id=prediction.business_id).first() if (con <= 3): try: dataRes_1.append(busines.name) con = con + 1 except: print('error') else: if (con <= 6): try: dataRes_2.append(busines.name) con = con + 1 except: print('error') else: if (con <= 9): try: dataRes_3.append(busines.name) con = con + 1 except: print('error') else: break prediction_1 = modelItemitem(password) conM2 = 1 for prediction in prediction_1: busines = business.objects.filter( business_id=prediction.business_id).first() if (conM2 <= 3): try: dataRes_4.append(busines.name) conM2 = conM2 + 1 except: print('error') else: if (conM2 <= 6): try: dataRes_5.append(busines.name) conM2 = conM2 + 1 except: print('error') else: if (conM2 <= 9): try: dataRes_6.append(busines.name) conM2 = conM2 + 1 except: print('error') else: break dataRes = { 'user': user, 'password': password, 'dataRes_uno': dataRes_1, 'dataRes_dos': dataRes_2, 'dataRes_tres': dataRes_3, 'dataRes_cuatro': dataRes_4, 'dataRes_cinco': dataRes_5, 'dataRes_seis': dataRes_6 } if userValid(user, password): return render(request, 'basicapp/workPage.html', context=dataRes) else: data = {'user': '******', 'password': '******'} form = NewUserForm(data) form.is_valid() return render(request, 'basicapp/pageError.html') return render(request, 'basicapp/login.html', {'form': form})
def login(request): form = NewUserForm() from_2 = FormSearch() if request.method == "POST": form = NewUserForm(request.POST) if form.is_valid(): user = form.cleaned_data['name'] password = form.cleaned_data['password'] predictions_0 = Prediction.objects.filter(prediction='0')[:3] predictions_1 = Prediction.objects.filter(prediction='1')[:3] predictions_2 = Prediction.objects.filter(prediction='2')[:3] temp = [] dataRes_1 = [] dataRes_2 = [] dataRes_3 = [] for prediction in predictions_0: try: temp.append("Nombre Doctor: " + prediction.user_id) temp.append("ID Paciente: " + prediction.patinte_id) temp.append("Edad Paciente: " + prediction.patiente_age) temp.append("Fecha Análisis: " + prediction.analysis_date) temp.append("EEG: " + prediction.eeg) dataRes_1.append(temp.copy()) temp.clear() except: print('error') for prediction in predictions_1: try: temp.append("Nombre Doctor: " + prediction.user_id) temp.append("ID Paciente: " + prediction.patinte_id) temp.append("Edad Paciente: " + prediction.patiente_age) temp.append("Fecha Análisis: " + prediction.analysis_date) temp.append("EGG: " + prediction.eeg) dataRes_2.append(temp.copy()) temp.clear() except: print('error') for prediction in predictions_2: try: temp.append("Nombre Doctor: " + prediction.user_id) temp.append("ID Paciente: " + prediction.patinte_id) temp.append("Edad Paciente: " + prediction.patiente_age) temp.append("Fecha Análisis: " + prediction.analysis_date) temp.append("EGG: " + prediction.eeg) dataRes_3.append(temp.copy()) temp.clear() except: print('error') dataRes = { 'form': from_2, 'user': user, 'password': password, 'dataRes_uno': dataRes_1, 'dataRes_dos': dataRes_2, 'dataRes_tres': dataRes_3 } if userValid(user, password): return render(request, 'basicapp/workPage.html', context=dataRes) else: data = {'user': '******', 'password': '******'} form = NewUserForm(data) return render(request, 'basicapp/pageError.html') return render(request, 'basicapp/login.html', {'form': form})
def login(request): form = NewUserForm() if request.method == "POST": form = NewUserForm(request.POST) if form.is_valid(): user = form.cleaned_data['user'] password = form.cleaned_data['password'] predictions = PREDICTION_CHART.objects.filter( userId=user, prediction__isnull=False).order_by('prediction') if len(predictions) == 0: predictions = PREDICTION_CHART.objects.filter( userId='user_000052', prediction__isnull=False) con = 1 dataRes_1 = [] dataRes_2 = [] dataRes_3 = [] print(predictions) for prediction in reversed(predictions): if (con <= 3): artistName = Registry.objects.filter( musicbrainzArtistId=prediction.artistId).first() dataRes_1.append(artistName.artistName) con = con + 1 else: if (con <= 6): artistName = Registry.objects.filter( musicbrainzArtistId=prediction.artistId).first() dataRes_2.append(artistName.artistName) con = con + 1 else: if (con <= 9): artistName = Registry.objects.filter( musicbrainzArtistId=prediction.artistId).first( ) dataRes_3.append(artistName.artistName) con = con + 1 else: break dataRes = { 'user': user, 'password': password, 'dataRes_uno': dataRes_1, 'dataRes_dos': dataRes_2, 'dataRes_tres': dataRes_3, } if userValid(user, password): return render(request, 'basicapp/workPage.html', context=dataRes) else: data = {'user': '******', 'password': '******'} form = NewUserForm(data) form.is_valid() return render(request, 'basicapp/pageError.html') return render(request, 'basicapp/login.html', {'form': form})