-
-
Save abhisuri97/5a04df24ba97fe4cd1a100051cda2403 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@club.route('/new-club', methods=['GET', 'POST']) | |
@login_required | |
def new_club(): | |
"""Create a new club.""" | |
form = NewClubForm() | |
if form.validate_on_submit(): | |
club = Club( | |
name=form.name.data, | |
description=form.desc.data, | |
is_confirmed=current_user.is_admin(), | |
categories=form.categories.data) | |
db.session.add(club) | |
db.session.commit() | |
link = url_for( | |
'club.change_club_details', club_id=club.id, _external=True) | |
if (current_user.is_admin() == False): | |
for r in Role.query.filter_by(name='Administrator').all(): | |
for a in r.users: | |
get_queue().enqueue( | |
send_email, | |
recipient=a.email, | |
subject='A new club was suggested by {}'.format( | |
current_user.first_name), | |
template='club/email/suggested_club', | |
club=club, | |
link=link) | |
action = 'created' if current_user.is_admin() else 'suggested' | |
flash('Club {} successfully {}'.format(club.name, action), | |
'form-success') | |
return render_template('club/new_club.html', form=form) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment