create campaign form start
This commit is contained in:
parent
93dd70849a
commit
7ada4b2a6f
3 changed files with 89 additions and 4 deletions
|
|
@ -2,7 +2,7 @@ from app import db
|
|||
from app.campaigns import campaigns
|
||||
from app.users.models import User
|
||||
from app.campaigns.models import Campaign
|
||||
# from forms import LoginForm, RequestResetForm, ResetPasswordForm, EditUserForm, AddUserForm
|
||||
from app.campaigns.forms import CreateCampaignForm
|
||||
from flask import render_template, redirect, url_for, flash, request
|
||||
from flask_login import login_required, login_user, current_user, logout_user
|
||||
from werkzeug.security import check_password_hash, generate_password_hash
|
||||
|
|
@ -10,9 +10,20 @@ from datetime import datetime
|
|||
import os
|
||||
from time import sleep
|
||||
|
||||
@campaigns.route('add_campaign')
|
||||
@campaigns.route('add_campaign', methods=['GET', 'POST'])
|
||||
def add_campaign():
|
||||
return render_template('add_campaign.html')
|
||||
form = CreateCampaignForm()
|
||||
if form.validate_on_submit():
|
||||
campaign = Campaign(
|
||||
title=form.title.data,
|
||||
active=form.active.data,
|
||||
goal=form.goal.data
|
||||
)
|
||||
db.session.add(campaign)
|
||||
db.session.commit()
|
||||
return redirect(url_for('admin.administration'))
|
||||
return render_template('add_campaign.html',
|
||||
form=form)
|
||||
|
||||
@campaigns.route('campaign_page/<campaign_id>')
|
||||
def campaign_page(campaign_id):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue