def createProject(request):
    newProject = Project(
        name=request.form['name'],
        description=request.form['description'],
        status='NEW'
    )

    dbSession = Session()

    try:
        newProject = Project(
            name=request.form['name'],
            description=request.form['description'],
            status='NEW'
        )

        dbSession.add(newProject)
        dbSession.commit()

        produceMessageForKafkaTopic(newProject.id)

        return newProject
    except:
        dbSession.rollback()
        raise
    finally:
        dbSession.close()
示例#2
0
def newProject(category_id):
    DBSession = sessionmaker(bind=engine)
    session = DBSession()
    category = session.query(Category).filter_by(
        CategoryID=category_id).one()
    form = ProjectForm()
    if form.validate_on_submit():
        target = os.path.join(APP_ROOT, 'static/images/')
        if not os.path.isdir(target):
            os.mkdir(target)
        if request.files.get("picture") is not None:
            file = request.files.get("picture")
            filename = file.filename
            destination = "/".join([target, filename])
            file.save(destination)
            newProject = Project(
                ProjectName=request.form['name'],
                ProjectDesc=request.form['description'],
                CategoryID=category_id,
                DateAdd=datetime.now().replace(microsecond=0),
                DateEdit=datetime.now().replace(microsecond=0),
                ProjectLocation=request.form['location'],
                ProjectPicture=filename,
                UserID=login_session['user_id'])
        else:
            newProject = Project(
                ProjectName=request.form['name'],
                ProjectDesc=request.form['description'],
                CategoryID=category_id,
                DateAdd=datetime.now().replace(microsecond=0),
                DateEdit=datetime.now().replace(microsecond=0),
                ProjectLocation=request.form['location'],
                ProjectPicture='default.jpg',
                UserID=login_session['user_id'])
        session.add(newProject)
        session.commit()

        if request.files.get("additional-pictures") is not None:
            for file2 in request.files.getlist("additional-pictures"):
                filename2 = file2.filename
                destination = "/".join([target, filename2])
                file2.save(destination)
                newPicture = UploadFile(
                    FileName=filename2, ProjectID=newProject.ProjectID)
                session.add(newPicture)
                session.commit()
        flash("New Project Created!")
        return redirect(url_for('showProjects', category_id=category_id))
    else:
        return render_template('newproject.html', category_id=category_id,
                               category=category, form=form)
示例#3
0
def new_project():
    this_user = findUser()
    endorse = endInfo(this_user)
    if check_auth('new', None):
        if request.method == 'POST':

            this_project = Project(name=request.form['name'],
                                   category=request.form['category'],
                                   user_id=this_user.id,
                                   time_created=datetime.datetime.now(),
                                   tag_line=request.form['tagline'],
                                   website=request.form['website'])

            if request.form['twitch']:
                this_project.twitch = request.form['twitch']
            if request.form['steam']:
                this_project.steam = request.form['steam']
            if request.form['twitter']:
                this_project.twitter = request.form['twitter']

            file = request.files['file']
            if file and allowed_file(file.filename):
                filename = secure_filename(file.filename).split(".")
                cloudinary.uploader.upload(request.files['file'],
                                           public_id=filename[0])
                this_project.picture_name = filename[0]

            if request.form['youtube']:
                this_url = request.form['youtube']
                split_url = this_url.split("=")
                this_project.youtube_url = split_url[1]

            db.add(this_project)
            db.commit()

            description_text = request.form['description']
            this_text = description_text.split('\n')
            for i in this_text:
                this_paragraph = Paragraph(
                    text=i,
                    project_id=this_project.id,
                    time_created=datetime.datetime.now())
                db.add(this_paragraph)
                db.commit()

            if this_user.website is None:
                this_user.website = this_project.website

            flash("New Project Created", "success")
            if this_project:
                return redirect(url_for('project', project_id=this_project.id))
            else:
                return redirect(url_for('profile'))
        else:
            return render_template('new_project.html',
                                   user=this_user,
                                   endorsements=endorse)
    else:
        flash("Please Log In", "danger")
        return redirect(url_for('assets'))
示例#4
0
def create_project():
    new_project = Project(
        name=request.get_json().get('name'),
        description=request.get_json().get('description'),
        business_unit_id=request.get_json().get('business_unit_id'))
    project_repository.create_project(new_project)
    resp = jsonify(success=True)
    resp.status_code = 200
    return resp
def new_project(url, id, description, project_id, projectcategory, image_url):
    """Create New Project and return the Project Object."""
    newProject = Project(project_url=url,
                         author_id=id,
                         project_description=description,
                         projectname_id=project_id,
                         projectcategory_id=projectcategory,
                         image_url=image_url)
    session.add(newProject)
    session.commit()
    return newProject
示例#6
0
def newProject():
    if 'username' not in login_session:
        return redirect('/login')
    if request.method == 'POST':
        newProject = Project(project_name=request.form['newProjectName'],
                             user_id=login_session['user_id'])
        session.add(newProject)
        session.commit()
        flash("New Project %s is Created! " % (newProject.project_name))
        return redirect(url_for('showProjects'))
    else:
        return render_template('newProject.html')
def project_new(session):

    train_credits = 3
    test_credits = 3

    new_project = Project(train_credits=train_credits,
                          test_credits=test_credits)
    session.add(new_project)
    session.commit()  # May be better way to use a session scope here
    user = session.query(User).filter_by(id=getUserID()).first()
    user.project_id_current = new_project.id
    session.add(user)
示例#8
0
def newProject():
    if 'email' not in login_session:
        return redirect('/login')
    if request.method == 'POST':
        newProject = Project(name=request.form['name'],
                             description=request.form['description'],
                             user_id=login_session['user_id'])
        session.add(newProject)
        session.commit()
        return redirect(url_for('showProjects'))
    else:
        return render_template('newProject.html')
def newProject(career_id):

	career = session.query(Career).filter_by(id = career_id).one()

	if request.method == 'POST':
		if request.form['title']:
			newProject = Project(title = request.form['title'], description = request.form['description'], career_id = career_id)
			session.add(newProject)
			session.commit()
			flash("New project created!")
			return redirect(url_for('allProjects', career_id = career_id))
		else: 
			flash("Title field must not be empty!")
			return render_template('newproject.html', career = career)

	else: # handle GET request
		return render_template('newproject.html', career = career)
示例#10
0
def new_project():
    this_user = findUser()
    endorse = endInfo(this_user)
    if check_auth('new', None):
        if request.method == 'POST':

            this_project = Project(name=request.form['name'], category=request.form['category'], user_id=this_user.id,
                                   time_created=datetime.datetime.now(), tag_line=request.form['tagline'],
                                   website=request.form['website'])

            if request.form['twitch']:
                this_project.twitch = request.form['twitch']
            if request.form['steam']:
                this_project.steam = request.form['steam']
            if request.form['twitter']:
                this_project.twitter = request.form['twitter']

            file = request.files['file']
            if file and allowed_file(file.filename):
                filename = secure_filename(file.filename).split(".")
                cloudinary.uploader.upload(request.files['file'], public_id=filename[0])
                this_project.picture_name = filename[0]

            if request.form['youtube']:
                this_url = request.form['youtube']
                split_url = this_url.split("=")
                this_project.youtube_url = split_url[1]

            db.add(this_project)
            db.commit()

            description_text = request.form['description']
            this_text = description_text.split('\n')
            for i in this_text:
                this_paragraph = Paragraph(text=i, project_id=this_project.id, time_created=datetime.datetime.now())
                db.add(this_paragraph)
                db.commit()

            if this_user.website is None:
                this_user.website = this_project.website

            flash("New Project Created", "success")
            if this_project:
                return redirect(url_for('project', project_id=this_project.id))
            else:
                return redirect(url_for('profile'))
        else:
            return render_template('new_project.html', user=this_user, endorsements=endorse)
    else:
        flash("Please Log In", "danger")
        return redirect(url_for('assets'))
from database_setup import Base, Project, Property, User

engine = create_engine('sqlite:///propertieswithusers.db')
Base.metadata.bind = engine
DBSession = sessionmaker(bind=engine)
session = DBSession()

# Create dummy user
User1 = User(name="Robo Barista",
             email="*****@*****.**",
             picture='https://goo.gl/VzhNft')
session.add(User1)
session.commit()

# Residential Properties under various Projects
myFirstProject = Project(user_id=1, project_name="Sagari Apartments")
session.add(myFirstProject)
session.commit()

mySecondProject = Project(user_id=1, project_name="Goteti Apartments")
session.add(mySecondProject)
session.commit()

# Commercial Properties under various Projects
myThirdProject = Project(user_id=1, project_name="D Adress Mall")
session.add(myThirdProject)
session.commit()

myFourthProject = Project(user_id=1, project_name="Life Style")
session.add(myFourthProject)
session.commit()
示例#12
0
user3 = User(name="Dennis",email="*****@*****.**")
session.add(user3)
session.commit()

user4 = User(name="Arsene",email="*****@*****.**")
session.add(user4)
session.commit()

user5 = User(name="Jack",email="*****@*****.**")
session.add(user5)
session.commit()

projectitem1 = Project(project_url="frontend_url",
	project_description="This is the first project relating to the FrontEnd Stack",
	projectname_id="frontend",
	projectcategory_id="p1",
	author_id=1)
session.add(projectitem1)
session.commit()	

projectitem2 = Project(project_url="frontend_url",
	project_description="This is the second project relating to the FrontEnd Stack",
	projectname_id="frontend",
	projectcategory_id="p2",
	author_id=2)
session.add(projectitem2)
session.commit()	

projectitem3 = Project(project_url="frontend_url",
	project_description="This is the third project relating to the FrontEnd Stack",
示例#13
0
    'https://png.pngtree.com/element_pic/17/07/23/3e1a80864fe450b9312f5cb7cf486dcf.jpg'
)
session.add(User1)
session.commit()

# Projects in India

country1 = Country(user_id=1, name='India')

session.add(country1)
session.commit()

project1 = Project(
    user_id=1,
    name='Project1',
    description='this is a hrm project',
    number_of_members='60',
    category='HRMProject',
    country=country1,
)

session.add(project1)
session.commit()

project2 = Project(
    user_id=1,
    name='Project2',
    description='this is a fin project',
    number_of_members='100',
    category='FINProject',
    country=country1,
)
示例#14
0
# ***************************************************************************
# Projects for Woodturning***************************************************
category1 = Category(CategoryName="Woodturning",
                     CategoryDesc="Turning various wooden items on the lathe!",
                     CategoryPicture="cat_woodturning.jpg",
                     User=user1)

session.add(category1)
session.commit()

description = "Hard Maple and Purpleheart cup for holding pens and pencils."
dateAdd1 = datetime(2018, 10, 3, 10, 10, 10)
project1 = Project(ProjectName="Pencil Holder",
                   ProjectDesc=description,
                   DateAdd=dateAdd1,
                   DateEdit=dateAdd1,
                   Category=category1,
                   User=user1,
                   ProjectPicture="Pencil_Holder.jpg",
                   ProjectLocation="Detroit, MI")

session.add(project1)
session.commit()

# Projects for CNC***********************************************************
category2 = Category(CategoryName="CNC",
                     CategoryDesc="Projects created using a CNC router/laser!",
                     CategoryPicture="cat_CNC.jpg",
                     User=user1)

session.add(category2)
session.commit()