@blueprint.route('<STR_LIT>', methods=['<STR_LIT:GET>', '<STR_LIT:POST>'])<EOL>@login_required<EOL>@pass_community<EOL>@permission_required('<STR_LIT>')<EOL>def edit(community):
form = EditCommunityForm(formdata=request.values, obj=community)<EOL>deleteform = DeleteCommunityForm()<EOL>ctx = mycommunities_ctx()<EOL>ctx.update({<EOL>'<STR_LIT>': form,<EOL>'<STR_LIT>': False,<EOL>'<STR_LIT>': community,<EOL>'<STR_LIT>': deleteform,<EOL>})<EOL>if form.validate_on_submit():<EOL><INDENT>for field, val in form.data.items():<EOL><INDENT>setattr(community, field, val)<EOL><DEDENT>file = request.files.get('<STR_LIT>', None)<EOL>if file:<EOL><INDENT>if not community.save_logo(file.stream, file.filename):<EOL><INDENT>form.logo.errors.append(_(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'))<EOL><DEDENT><DEDENT>if not form.logo.errors:<EOL><INDENT>db.session.commit()<EOL>flash("<STR_LIT>", category='<STR_LIT:success>')<EOL>return redirect(url_for('<STR_LIT>', community_id=community.id))<EOL><DEDENT><DEDENT>return render_template(<EOL>current_app.config['<STR_LIT>'],<EOL>**ctx<EOL>)<EOL>
Create or edit a community.