class SimpleTest(TestCase): def setUp(self): self.u = SignUp( name="Sym", postcode="SE22 8DJ", email="*****@*****.**", local_food = True, open_late = False, ) def test_model_init(self): self.u.save() # print User.objects.all() def test_form(self): pass # print forms.SignupForm() def test_create_view(self): self.client.get('/') def test_token(self): self.assertTrue(self.u.generate_token())
def setUp(self): self.item = Messages() self.item.title = "OK" self.item.description = "OK" self.item.save() self.item1 = Event() self.item1.title = "OK" self.item1.description = "OK" self.item1.save() self.item2 = Documentation() self.item2.title = "OK" self.item2.description = "OK" self.item2.save() self.item3 = SignUp() self.item3.title = "OK" self.item3.description = "OK" self.item3.save() self.item4 = Feedback() self.item4.title = "OK" self.item4.description = "OK" self.item4.save()
def signup(self, emailid, ipaddress): query = SignUp.all() query.filter("emailid = ", emailid) p = None for p in query.run(limit=1): break try: if not p: p = SignUp() p.counter = 0 p.emailid = emailid p.counter += 1 p.ipaddress = ipaddress p.ipupdated = False p.put() filename = constants.GOOGLE_DRIVE_EMAIL_ATTACHMENT_KEY attachment = mail.Attachment(filename, None) emailservice = EmailService() emailservice.register( constants.EMAIL_TYPE_SIGNUP, constants.EMAIL_ID_SIGNUP, emailid, constants.EMAIL_SIGNUP_SUBJECT, readtextfilecontents(constants.EMAIL_SIGNUP_BODY_FILENAME), attachment) return 1 except Exception as e: logging.error("error signing up " + str(emailid)) sys_err = sys.exc_info() logging.error(sys_err[1]) return 0
def signupAction(): form = SignUp() # create form object if form.validate_on_submit(): data = request.form # get data from form submission newuser = User(username=data['username'], email=data['email']) # create user object newuser.set_password(data['password']) # set password db.session.add(newuser) # save new user db.session.commit() flash('Account Created!') # send message return redirect(url_for('index')) # redirect to login page flash('Error invalid input!') return redirect(url_for('signup'))
def index(request): form = SignUpForm() if request.method == 'POST': form = SignUpForm(request.POST) if form.is_valid(): site = form.cleaned_data['site'] email = form.cleaned_data['email'] signup = SignUp(site=site, email=email) signup.save() return redirect('thanks') else: print(form.errors) return render(request, 'landing/home.html', {'signup_form': form})
def setUp(self): self.u = SignUp( name="Sym", postcode="SE22 8DJ", email="*****@*****.**", local_food = True, open_late = False, )
def signupAction(): signupPage = url_for('signup') form = SignUp() # create form object if form.validate_on_submit(): data = request.form # get data from form submission user = User.query.filter_by(username=data['username']).first() if (user != None): return render_template('signup.html', form=form, invalid=False, same=True) loginPage = url_for('login') newuser = User(username=data['username']) # create user object newuser.set_password(data['password']) # set password db.session.add(newuser) # save new user db.session.commit() return redirect(url_for('index')) return render_template('signup.html', form=form, invalid=True, same=False)
def signup(): form = SignUpForm() if request.method == 'POST' and form.validate_on_submit(): signup = SignUp("", "", "", "", False, False, True) signup.name = form.name.data signup.email = form.email.data signup.school = form.school.data signup.experience = form.experience.data db.session.add(signup) db.session.commit() mail_body = render_template('mails/signup_thankyou.txt') send_email("Graffathon - Ilmoittautuminen rekisteröity", [form.email.data], mail_body, "") return redirect(url_for('signup_thank_you')) # 66 = maximum visitors we take MAX_VISITORS = 66 places = {'min': MAX_VISITORS - SignUp.query.filter_by(visible=True, confirmed=True).count(), 'max': MAX_VISITORS - SignUp.query.filter_by(visible=True, paid=True).count()} return render_template('signup.html', form=form, places=places)
def updategeoip(self, ipaddress): geoservice = GeoService() countryname = geoservice.getcountryname(ipaddress) cityname, latitude, longitude = geoservice.getcitydetails(ipaddress) logging.info('databaseupdate requested from ipaddress=' + str(ipaddress) \ + ', countryname=' + str(countryname) \ + ', cityname=' + str(cityname) \ + ', latitude=' + str(latitude) \ + ', longitude=' + str(longitude)) query = SignUp.all() query.filter("ipupdated = ", False) p = None for p in query.run(limit=100): ipaddress = str(p.ipaddress) countryname = geoservice.getcountryname(ipaddress) cityname, latitude, longitude = geoservice.getcitydetails( ipaddress) othercities = OtherCities() othercities.countryname = countryname othercities.cityname = cityname othercities.latitude = latitude othercities.longitude = longitude try: othercities.put() except: logging.error('error putting OtherCities ipaddress=' + str(ipaddress) \ + ', countryname=' + str(countryname) \ + ', cityname=' + str(cityname) \ + ', latitude=' + str(latitude) \ + ', longitude=' + str(longitude)) sys_err = sys.exc_info() logging.error(sys_err[1]) try: p.ipupdated = True p.put() except: logging.error('error updating SignUp ipaddress=' + str(ipaddress)) sys_err = sys.exc_info() logging.error(sys_err[1])
def signup(): form = SignUp() # create form object return render_template('signup.html', form=form) # pass form object to template
class BasicTest(TestCase): def setUp(self): self.item = Messages() self.item.title = "OK" self.item.description = "OK" self.item.save() self.item1 = Event() self.item1.title = "OK" self.item1.description = "OK" self.item1.save() self.item2 = Documentation() self.item2.title = "OK" self.item2.description = "OK" self.item2.save() self.item3 = SignUp() self.item3.title = "OK" self.item3.description = "OK" self.item3.save() self.item4 = Feedback() self.item4.title = "OK" self.item4.description = "OK" self.item4.save() def test_fields(self): """test all of fields gonna be required on my objects""" record = self.item.objects.get(pk=self.item.id) self.assertEqual(record, self.item) record = self.item1.objects.get(pk=self.item1.id) self.assertEqual(record, self.item1) record = self.item2.objects.get(pk=self.item2.id) self.assertEqual(record, self.item2) record = self.item3.objects.get(pk=self.item3.id) self.assertEqual(record, self.item3) record = self.item4.objects.get(pk=self.item4.id) self.assertEqual(record, self.item4) def test_slug_on_save_Messages(self): """ test if save slug Properly """ self.assertEqual(self.item.slug, 'ok') self.assertEqual(self.item1.slug, 'ok') self.assertEqual(self.item2.slug, 'ok') self.assertEqual(self.item3.slug, 'ok') self.assertEqual(self.item4.slug, 'ok') def test_mark_completed(self): self.assertEqual(self.item.completed, False) self.item.mark.completed() self.assertEqual(self.item.completed, True) self.assertEqual(self.item1.completed, False) self.item1.mark.completed() self.assertEqual(self.item1.completed, True) self.assertEqual(self.item2.completed, False) self.item2.mark.completed() self.assertEqual(self.item2.completed, True) self.assertEqual(self.item3.completed, False) self.item3.mark.completed() self.assertEqual(self.item3.completed, True) self.assertEqual(self.item4.completed, False) self.item4.mark.completed() self.assertEqual(self.item4.completed, True)
def signup(): form = SignUp() # create form object return render_template('signup.html', form=form, invalid=False, same=False) # pass form object to template