def serialize(self): if self.date_approved: date = unix_time(self.date_approved) else: date = '' return { 'id': self.id, 'requester_id': self.requester_id, 'requester_name': User.query.filter_by(id=self.requester_id) .first().name, 'amount': int(self.amount * 100), 'comment': self.comment, 'type': self.type, 'date_requested': unix_time(self.date_requested), 'date_approved': date, 'status': self.status }
def __init__(self, json, user_id): self.date = unix_time() self.title = json['title'] self.content = sanitize(json['content']) self.sticky = False self.user_id = user_id self.tags = [get_or_create(tag['name'], Tag, name=tag['name']) for tag in json['tags']] self.images = [get_or_create(link, ImageLink, link=link) for link in json['images']]
def serialize(self): return { 'voting_started': self.voting_started, 'lounge_open': self.lounge_open, 'run_console_visible': self.run_console_visible, 'lounge_password': '', 'officers_password': '', 'voting_end_date': unix_time(self.voting_end_date), 'landing_image': ImageLink.query.get( self.landing_image_id).serialize, 'officers_image': ImageLink.query.get( self.officers_image_id).serialize }