def get(self):
        if self.user:
            # skills
            skills = Skills.query(Skills.user == self.user).fetch()
            # recent projects
            recent = Projects.query(Projects.user == self.user).fetch(limit=5)
            # create dictionary to hold categories with their projects
            data = {}
            # holds the categories which are meant to be shown on homepage
            featured_categories = []
            categories = Categories.query(Categories.user == self.user).fetch()
            for i in categories:
                if (i.feature == True):
                    featured_categories.append(i)
                    data['{}'.format(i.name)] = Projects.query(
                        Projects.category_name == i.name
                        and Projects.feature == True
                        and Projects.user == self.user).fetch()

            self.render('welcome.html',
                        recent=recent,
                        data=data,
                        categories=featured_categories,
                        skills=skills,
                        user=self.user)
        else:
            self.redirect('/login')
Exemplo n.º 2
0
 def create_new_project(self, projects):
     wd = self.app.wd
     wd.find_element_by_xpath("//input[@value='Create New Project']").click()
     self.fill_in_form_project(Projects(name=projects.name, status=projects.status,
                                        view_state=projects.view_state))
     wd.find_element_by_xpath("//input[@value='Add Project']").click()
     if wd.find_elements_by_css_selector("body > div:nth-child(5) > table > tbody > tr:nth-child(1) > td"):
         self.manage_projects()
         wd.find_element_by_xpath("//input[@value='Create New Project']").click()
         self.fill_in_form_project(Projects(name=projects.name, status=projects.status,
             inherit_global=projects.inherit_global, view_state=projects.view_state))
         wd.find_element_by_xpath("//input[@value='Add Project']").click()
     self.open_home_page()
     self.project_cache = None
Exemplo n.º 3
0
 def get(self):
     projects = Projects.query(Projects.user == self.user).fetch()
     categories = Categories.query(Categories.user == self.user).fetch()
     skills = Skills.query(Skills.user == self.user).fetch()
     self.render('projects.html',
                 projects=projects,
                 categories=categories,
                 skills=skills)
Exemplo n.º 4
0
 def get(self, user_name):
     user_other = User.by_name(user_name)
     projects = Projects.query(Projects.user == user_other).fetch()
     categories = Categories.query(Categories.user == user_other).fetch()
     self.render('visitprojects.html',
                 projects=projects,
                 categories=categories,
                 user_other=user_other)
 def get(self, user_name):
     user_other = User.by_name(user_name)
     if user_other:
         other_projects = Projects.query(
             Projects.user.name == user_name).fetch()
         other_categories = Categories.query(
             Categories.user.name == user_name).fetch()
         recent_projects = Projects.query(
             Projects.user.name == user_name).fetch(limit=6)
         other_skills = Skills.query(Skills.user.name == user_name).fetch()
         self.render('visitmain.html',
                     recent_projects=recent_projects,
                     other_projects=other_projects,
                     other_categories=other_categories,
                     user_other=user_other,
                     other_skills=other_skills)
     else:
         self.render('errorpage.html',
                     error="Sorry, that user could not be found.")
    def get(self):
        if self.user:
            projects = Projects.query(Projects.user == self.user).fetch(
                limit=5)
            categories = Categories.query(Categories.user == self.user).fetch()
            skills = Skills.query(Skills.user == self.user).fetch()

            self.render('welcome.html',
                        projects=projects,
                        categories=categories,
                        skills=skills)
        else:
            self.redirect('/login')
Exemplo n.º 7
0
    def post(self):
        title = self.request.get("title")
        link = self.request.get("link")
        description = self.request.get("description")
        programming_language = self.request.get("programming_language")
        category = self.request.get("name_category")
        add_category = self.request.get("add_category")
        feature = self.request.get("p_feature")
        error = "Need Title, Link, and Description!"

        if self.user:
            if (title):
                p = Projects(parent=post_key(),
                             title=title,
                             link='[None]',
                             description='[None]',
                             user=self.user)
                if (link):
                    p.link = link
                if (description):
                    p.description = description
                if (programming_language):
                    p.programming_language = programming_language
                if (category):
                    p.category_name = category
                if (add_category):
                    c = Categories(name=add_category, user=self.user)
                    c.put()
                if (feature and feature == "true"):
                    p.feature = True
                else:
                    p.feature = False
                p.put()
                self.redirect('/main')
            else:
                self.redirect('/main')
        else:
            self.redirect('/login')
Exemplo n.º 8
0
    def post(self):
        name_category = self.request.get("name_c")

        if (name_category == 'all'):
            self.redirect('/projects')
        else:
            if (name_category):
                category = Categories.by_name(name_category)
            projects = Projects.query(Projects.category_name == name_category).fetch()
            categories = Categories.query(Categories.user == self.user).fetch()
            self.render('projects.html',
                        category_filter = category,
                        projects = projects,
                        categories = categories)
Exemplo n.º 9
0
def test_add_project(app):
    project_name = random_project_name("project", 13)
    add_project = Projects(name=project_name,
                           status='development',
                           view_state='public')
    app.mantis_projects.autorization()
    app.mantis_projects.manage_projects()
    old_list = app.mantis_projects.get_project_list()
    app.mantis_projects.create_new_project(add_project)
    new_list = app.mantis_projects.get_project_list()
    assert len(old_list) + 1 == len(new_list)
    old_list.append(add_project)
    assert sorted(old_list,
                  key=Projects.sorted_name) == sorted(new_list,
                                                      key=Projects.sorted_name)
    soap_projects = app.soap.get_list_from_soap("administrator", "root")
    assert len(soap_projects) == len(new_list)
Exemplo n.º 10
0
 def get_project_list(self, reset_cache=False):
     if reset_cache:
         self.project_cache = None
     if self.project_cache is None:
         wd = self.app.wd
         self.manage_projects()
         self.project_cache = []
         elements = wd.find_elements_by_xpath("/html/body/table[3]/tbody/tr")
         for element in elements:
             if element.get_attribute("class") not in ('', 'row-category'):
                 cells = element.find_elements_by_tag_name("td")
                 name = cells[0].text
                 status = cells[1].text
                 enabled = cells[2].text
                 view_state = cells[3].text
                 self.project_cache.append(Projects(name=name, status=status, enabled=enabled,
                                     view_state=view_state))
     return list(filter(None, self.project_cache))
Exemplo n.º 11
0
def predict():
    
    req=request.get_json()
    if ("params" in req):  
        data = req["params"]["data"]
        user_id = req["params"]["user_id"]
        project_id = req["params"]["project_id"]
        filename = req["params"]["filename"]
        if (user_id == None or project_id == None or filename == None):  return apierrors.NoData()
    else:
        return apierrors.NoData();

    P = Projects(user_id, project_id)
    project = P.read(id=project_id)
    P.addDataset(data)
    dataset = P.getDataset()
    # reshape the dataset  to a dataframe like object
    X = {}
    if(type(dataset[0]["data"]) == str): dataset[0]["data"] = json.loads(dataset[0]["data"])
    
    for k in dataset[0]["data"]:        
        X[k] = []    
    
    for i in dataset:   
        if(i["data"]=="data"): continue
        if(type(i["data"]) == str): obj=json.loads(i["data"])
        else: obj=json.loads(json.dumps(i["data"]))        
        for k in obj:
            X[k].append(obj[k])

    
    # convert the array to pandas dataframe
    rawX = pd.DataFrame(X)    
    X = preProcess(dataset=rawX)
    pkl_file = get_pickle(user_id + "/"+project_id+"/pickle.pkl")    
    if(pkl_file==None): return apierrors.ErrorMessage("No pickle file found, maybe you should train the model first")    
    model = pickle.load(pkl_file)    
    nbrs = model.fit(X)
    distances, indices = nbrs.kneighbors(X)      
    
    obj = [X[0]]

    # for i in X[0]:
    #     print(i)
    #     obj.append([i])
    
    data = rawX.to_json()
    indexes = pd.DataFrame(indices).to_json()        
    print(nbrs.kneighbors(obj))
    return '{ "data": ' + data + ', "indexes": '+indexes+'}'
    def post(self, user_name):
        user_other = User.by_name(user_name)
        if user_other:
            name_category = self.request.get("name_c")

            if (name_category == 'all'):
                self.redirect('/visit/projects/%s' % (user_other.name))
            else:
                if (name_category):
                    category = Categories.by_name(name_category)
                projects = Projects.query(
                    Projects.category_name == name_category).fetch()
                categories = Categories.query(
                    Categories.user == user_other).fetch()
                self.render('visitprojects.html',
                            category_filter=category,
                            user_other=user_other,
                            projects=projects,
                            categories=categories)
        else:
            self.render('errorpage.html',
                        error="Sorry, that information could not be found.")
Exemplo n.º 13
0
def predict():
    req = request.get_json()
    if ("params" in req):
        user_id = req["params"]["user_id"]
        project_id = req["params"]["project_id"]
        data = req["params"]["data"]
    else:
        return apierrors.ErrorMessage(
            "You need to specify parameters to load ")

    P = Projects(user_id, project_id)
    project = P.read(id=project_id)
    P.addDataset(data)
    dataset = P.getDataset()
    X = []
    keys = []

    for i in dataset:
        a = json.dumps(i["data"])
        b = json.loads(a)
        X.append(b)

        # X.append()

    X = pd.DataFrame(X)
    print(X.head())
    X = preProcess(dataset=X)
    pkl_file = get_pickle(user_id + "/" + project_id + "/pickle.pkl")
    model = pickle.load(pkl_file)
    db = model.fit(X)
    core_samples_mask = np.zeros_like(db.labels_, dtype=bool)
    core_samples_mask[db.core_sample_indices_] = True
    labels = db.labels_

    n_clusters_ = len(set(labels)) - (1 if -1 in labels else 0)

    resultObj = {
        "clusters": n_clusters_,
        "dataset": X.tolist(),
        "labels": labels.tolist()
    }
    # return json.dumps(resultObj)

    return json.dumps(resultObj)
Exemplo n.º 14
0
def predict():
    req = request.get_json()
    if "params" in req:        
        data = req["params"]["data"]
        user_id = req["params"]["user_id"]
        project_id = req["params"]["project_id"]
        filename = req["params"]["filename"]
    else:
        return apierrors.NoData()
    print("start")
    P = Projects(user_id, project_id)
    project = P.read(id=project_id)
    P.addDataset(data)
    dataset = P.getDataset()    
    # reshape the dataset  to a dataframe like object
    X = {}
    if(type(dataset[0]["data"]) == str): dataset[0]["data"] = json.loads(dataset[0]["data"])
    
    for k in dataset[0]["data"]:        
        X[k] = []    

    for i in dataset:               
        if(type(i["data"]) == str): obj=json.loads(i["data"])
        else: obj=json.loads(json.dumps(i["data"]))
        for k in obj:
            X[k].append(obj[k])
    # convert the array to pandas dataframe
    
    rawX = pd.DataFrame(X)    
    
    X = preProcess(dataset=rawX)
    
    pkl_file = get_pickle(user_id + "/"+project_id+"/pickle.pkl")    
    if(pkl_file==None): return apierrors.ErrorMessage("No pickle file found, maybe you should train the model first")    
    
    model = pickle.load(pkl_file)        
    obj = [X[0]]     
    labels = pd.DataFrame(model.predict(X)).to_json()
    return json.dumps({
        "dataset": json.loads(rawX.to_json()),
        "labels": json.loads(labels)
    })
Exemplo n.º 15
0
# -*- coding: utf-8 -*-