def searchEvent(searchString): found = Persister.searchEvent(searchString) result = [] for eventName in found: event = found[eventName] leader = Persister.getLeader(event['leader']) photo = Persister.getProfilePhoto(event['leader']) bio = Persister.getDescription(event['leader']) createDate = event['created'] created = createDate.strftime('%m/%d/%Y') begin = event['begin'] beginDay = begin.strftime('%d') beginMonth = begin.strftime('%b') beginTime = begin.strftime('%H:%M') leaderId = event['leader'] end = event['end'] endDay = end.strftime('%d') endMonth = end.strftime('%b') endTime = end.strftime('%H:%M') participantList = [] participants = Persister.getAllParticepants(event['id']) if participants != 400: for participant in participants: person = Persister.getPerson(participant.person_id) name = person.firstname + " " + person.lastname participantInfo = { "id": person.id, "name": name, "points": person.points } participantList.append(participantInfo) result.append({ "id": event['id'], "name": event['name'], "begin": beginDay, "beginMonth": months[beginMonth], "beginTime": beginTime, "beginFull": begin, "end": endDay, "endMonth": months[endMonth], "endTime": endTime, "endFull": end, "location": event['location'], "desc": event['desc'], "leader": leader, "cancel": event['cancel'], "img": event['img'], "qrCode": event['qr_code'], "created": created, "leaderDesc": bio, "leaderId": leaderId, "link": event['link'], "photo": photo, "subscribed": None, "participants": participantList }) return result
def getAllEvents(): events = Persister.getAllEvents() result = [] if events != 400: for event in events: leader = Persister.getLeader(event.leader) if (leader == None): leader = "" photo = Persister.getProfilePhoto(event.leader) bio = Persister.getDescription(event.leader) createDate = event.created created = createDate.strftime('%m/%d/%Y') begin = event.begin beginDay = begin.strftime('%d') beginMonth = begin.strftime('%b') beginTime = begin.strftime('%H:%M') end = event.end endDay = end.strftime('%d') endMonth = end.strftime('%b') endTime = end.strftime('%H:%M') participantList = [] participants = Persister.getAllParticepants(event.id) if participants != 400: for participant in participants: person = Persister.getPerson(participant.person_id) name = person.firstname + " " + person.lastname participantInfo = { "id": person.id, "name": name, "points": person.points } participantList.append(participantInfo) result.append({ "id": event.id, "name": event.name, "begin": beginDay, "beginMonth": months[beginMonth], "beginTime": beginTime, "end": endDay, "endMonth": months[endMonth], "endTime": endTime, "location": event.location, "desc": event.desc, "leader": leader, "cancel": event.cancel, "img": event.img, "qrCode": event.qr_code, "created": created, "leaderDesc": bio, "link": event.link, "photo": photo, "subscribed": None, "participants": participantList }) return result
def getAllEvents(): events = Persister.getAllEvents() if events != 400: result = [] for event in events: leader = Persister.getLeader(event.leader) photo = Persister.getProfilePhoto(event.leader) createDate = event.created created = createDate.strftime('%m/%d/%Y') begin = event.begin beginDay = begin.strftime('%d') beginMonth = begin.strftime('%b') result.append({"id": event.id, "name": event.name, "begin": beginDay,"beginMonth": beginMonth,"end": event.end, "location": event.location, "desc": event.desc, "leader": leader, "cancel": event.cancel, "img": event.img,"qrCode": event.qr_code, "created": created,"link":event.link,"photo":photo }) return result
def searchEvent(searchString): found = Persister.searchEvent(searchString) result = [] for eventName in found: event = found[eventName] leader = Persister.getLeader(event['leader']) photo = Persister.getProfilePhoto(event['leader']) createDate = event['created'] created = createDate.strftime('%m/%d/%Y') begin = event['begin'] beginDay = begin.strftime('%d') beginMonth = begin.strftime('%b') result.append({"id": event['id'], "name": event['name'], "begin": beginDay,"beginMonth": beginMonth,"end": event['end'], "location": event['location'], "desc": event['desc'], "leader": leader, "cancel": event['cancel'], "img": event['img'],"qrCode": event['qr_code'], "created": created,"link":event['link'],"photo":photo }); return result
def getProfilePhoto(id): return Persister.getProfilePhoto(id)