()
return render_template('new_project.html', form=form)
Create a new project.
Create a new project.
Create a new project .
def new():
    """
    Create a new project.
    """
    form = ProjectDetailsForm()
    if form.validate_on_submit():
        p = Project.by_name_and_owner(form.name.data, g.user)
        if p:
            form.name.errors = [
                wtf.ValidationError('Project name must be unique.')
            ]
        else:
            p = Project.new(
                form.name.data,
                public=form.public.data,
                website=form.website.data
            )
            p.full_name = '{0}/{1}'.format(g.user.username, p.name)
            g.user.projects.append(p)
            db.session.add(p)

            if p.public:
                # New public projects get added to #commits by default.
                c = Channel.new(
                    '#commits',
                    'chat.freenode.net',
                    6667,
                    ssl=False,
                    public=True
                )
                p.channels.append(c)

            db.session.commit()

            return redirect(url_for('.details', u=g.user.username, p=p.name))

    return render_template('new_project.html', form=form)
def new ( ) : form = ProjectDetailsForm ( ) if form . validate_on_submit ( ) : p = Project . by_name_and_owner ( form . name . data , g . user ) if p : form . name . errors = [ wtf . ValidationError ( 'Project name must be unique.' ) ] else : p = Project . new ( form . name . data , public = form . public . data , website = form . website . data ) p . full_name = '{0}/{1}' . format ( g . user . username , p . name ) g . user . projects . append ( p ) db . session . add ( p ) if p . public : # New public projects get added to #commits by default. c = Channel . new ( '#commits' , 'chat.freenode.net' , 6667 , ssl = False , public = True ) p . channels . append ( c ) db . session . commit ( ) return redirect ( url_for ( '.details' , u = g . user . username , p = p . name ) ) return render_template ( 'new_project.html' , form = form )