def post(self, tid, op): if op == 'view': return self.get(tid, op) team = TeamService(db).get(tid) team.title = request.form.get('title') team.desc = request.form.get('desc') db.session.commit() return self.get(op='view', tid=tid)
def get(self, tid, op): if op == 'edit': return current_app.make_response( render_template('team.html', team=TeamService(db).get(tid), edit=True)) return current_app.make_response( render_template('team.html', team=TeamService(db).get(tid), isLeader=permission_check(tid)))
def post(self, tid, uid): uids = [int(i) for i in request.form.get('uids').split(' ')] for uid in uids: TeamService(db).add_user(tid=tid, uid=uid) return current_app.make_response( redirect(url_for('Team.team', op='view', tid=tid)))
def get(self, tid, uid): TeamService(db).add_user(tid, uid) return TeamAPI().get(op='view', tid=tid)
def post(self): title = request.form.get('title') desc = request.form.get('desc') team = TeamService(db).create(title=title, desc=desc) return TeamAPI().get(tid=team.id, op='view')
def get(self): return current_app.make_response( render_template( 'teams.html', teams=TeamService(db).get_all(owner_id=g.user_id), ))
def permission_check(tid, **kwargs): team = TeamService(db).get(tid) r = TeamUserRelationshipService(db).get(team_id=team.id, user_id=g.user_id) if r: return r.isLeader or team.owner.id == g.user_id return False