def createEvent(name,begin,end,location,description,leader,img): size=6 chars=string.ascii_uppercase + string.digits unHashed = ''.join(random.choice(chars) for _ in range(size)) qr_code = pbkdf2_sha256.hash(unHashed) if(name == '' or begin == '' or end == '' or location == '' or description == '' or leader== '' or img==''): return 400 event = Event( name=name, begin=begin, end=end, location=location, desc=description, leader=leader, cancel=0, img=img, qr_code=qr_code, created= datetime.datetime.now(), link= None ) return Persister.persist_object(event)
def createNewsItemApp(title, content, img): if (title == '' or content == '' or img == ''): return 400 item = Content(url=img, title=title, desc=content, link=None, created=datetime.datetime.now()) return Persister.persist_object(item)
def registerFacebookUser(form): person = Person(firstname=form.get('firstName'), lastname=form.get('lastName'), email=form.get('email'), password='', points=0, clearance=0, license=True, authenticated=False) return Persister.persist_object(person)
def subToEvent(eventId, personId): if not Persister.checkParticepant(eventId, personId): particepant = Particepant( person_id=personId, event_id=eventId, event_scanned=0 ) if Persister.persist_object(particepant) == 200: return ({"responseCode": 200, "msg": "Added particepant entry."}) else: return ({"responseCode": 400, "msg": "Could not add entry due to db error."}) return ({"responseCode": 400, "msg": "Could not add participant entry because either some of the given data did not match or the entry already exists."})
def registerSubmit(form, clearance): firstName = form.get('firstName', None) lastName = form.get('lastName', None) email = form.get('email', None) password = form.get('password', None) wordpresskey = form.get('wordpresskey', None) firstName = firstName.strip() lastName = lastName.strip() firstName = firstName.lower() lastName = lastName.lower() email = email.lower() password = password.lower() if checks.checkSpecialChars([firstName, lastName]): msg = "Gebruik alstublieft geen speciale karakters in uw naam!" return {"code": 400, "message": msg} if checks.checkSpecialCharsEmail(email): msg = "Gebruik alstublieft geen speciale karakters in uw email!" return {"code": 400, "message": msg} if checks.emptyCheck([firstName, lastName, email, password]): msg = "Vul alstublieft alle velden in." return {"code": 400, "message": msg} if checks.lengthSixtyFourCheck([firstName, lastName, email]): msg = "Vul alsublieft niet meer dan 64 karakters in." return {"code": 400, "message": msg} password = form.get('password', None) check = checks.passwordLengthCheck(password) if check == [False, "short"]: msg = "Uw wachtwoord moet langer dan 5 karakters zijn." return {"code": 400, "message": msg} if check == [False, "long"]: msg = "Uw wachtwoord moet korter zijn dan 64 karakters." return {"code": 400, "message": msg} if Persister.checkEmailExistance(email): msg = "Dit emailadres bestaat al." return {"code": 400, "message": msg} if (clearance == 0): person = Person(firstname=firstName, lastname=lastName, email=email, password=password, points=0, clearance=0, license=True, authenticated=False) return Persister.persist_object(person) elif (clearance == 1): person = Person(firstname=firstName, lastname=lastName, email=email, password=password, points=0, clearance=1, wordpressKey=wordpresskey, license=True, authenticated=False, biography=form.get('biography'), profilePhoto=form.get('img')) return Persister.persist_object(person) else: return None