Example #1
0
	def to_json_dict(self):
		reply_dict = {}
		reply_dict["reply_id"] = self.reply_id
		reply_dict["post_id"] = self.post_id
		reply_dict["author_id"] = self.author_id
		reply_dict["author_name"] = self.author_name
		reply_dict["portrait_src"] = filesystem_storage_service.get_cropped_src(self.author_portrait, self.author_id)
		reply_dict["reply_body"] = self.reply_body
		reply_dict["reply_date"] = self.reply_date.isoformat("T")
		reply_dict["location"] = self.location.to_json_dict()
		reply_dict["privacy"] = self.privacy
		reply_dict["edited"] = self.edited

		return reply_dict
Example #2
0
	def to_json_dict(self):
		post_dict = {}

		post_dict['post_id'] = self.post_id
		post_dict['author_id'] = self.author_id
		post_dict['author_name'] = self.author_name
		post_dict["portrait_src"] = filesystem_storage_service.get_cropped_src(self.author_portrait, self.author_id)
		post_dict['body'] = self.body
		post_dict['post_date'] = self.post_date.isoformat("T")
		post_dict['privacy'] = self.privacy
		post_dict['location'] = self.location.to_json_dict()
		post_dict['likes'] = self.likes
		post_dict['liked'] = self.liked

		if self.replies != None:
			replies_dicts = []
			for reply in self.replies:
				replies_dicts.append(reply.to_json_dict())
			post_dict['replies'] = replies_dicts

		return post_dict
Example #3
0
	def to_json_dict(self, **kwargs):
		show_private_fields = kwargs.get("private", False)
		build_profile_pic_src = kwargs.get("portrait", True)

		user_dict = None
		portrait_src = filesystem_storage_service.get_cropped_src(self.portrait, self.user_id)
		if show_private_fields:
			user_dict = self.__dict__
			user_dict["preferences"] = self.preferences.to_json_dict()

		else:
			user_dict = {
				"user_id" : self.user_id,
				"first_name" : self.first_name,
				"last_name" : self.last_name,
				"nick_name" : self.nick_name,
				"portrait" : self.portrait,
				"biography" : self.biography
			}

		user_dict["portrait_src"] = portrait_src
		

		return user_dict
Example #4
0
	def to_json_dict(self):
		return {
			"user_id" : self.user_id,
			"name" : self.name,
			"portrait_src" : filesystem_storage_service.get_cropped_src(self.portrait, self.user_id)
		}