示例#1
0
def create_project_sample(customer_name, user_id=None):
    
    if not current_user.is_authenticated:
        if user_id is None:
            print('not logged in')
            return redirect(url_for('login'))

    if request.method == 'POST':

        dataset = [
                   {'name':'sample.csv', 'type':'Forecasting Timeseries Data', 'file_attributes':[0,0], 'datasetID':'sample.csv', 'status':'Active'}, 
                   {'name':'sample.csv', 'type':'Item Attributes', 'file_attributes':[0,0], 'datasetID':'sample1.csv', 'status':'Active'}, 
                  ]
        pname = customer_name
	#if pname is None or len(pname) == 0:
           # pname = "Sample"

        ptype = "Forecasting"
        project_id = int(str(uuid.uuid4().int)[:6])
        date = str(datetime.datetime.utcnow())

        #project_id, user_id, pname, ptype, dataset, date
        new_project = Project(project_id, user_id, pname, ptype, dataset, date)
        new_project.save_to_mongo()


        return redirect(url_for('project_dashboard', project_id=project_id))
示例#2
0
def create_project_sample(customer_name, user_id=None):
    """
    Creates a sample customer user via ADMIN dashboard
    Allows an ADMIN user to create sample customer 
    through its dashboard and set all DATA required
    AUTOMATICALLY. It created the user and saves all the files
    required in necessary order.\n\n
    method: POST\n
    POST: API usage, acts a api to login user\n\n

    Args:
        customer_name (str): name of the customer name need to be sent in url, like GET
        user_id (str): Id of the the user need to be sent in url, like GET (optional)
    
    Returns:
        redirect: url for the admin dashboard on success
    """

    if not current_user.is_authenticated:
        if user_id is None:
            print('not logged in')
            return redirect(url_for('login'))

    if request.method == 'POST':

        dataset = [
            {
                'name': 'sample.csv',
                'type': 'Forecasting Timeseries Data',
                'file_attributes': [0, 0],
                'datasetID': 'sample.csv',
                'status': 'Active'
            },
            {
                'name': 'sample.csv',
                'type': 'Item Attributes',
                'file_attributes': [0, 0],
                'datasetID': 'sample1.csv',
                'status': 'Active'
            },
        ]
        pname = customer_name
        #if pname is None or len(pname) == 0:
        # pname = "Sample"

        ptype = "Forecasting"
        project_id = int(str(uuid.uuid4().int)[:6])
        date = str(datetime.datetime.utcnow())

        #project_id, user_id, pname, ptype, dataset, date
        new_project = Project(project_id, user_id, pname, ptype, dataset, date)
        new_project.save_to_mongo()

        return redirect(url_for('project_dashboard', project_id=project_id))
示例#3
0
def create_project():

    if not current_user.is_authenticated:
        print('not logged in')
        return redirect(url_for('login'))

    data = Project.from_user(current_user.user_id)

    all_data = []
    html = None
    project_id = None
    titles = None

    if request.method == 'POST':
        f_1 = request.files['file_1']
        f_2 = request.files['file_2']

        filename_one = str(uuid.uuid4())[:8] + "." + f_1.filename.rsplit(
            '.', 1)[1].lower()
        if not f_2:
            f_2 = f_1

        filename_two = str(uuid.uuid4())[:8] + "." + f_2.filename.rsplit(
            '.', 1)[1].lower()
        f_1.save(app.config['UPLOAD_FOLDER'] + "dataset/" +
                 secure_filename(filename_one))
        f_2.save(app.config['UPLOAD_FOLDER'] + "dataset/" +
                 secure_filename(filename_two))

        dataset = [{
            'name': filename_one,
            'type': 'Forecasting Timeseries Data',
            'file_attributes': [0, 0],
            'datasetID': filename_one,
            'status': 'Active'
        }, {
            'name': filename_two,
            'type': 'Item Attributes',
            'file_attributes': [0, 0],
            'datasetID': filename_two,
            'status': 'Active'
        }]
        pname = request.form['pname']
        ptype = request.form['ptype']
        user_id = current_user.user_id
        project_id = int(str(uuid.uuid4().int)[:6])
        date = str(datetime.datetime.utcnow())

        #project_id, user_id, pname, ptype, dataset, date
        new_project = Project(project_id, user_id, pname, ptype, dataset, date)
        new_project.save_to_mongo()

        return redirect(url_for('project_dashboard', project_id=project_id))
示例#4
0
def create_project():
    """
    Create customer user via ADMIN dashboard
    Allows an ADMIN user to create customer 
    through its dashboard and set all DATA required
    MANUALLY. It created the user and saves all the files
    required in necessary order.\n\n
    
    method: POST\n
    POST: API usage, acts a api to craete customer user\n
    params should be in a FLASK FORM json format (Form data).\n\n

    Args:
        form_data: data retrived from Flask form from the frontend
        file_1: Data set for the user specifying feature file needed to for time series forecasting
        file_2: optional file for attributes 
    
    Returns:
        redirect: url for the newely creadted user or redirects to root.

    form_data = {
    'name': type=str
    'lname': type=str)
    'gender': type=str
    'phone': type=str
    'address': type=str
    'city': type=str
    'zipcode': type=str
    'state': type=str
    'username': type=str
    'password': type=str 
    'email': type=str 
    }

    file_1 = file upload from CSV
    file_2 = file upload from CSV optional
    """

    if not current_user.is_authenticated:
        print('not logged in')
        return redirect(url_for('login'))

    data = Project.from_user(current_user.user_id)

    all_data = []
    html = None
    project_id = None
    titles = None

    if request.method == 'POST':
        f_1 = request.files['file_1']
        f_2 = request.files['file_2']

        filename_one = str(uuid.uuid4())[:8] + "." + f_1.filename.rsplit(
            '.', 1)[1].lower()
        if not f_2:
            f_2 = f_1

        filename_two = str(uuid.uuid4())[:8] + "." + f_2.filename.rsplit(
            '.', 1)[1].lower()
        f_1.save(app.config['UPLOAD_FOLDER'] + "dataset/" +
                 secure_filename(filename_one))
        f_2.save(app.config['UPLOAD_FOLDER'] + "dataset/" +
                 secure_filename(filename_two))

        dataset = [{
            'name': filename_one,
            'type': 'Forecasting Timeseries Data',
            'file_attributes': [0, 0],
            'datasetID': filename_one,
            'status': 'Active'
        }, {
            'name': filename_two,
            'type': 'Item Attributes',
            'file_attributes': [0, 0],
            'datasetID': filename_two,
            'status': 'Active'
        }]
        pname = request.form['pname']
        ptype = request.form['ptype']
        user_id = current_user.user_id
        project_id = int(str(uuid.uuid4().int)[:6])
        date = str(datetime.datetime.utcnow())

        #project_id, user_id, pname, ptype, dataset, date
        new_project = Project(project_id, user_id, pname, ptype, dataset, date)
        new_project.save_to_mongo()

        return redirect(url_for('project_dashboard', project_id=project_id))