示例#1
0
 def _process(self):
     existing_group = self.group if not self.new_group else None
     form = EditGroupForm(obj=existing_group, group=existing_group)
     if form.validate_on_submit():
         form.populate_obj(self.group)
         if self.new_group:
             db.session.add(self.group)
             msg = _("The group '{name}' has been created.")
         else:
             msg = _("The group '{name}' has been updated.")
         db.session.flush()
         flash(msg.format(name=self.group.name), "success")
         return redirect(url_for(".groups"))
     return WPGroupsAdmin.render_template("group_edit.html", group=existing_group, form=form)
示例#2
0
 def _process(self):
     existing_group = self.group if not self.new_group else None
     form = EditGroupForm(obj=existing_group, group=existing_group)
     if form.validate_on_submit():
         form.populate_obj(self.group)
         if self.new_group:
             db.session.add(self.group)
             msg = _("The group '{name}' has been created.")
         else:
             msg = _("The group '{name}' has been updated.")
         db.session.flush()
         flash(msg.format(name=self.group.name), 'success')
         return redirect(url_for('.groups'))
     return WPGroupsAdmin.render_template('group_edit.html', group=existing_group, form=form)