def group_requisition(): is_admin() action = request.args.get("action", '').strip() #如果通过申请 if action == 'pass': id = int(request.args.get("id", '').strip()) gr = Group_Requisition.query.get_or_404(id) group = Group(gr.name,gr.url_name,gr.author_id,gr.description) gr.status = 1 send_msg(gr.author_id,u'小组申请通过',u'恭喜您,您所申请的'+gr.name+u'小组已经通过审核。去http://www.42ic.com/group/'+gr.url_name+u',看看吧') db.session.add( group ) db.session.commit() #申请人自动加入 group_user = Group_User(group.id,gr.author_id) db.session.add( group_user ) db.session.commit() return redirect(url_for("admin.group_requisition")) if action == 'refusal': id = int(request.args.get("id", '').strip()) gr = Group_Requisition.query.get_or_404(id) gr.status = 2 send_msg(gr.author_id,u'小组申请失败',u'对不起,您申请的小组'+gr.name+u'资料不全,未能通过审核') db.session.commit() return redirect(url_for("admin.group_requisition")) req_list = Group_Requisition.query.order_by(Group_Requisition.status).all() #send_msg(1,'hi','lyping') return render_template("/admin/group_requisition.html",req_list = req_list)
def signup(): form = SignupForm(next=request.args.get("next")) if form.validate_on_submit(): user = User() form.populate_obj(user) user.reg_ip = request.remote_addr db.session.add(user) user_icon = Users_icon() db.session.commit() user_icon.uid = user.id db.session.add(user_icon) #默认姓名就是用户名 user.name = user.username #广播一下 queue.push((101,user.id)) db.session.commit() send_msg(user.id,u'欢迎加入42ic.com',u'42ic是一个专注于电子行业的社区网站,欢迎您的加入!') flash(u"您已经注册成功!请登陆", "success") next_url = form.next.data if not next_url or next_url == request.path: next_url = url_for('account.login') #print('OK') return redirect(next_url) return render_template("account/signup.html", form=form)