def render_entry(username, page, entry_type=None): user = UserService.get_by_username(username) if not user: abort(404) statistic = EntryService.get_statistic_by_author_id(user.id) data = get_people_entries(user.id, page, entry_type) if entry_type is not None: current_entry_type = entry_type_str[entry_type] else: current_entry_type = 'latest' return render_template("people/%s.html" % 'latest', current_entry_type=current_entry_type, entries_list=data['entries_list'], record_total=data['record_total'], page_total=data['page_total'], current_page=page, page_url='/%s/%s/%s/index' % (URL_BASE, username, current_entry_type), statistic=statistic, notices=NoticeService.get_list_for_show(), people=user)
def message(username): """ 显示个人消息 """ query, sort, order, page = query_condition() user = UserService.get_by_username(username) if not user: abort(404) statistic = EntryService.get_statistic_by_author_id(user.id) record_total, page_total, messages_list = MessageService( ).getlist_by_receiver_id(user.id, page, sort, order) current_entry_type = 'message' return render_template("people/%s.html" % current_entry_type, current_entry_type=current_entry_type, messages_list=messages_list, record_total=record_total, page_total=page_total, current_page=page, page_url='/%s/%s/%s/index' % (URL_BASE, username, current_entry_type), statistic=statistic, notices=NoticeService.get_list_for_show(), people=user)
def favorites_comment(username): query, sort, order, page = query_condition() user = UserService.get_by_username(username) if not user: abort(404) statistic = EntryService.get_statistic_by_author_id(user.id) _total, _pages, _list = CommentService.getlist_by_author_id(user.id, page) current_entry_type = 'comment' return render_template("favorites/%s.html" % current_entry_type, current_entry_type=current_entry_type, comments_list=_list, record_total=_total, page_total=_pages, current_page=page, page_url='/%s/%s/%s/index' % (URL_BASE, username, current_entry_type), statistic=statistic, notices=NoticeService.get_list_for_show(), people=user)
def comment(username): query, sort, order, page = query_condition() user = UserService.get_by_username(username) if not user: abort(404) statistic = EntryService.get_statistic_by_author_id(user.id) record_total, page_total, comments_list = CommentService.getlist_by_author_id( user.id, page, sort, order) # for comment in comments_list: # entry = EntryService.get_by_id(comment.entry_id) # comment.entry_title = entry.title # # http://127.0.0.1:5000/article/5.html#comment-90 # comment.entry_url = url_for('portal.entry', slug=entry.slug)+ "#comment-%d" % comment.id current_entry_type = 'comment' return render_template("people/%s.html" % current_entry_type, current_entry_type=current_entry_type, comments_list=comments_list, record_total=record_total, page_total=page_total, current_page=page, page_url='/%s/%s/%s/index' % (URL_BASE, username, current_entry_type), statistic=statistic, notices=NoticeService.get_list_for_show(), people=user)
def edit(username): """ 编辑 users """ user = UserService.get_by_username(username) if not user: abort(404) if request.method == 'GET': form = PeopleEditForm(next=request.args.get('next', None), id=id, obj=user) else: form = PeopleEditForm(next=request.args.get('next', None), id=id) if form.validate_on_submit(): # 获取指定的表单数据 form.populate_obj(user) # 保存数据 UserService.update(user) flash(_("Modify success"), "success") next_url = form.next.data if not next_url or next_url == request.path: next_url = url_for('people.show', username=username) return redirect(next_url) elif form.errors: for error_name, error_value in form.errors.iteritems(): print "error: %s %s" % (error_name, error_value) flash(_("Cause an error"), "failed") statistic = EntryService.get_statistic_by_author_id(user.id) return render_template("people/edit.html", form=form, people=user, statistic=statistic, form_id=user.id)
def render_entry(username, page, entry_type=None): user = UserService.get_by_username(username) if not user: abort(404) statistic = EntryService.get_statistic_by_author_id(user.id) data = get_people_entries(user.id, page, entry_type) if entry_type is not None: current_entry_type = entry_type_str[entry_type] else: current_entry_type = 'latest' return render_template("people/%s.html" % 'latest', current_entry_type=current_entry_type, entries_list=data['entries_list'], record_total=data['record_total'], page_total=data['page_total'], current_page=page, page_url = '/%s/%s/%s/index' % (URL_BASE, username, current_entry_type), statistic=statistic, notices=NoticeService.get_list_for_show(), people=user)
def comment(username): query, sort, order, page = query_condition() user = UserService.get_by_username(username) if not user: abort(404) statistic = EntryService.get_statistic_by_author_id(user.id) record_total, page_total, comments_list = CommentService.getlist_by_author_id(user.id, page, sort, order) # for comment in comments_list: # entry = EntryService.get_by_id(comment.entry_id) # comment.entry_title = entry.title # # http://127.0.0.1:5000/article/5.html#comment-90 # comment.entry_url = url_for('portal.entry', slug=entry.slug)+ "#comment-%d" % comment.id current_entry_type = 'comment' return render_template("people/%s.html" % current_entry_type, current_entry_type=current_entry_type, comments_list=comments_list, record_total=record_total, page_total=page_total, current_page=page, page_url = '/%s/%s/%s/index' % (URL_BASE, username, current_entry_type), statistic=statistic, notices=NoticeService.get_list_for_show(), people=user)
def message(username): """ 显示个人消息 """ query, sort, order, page = query_condition() user = UserService.get_by_username(username) if not user: abort(404) statistic = EntryService.get_statistic_by_author_id(user.id) record_total, page_total, messages_list = MessageService().getlist_by_receiver_id(user.id, page, sort, order) current_entry_type = 'message' return render_template("people/%s.html" % current_entry_type, current_entry_type=current_entry_type, messages_list=messages_list, record_total=record_total, page_total=page_total, current_page=page, page_url = '/%s/%s/%s/index' % (URL_BASE, username, current_entry_type), statistic=statistic, notices=NoticeService.get_list_for_show(), people=user)
def show(username): """ 显示 users """ user = UserService.get_by_username(username) if not user: abort(404) statistic = EntryService.get_statistic_by_author_id(user.id) return render_template("people/show.html", people=user, statistic=statistic, user=user)
def change_passwd(username): """ 改变密码 """ user = UserService.get_by_username(username) if not user: abort(404) statistic = EntryService.get_statistic_by_author_id(user.id) if request.method == 'GET': form = ChangePasswordForm(next=request.args.get('next', None), id=user.id, obj=user) else: form = ChangePasswordForm(next=request.args.get('next', None), id=user.id) if form.validate_on_submit(): # 获取指定的表单数据 form.populate_obj(user) # 保存数据 result = UserService.update_pwd_by_id(user.id, user.password) if result: flash(_("Modify success"), "success") else: flash(_("This old password is error"), "failed") return render_template("people/change_passwd.html", people=user, statistic=statistic, form=form, form_id=user.id) return render_template("people/change_passwd_success.html", people=user, statistic=statistic, form=form, form_id=user.id) elif form.errors: for error_name, error_value in form.errors.iteritems(): print "error: %s %s" % (error_name, error_value) flash(_("Cause an error"), "failed") return render_template("people/change_passwd.html", people=user, statistic=statistic, form=form, form_id=user.id)
def show(username): """ 显示 users """ user = UserService.get_by_username(username) if not user: abort(404) statistic = EntryService.get_statistic_by_author_id(user.id) return render_template("people/show.html", people=user, statistic=statistic, user=user)
def edit(username): """ 编辑 users """ user = UserService.get_by_username(username) if not user: abort(404) if request.method == 'GET': form = PeopleEditForm(next=request.args.get('next', None), id=id, obj=user) else: form = PeopleEditForm(next=request.args.get('next', None), id=id) if form.validate_on_submit(): # 获取指定的表单数据 form.populate_obj(user) # 保存数据 UserService.update(user) flash(_("Modify success"), "success") next_url = form.next.data if not next_url or next_url == request.path: next_url = url_for('people.show', username=username) return redirect(next_url) elif form.errors: for error_name, error_value in form.errors.iteritems(): print "error: %s %s" % (error_name, error_value) flash(_("Cause an error"), "failed") statistic = EntryService.get_statistic_by_author_id(user.id) return render_template("people/edit.html", form=form, people=user, statistic=statistic, form_id=user.id)
def change_passwd(username): """ 改变密码 """ user = UserService.get_by_username(username) if not user: abort(404) statistic = EntryService.get_statistic_by_author_id(user.id) if request.method == 'GET': form = ChangePasswordForm(next=request.args.get('next', None), id=user.id, obj=user) else: form = ChangePasswordForm(next=request.args.get('next', None), id=user.id) if form.validate_on_submit(): # 获取指定的表单数据 form.populate_obj(user) # 保存数据 result = UserService.update_pwd_by_id(user.id, user.password) if result: flash(_("Modify success"), "success") else: flash(_("This old password is error"), "failed") return render_template("people/change_passwd.html", people=user, statistic=statistic, form=form, form_id=user.id) return render_template("people/change_passwd_success.html", people=user, statistic=statistic, form=form, form_id=user.id) elif form.errors: for error_name, error_value in form.errors.iteritems(): print "error: %s %s" % (error_name, error_value) flash(_("Cause an error"), "failed") return render_template("people/change_passwd.html", people=user, statistic=statistic, form=form, form_id=user.id)
def favorites_comment(username): query, sort, order, page = query_condition() user = UserService.get_by_username(username) if not user: abort(404) statistic = EntryService.get_statistic_by_author_id(user.id) _total, _pages, _list = CommentService.getlist_by_author_id(user.id, page) current_entry_type = 'comment' return render_template("favorites/%s.html" % current_entry_type, current_entry_type=current_entry_type, comments_list=_list, record_total=_total, page_total=_pages, current_page=page, page_url = '/%s/%s/%s/index' % (URL_BASE, username, current_entry_type), statistic=statistic, notices=NoticeService.get_list_for_show(), people=user)