Example #1
0
File: team.py Project: Puwong/MiMac
 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)
Example #2
0
File: team.py Project: Puwong/MiMac
 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)))
Example #3
0
File: team.py Project: Puwong/MiMac
 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)))
Example #4
0
File: team.py Project: Puwong/MiMac
 def get(self, tid, uid):
     TeamService(db).add_user(tid, uid)
     return TeamAPI().get(op='view', tid=tid)
Example #5
0
File: team.py Project: Puwong/MiMac
 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')
Example #6
0
File: team.py Project: Puwong/MiMac
 def get(self):
     return current_app.make_response(
         render_template(
             'teams.html',
             teams=TeamService(db).get_all(owner_id=g.user_id),
         ))
Example #7
0
File: team.py Project: Puwong/MiMac
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