def as_dict(self): dic = dict(self.to_mongo()) dic['comments'] = self.comments dic['created_at'] = format_datetime(self.created_at, '%b %d, %Y') u = User.objects(id=self.author_id).first() dic['author_name'] = u.nickname if u else '-' return dic
def as_dict(self): return { 'id': self.id, 'name': self.name, 'desc': self.desc, 'creator_id': self.creator_id, 'creator': User.get_username(self.creator_id), 'created_at': format_datetime(self.created_at, '%Y-%m-%d'), 'members': self.members }
def as_dict(self): dic = dict(self.to_mongo()) dic['created_at'] = format_datetime(self.created_at, '%b %d, %Y') if 'updated_at' in dic: del dic['updated_at'] if 'deleted_at' in dic: del dic['deleted_at'] return dic
def as_dict(self): dic = dict(self.to_mongo()) dic['gender_text'] = GENDERS_DICT.get(self.gender, '') if self.roles: del dic['with_roles'] if self.privileges: del dic['privileges'] if self.created_at: dic['created_at'] = format_datetime(self.created_at) if self.updated_at: dic['updated_at'] = format_datetime(self.updated_at) if self.deleted_at: dic['deleted_at'] = format_datetime(self.deleted_at) return dic
def as_dict(self): dic = dict(self.to_mongo()) dic['created_at'] = format_datetime(self.created_at, '%b %d, %Y') if 'updated_at' in dic: del dic['updated_at'] if 'deleted_at' in dic: del dic['deleted_at'] if not self.parent_id: replies = [] for r in self.__class__.objects( parent_id=self.id).order_by('created_at'): replies.append(r.as_dict()) dic['replies'] = replies return dic
def as_dict(self, with_history=False): dic = { 'room_id': self.room_id, 'user_id': self.user_id, 'status': self.status, 'status_text': self.STATUS_DICT.get(self.status, '-') } if with_history: histories = [] for history in self.histories: histories.append({ 'status': history.status, 'status_text': self.STATUS_DICT.get(history.status, '-'), 'operated_at': format_datetime(history.operated_at, '%Y-%m-%d') }) dic.update(histories=histories) return dic
def as_dict(self): dic = dict(self.to_mongo()) dic['comments'] = self.comments dic['created_at'] = format_datetime(self.created_at, '%b %d, %Y') return dic