def groups_create(): form = GroupForm(request.form) if not form.validate(): return render_template("group/new.html", form=GroupForm(), error="Minimum length for name is 4") g = Groups(form.name.data, current_user.get_id()) db.session().add(g) db.session().commit() ga = GroupAccountLink(g.id, current_user.get_id(), False) db.session().add(ga) db.session().commit() return redirect(url_for("group_home", param=g.id))
def groups_create(): form = GroupForm(request.form) if not form.validate(): return render_template("groups/new.html", form=form) allusers = get_users_choices() memberlist = [] for v in form.group_users_select.data: try: user_id = int(v) memberlist.append(v) except ValueError: pass g = Group(memberlist) g.name = form.name.data g.created_by = current_user.id #INSERT INTO group_accounts VALUES :group_id, :account_id db.session().add(p) db.session().commit() return redirect(url_for("polls_index"))
def group_edit(param): toEdit = Groups.query.filter_by(id=param).first() if request.method == "GET": form = GroupForm() form.name.data = toEdit.name return render_template("group/edit.html", form=form, id=param) form = GroupForm(request.form) if not form.validate(): form = GroupForm() form.name.data = toEdit.name return render_template("group/edit.html", form=form, id=param, error="Minimum length for name is 4") Groups.edit_group(form.name.data, param) return redirect(url_for("user_own"))
def groups_edit_form(group_id): g = Group.query.get(group_id) if g.creator_id != current_user.id and current_user.role != "ADMIN": return login_manager.unauthorized() return render_template("groups/edit.html", group=g, form=GroupForm(), authorized=True)
def edit_group(group_id): group_id=int(group_id) group = Crew.query.get(group_id) members = group.get_members_with_release_count() form=GroupForm() non_members= group.get_non_members() memberform=AddMemberForm() memberform.member_id.choices = [(0, 'Choose existing artist')]+[(a.id, a.name) for a in non_members] return render_template("groups/edit.html", form=form, memberform=memberform, group=group, authors=non_members, members=members)
def group_new(): form = GroupForm(request.form) if not form.validate(): return render_template("groups/newGroup.html", form=form) g = Groups(form.heading.data) g.account_id = current_user.id db.session().add(g) db.session().commit() return redirect(url_for("all_groups"))
def modify_group_form(group_id): g = Groups.query.get(group_id).heading form = GroupForm() form.heading.default = g form.process() categories = Groups.categories(group_id) return render_template("groups/modifyGroup.html", form=form, group_id=group_id, categories=categories)
def groups_create(): form = GroupForm(request.form) if not form.validate(): return render_template("groups/new.html", form=form) group = Group(form.groupname.data) db.session().add(group) db.session().commit() return redirect(url_for("list_groups"))
def groups_create(): form = GroupForm(request.form) if not form.validate(): return render_template("groups/new.html", form=form) g = Group(form.name.data, current_user.id) db.session().add(g) g.members.append(current_user) db.session().commit() return redirect(url_for("users_groups"))
def groups_create(): form = GroupForm(request.form) if not form.validate(): return render_template("groups/new.html", form=form) g = Group(form.name.data) db.session().add(g) db.session().commit() flash('Group added succesfully', 'success') return redirect(url_for("groups_index"))
def modify_group(group_id): form = GroupForm(request.form) if not form.validate(): return render_template("groups/modifyGroup.html", form=form) g = Groups.query.get(group_id) if g.account_id == current_user.id or current_user.get_role( ).role == "ADMIN": g.heading = form.heading.data db.session.commit() return redirect(url_for("all_groups"))
def update_group(group_id): form=GroupForm(request.form) if not form.validate(): authors = Author.query.all() return render_template("groups/new.html", form=form, authors=authors) name=form.name.data abbreviation=form.abbreviation.data group=Crew.query.get(group_id) group.abbreviaion=abbreviation group.name=name db.session().commit() return redirect(url_for("view_group", group_id=group.id))
def groups_edit(group_id): g = Group.query.get(group_id) if g.creator_id != current_user.id and current_user.role != "ADMIN": return login_manager.unauthorized() form = GroupForm(request.form) if not form.validate(): return render_template("groups/edit.html", group=g, form=form) g.name = form.name.data db.session().commit() return redirect(url_for("groups_view", group_id=group_id))
def group_create(): #create group if unique name. forward to existing groups view form=GroupForm(request.form) if not form.validate(): authors = Author.query.all() return render_template("groups/new.html", form=form, authors=authors) name=form.name.data abbreviation=form.abbreviation.data group=Crew.query.filter_by(name=name).first() if (group == None): group=Crew(name, abbreviation) db.session().add(group) db.session().commit() return redirect(url_for("view_group", group_id=group.id))
def group_form(): return render_template("groups/new.html", form=GroupForm())
def groups_form(): myform = GroupForm() myform.group_users_select.choices = get_users_choices() return render_template("groups/new.html", form=myform)
def group_new_form(): # for new groups just offer (value=group.name)a simple form with group name and acronym form = GroupForm() authors = Author.query.all() return render_template("groups/new.html", form=form, authors=authors)