def __get_return_list(posts): result = [] for post in posts: post_dict = {} post_dict[ParamConsts.POSTID] = post.id post_dict[ParamConsts.USERID] = post.user_id post_dict[ParamConsts.LATITUDE] = post.latitude post_dict[ParamConsts.LONGTITUDE] = post.longitude post_dict[ParamConsts.USER_LATITUDE] = post.user_latitude post_dict[ParamConsts.USER_LONGITUDE] = post.user_longitude post_dict[ParamConsts.TEXT_CONTENT] = post.text_content post_dict[ParamConsts.CONTENT_TYPE] = post.content_type post_dict[ParamConsts.CREATE_DATE] = date2str(post.create_date) result.append(post_dict) return result
def cp(request): cp_form = CpForm(request.GET) if cp_form.is_valid(): post = Post() post.user_id = cp_form.cleaned_data[ParamConsts.USERID] post.app_id = cp_form.cleaned_data[ParamConsts.APPID] post.place_id = cp_form.cleaned_data[ParamConsts.PLACEID] post.content_type = cp_form.cleaned_data[ParamConsts.CONTENT_TYPE] post.text_content = cp_form.cleaned_data[ParamConsts.TEXT_CONTENT] post.latitude = cp_form.cleaned_data[ParamConsts.LATITUDE] post.longitude = cp_form.cleaned_data[ParamConsts.LONGTITUDE] post.user_latitude = cp_form.cleaned_data[ParamConsts.USER_LATITUDE] post.user_longitude = cp_form.cleaned_data[ParamConsts.USER_LONGITUDE] services.new_post(post); returnCode = errors.ERROR_SUCCESS return get_json_response(get_return_dict(returnCode, {ParamConsts.POSTID: post.id, ParamConsts.CREATE_DATE: date2str(post.create_date)})) else: returnCode = errors.ERROR_PARAMETER return get_json_response(get_return_dict(returnCode, message=cp_form.errors))