@blueprint.route('<STR_LIT>', methods=['<STR_LIT:GET>', '<STR_LIT:POST>'])<EOL>@login_required<EOL>def new():
form = CommunityForm(formdata=request.values)<EOL>ctx = mycommunities_ctx()<EOL>ctx.update({<EOL>'<STR_LIT>': form,<EOL>'<STR_LIT>': True,<EOL>'<STR_LIT>': None,<EOL>})<EOL>if form.validate_on_submit():<EOL><INDENT>data = copy.deepcopy(form.data)<EOL>community_id = data.pop('<STR_LIT>')<EOL>del data['<STR_LIT>']<EOL>community = Community.create(<EOL>community_id, current_user.get_id(), **data)<EOL>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>db.session.rollback()<EOL>community = None<EOL><DEDENT><DEDENT>if community:<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>community_form=form,<EOL>**ctx<EOL>)<EOL>
Create a new community.