示例#1
0
def team_delete(org, team):
    if team == org.owners:
        abort(403)
    if request.method == 'POST':
        team_data_changed.send(team, changes=['delete'], user=g.user)
    return render_delete_sqla(team, db, title=u"Confirm delete", message=u"Delete team '%s'?" % team.title,
        success=u"You have deleted team '%s' from organization '%s'." % (team.title, org.title),
        next=url_for('.org_info', name=org.name))
示例#2
0
文件: org.py 项目: gonrin/lastuser
def team_delete(org, team):
    if team == org.owners or team == org.members:
        abort(403)
    if request.method == 'POST':
        team_data_changed.send(team, changes=['delete'], user=g.user)
    return render_delete_sqla(team, db, title=_(u"Confirm delete"), message=_(u"Delete team {title}?").format(title=team.title),
        success=_(u"You have deleted team ‘{team}’ from organization ‘{org}’").format(team=team.title, org=org.title),
        next=url_for('.org_info', name=org.name))
示例#3
0
文件: org.py 项目: gonrin/lastuser
def team_edit(org, team):
    form = TeamForm(obj=team)
    if form.validate_on_submit():
        form.populate_obj(team)
        db.session.commit()
        team_data_changed.send(team, changes=['edit'], user=g.user)
        return render_redirect(url_for('.org_info', name=org.name), code=303)
    return render_form(form=form,
        title=_(u"Edit team: {title}").format(title=team.title),
        formid='team_edit', submit=_("Save"), ajax=False)
示例#4
0
文件: org.py 项目: gonrin/lastuser
def team_new(org):
    form = TeamForm()
    if form.validate_on_submit():
        team = Team(org=org)
        db.session.add(team)
        form.populate_obj(team)
        db.session.commit()
        team_data_changed.send(team, changes=['new'], user=g.user)
        return render_redirect(url_for('.org_info', name=org.name), code=303)
    return render_form(form=form, title=_(u"Create new team"),
        formid='team_new', submit=_("Create"))
示例#5
0
def team_edit(org, team):
    form = TeamForm(obj=team)
    if form.validate_on_submit():
        form.populate_obj(team)
        db.session.commit()
        team_data_changed.send(team, changes=['edit'], user=g.user)
        return render_redirect(url_for('.org_info', name=org.name), code=303)
    return render_form(form=form,
                       title=_(u"Edit team: {title}").format(title=team.title),
                       formid='team_edit',
                       submit=_("Save"),
                       ajax=False)
示例#6
0
文件: org.py 项目: gantir/lastuser
def team_edit(org, team):
    form = TeamForm(obj=team)
    if request.method == 'GET':
        form.users.data = [u.userid for u in team.users]
    if form.validate_on_submit():
        team.title = form.title.data
        if form.users.data:
            team.users = User.query.filter(User.userid.in_(form.users.data)).all()
        db.session.commit()
        team_data_changed.send(team, changes=['edit'], user=g.user)
        return render_redirect(url_for('.org_info', name=org.name), code=303)
    return make_response(render_template('edit_team.html', form=form, title=u"Edit team: %s" % team.title, formid='team_edit', submit="Save", ajax=False))
示例#7
0
def team_new(org):
    form = TeamForm()
    if form.validate_on_submit():
        team = Team(org=org)
        team.title = form.title.data
        if form.users.data:
            team.users = User.query.filter(User.userid.in_(form.users.data)).all()
        db.session.add(team)
        db.session.commit()
        team_data_changed.send(team, changes=['new'], user=g.user)
        return render_redirect(url_for('.org_info', name=org.name), code=303)
    return make_response(render_template('edit_team.html', form=form, title=u"Create new team",
        formid='team_new', submit="Create"))
示例#8
0
def team_delete(org, team):
    if team == org.owners or team == org.members:
        abort(403)
    if request.method == 'POST':
        team_data_changed.send(team, changes=['delete'], user=g.user)
    return render_delete_sqla(
        team,
        db,
        title=_(u"Confirm delete"),
        message=_(u"Delete team {title}?").format(title=team.title),
        success=_(u"You have deleted team ‘{team}’ from organization ‘{org}’"
                  ).format(team=team.title, org=org.title),
        next=url_for('.org_info', name=org.name))
示例#9
0
def team_new(org):
    form = TeamForm()
    if form.validate_on_submit():
        team = Team(org=org)
        db.session.add(team)
        form.populate_obj(team)
        db.session.commit()
        team_data_changed.send(team, changes=['new'], user=g.user)
        return render_redirect(url_for('.org_info', name=org.name), code=303)
    return render_form(form=form,
                       title=_(u"Create new team"),
                       formid='team_new',
                       submit=_("Create"))
示例#10
0
文件: org.py 项目: gantir/lastuser
def team_delete(org, team):
    if team == org.owners:
        abort(403)
    if request.method == 'POST':
        team_data_changed.send(team, changes=['delete'], user=g.user)
    return render_delete_sqla(
        team,
        db,
        title=u"Confirm delete",
        message=u"Delete team '%s'?" % team.title,
        success=u"You have deleted team '%s' from organization '%s'." %
        (team.title, org.title),
        next=url_for('.org_info', name=org.name))
示例#11
0
 def edit(self):
     form = TeamForm(obj=self.obj)
     if form.validate_on_submit():
         form.populate_obj(self.obj)
         db.session.commit()
         team_data_changed.send(self.obj,
                                changes=['edit'],
                                user=current_auth.user)
         return render_redirect(self.obj.org.url_for(), code=303)
     return render_form(
         form=form,
         title=_(u"Edit team: {title}").format(title=self.obj.title),
         formid='team_edit',
         submit=_("Save"),
         ajax=False)
示例#12
0
 def new_team(self):
     form = TeamForm()
     if form.validate_on_submit():
         team = Team(org=self.obj)
         db.session.add(team)
         form.populate_obj(team)
         db.session.commit()
         team_data_changed.send(team,
                                changes=['new'],
                                user=current_auth.user)
         return render_redirect(self.obj.url_for('view'), code=303)
     return render_form(form=form,
                        title=_(u"Create new team"),
                        formid='new_team',
                        submit=_("Create"))
示例#13
0
 def delete(self):
     if self.obj == self.obj.org.owners or self.obj == self.obj.org.members:
         abort(403)
     if request.method == 'POST':
         team_data_changed.send(self.obj,
                                changes=['delete'],
                                user=current_auth.user)
     return render_delete_sqla(
         self.obj,
         db,
         title=_(u"Confirm delete"),
         message=_(u"Delete team {title}?").format(title=self.obj.title),
         success=_(
             u"You have deleted team ‘{team}’ from organization ‘{org}’").
         format(team=self.obj.title, org=self.obj.org.title),
         next=self.obj.org.url_for())
示例#14
0
def team_new(org):
    form = TeamForm()
    if form.validate_on_submit():
        team = Team(org=org)
        team.title = form.title.data
        if form.users.data:
            team.users = User.query.filter(User.userid.in_(
                form.users.data)).all()
        db.session.add(team)
        db.session.commit()
        team_data_changed.send(team, changes=['new'], user=g.user)
        return render_redirect(url_for('.org_info', name=org.name), code=303)
    return make_response(
        render_template('edit_team.html',
                        form=form,
                        title=u"Create new team",
                        formid='team_new',
                        submit="Create"))
示例#15
0
def team_edit(org, team):
    form = TeamForm(obj=team)
    if request.method == 'GET':
        form.users.data = [u.userid for u in team.users]
    if form.validate_on_submit():
        team.title = form.title.data
        if form.users.data:
            team.users = User.query.filter(User.userid.in_(
                form.users.data)).all()
        db.session.commit()
        team_data_changed.send(team, changes=['edit'], user=g.user)
        return render_redirect(url_for('.org_info', name=org.name), code=303)
    return make_response(
        render_template(u'edit_team.html',
                        form=form,
                        title=u"Edit team: {title}".format(title=team.title),
                        formid='team_edit',
                        submit="Save",
                        ajax=False))