Beispiel #1
0
def create_sample_data():
    """creation of nodes and relationship between those"""
    # create skills
    python: Union[Skill, Any] = Skill(name="Python").save()
    fim_process = Skill(name="FIM Process").save()
    neo4j = Skill(name="neo4j").save()
    data_engineering = Skill(name="Data Engineering").save()
    data_visualization = Skill(name="Data Visualization").save()

    # create team members and connect to skill
    tom = TeamMember(first_name="Tom", last_name="Holiday").save()
    tom.skill.connect(python, {"year": 2019, "score": 4.0})
    tom.skill.connect(fim_process, {"year": 2019, "score": 5.0})
    tom.skill.connect(python, {"year": 2020, "score": 5.0})
    tom.skill.connect(fim_process, {"year": 2020, "score": 5.0})
    tran = TeamMember(first_name="Tran", last_name="Charismatic").save()
    tran.skill.connect(python, {"year": 2019, "score": 3.0})
    ron = TeamMember(first_name="Ron", last_name="Paradise").save()
    ron.skill.connect(neo4j, {"year": 2019, "score": 2.0})
    ron.skill.connect(python, {"year": 2019, "score": 3.0})
    ron.skill.connect(data_engineering, {"year": 2019, "score": 5.0})
    dev = TeamMember(first_name="Dev", last_name="Global").save()
    dev.skill.connect(data_engineering, {"year": 2019, "score": 4.0})
    dev.skill.connect(data_visualization, {"year": 2019, "score": 3.0})
    aqua = TeamMember(first_name="Aqua", last_name="Gloss").save()
    aqua.skill.connect(data_visualization, {"year": 2019, "score": 2.0})
    aqua.skill.connect(python, {"year": 2019, "score": 2.0})
    prem = TeamMember(first_name="Prem", last_name="Chopra").save()
    prem.skill.connect(fim_process, {"year": 2019, "score": 3.0})
    print("Created sample data ...")
Beispiel #2
0
def add_skills():
    name = request.get_json(force=True)['name']

    skill = Skill()
    skill.name = name

    db.session.add(skill)
    db.session.commit()
Beispiel #3
0
 def create(self, validated_data):
     skill = Skill(
         name=validated_data['name'],
         alias=validated_data['name'].lower(),
         active=validated_data['active']
     )
     skill.save()
     return skill
def create_skills(all_data):
    session = Session()
    for user in all_data:
        skills = user['skills']
        for skill in skills:
            Skill.create_if_not_exists(skill, session)

    session.commit()
    print('Created skills')
Beispiel #5
0
def resolve_create_skill(_, info, input):
    skill = Skill(**input)
    skill.id = str(uuid4())
    try:
        session.add(skill)
        session.commit()
    except Exception:
        session.rollback()
    return skill
Beispiel #6
0
def load_skills():
    # Loads skills
    skills = json.load(open('data/skills.json'))
    data = []
    for skill in skills:
        s = Skill(
            title=skill['title'],
            desc=skill['desc'])
        if 'links' in skill:
            s.links = skill['links']
        data.append(s)
    ndb.put_multi(data)
Beispiel #7
0
 def test_skill_model(self):
     load()
     skill = Skill(title='Python', desc='Cool',
                   links=['http://www.github.com/'])
     skill.approve()
     self.assertEquals(skill.approved, 1)
     skills = Skill.all()
     self.assertEquals(len(skills), 4)
     s_key = skill.put()
     skill.id = s_key.id()
     skill.put()
     Skill.get(skill.id)
     self.assertEquals(skill.id, s_key.id())
Beispiel #8
0
def create_skill():

	try:
		if 'skill_name' not in request.json or 'skill_type' not in request.json:
			return (jsonify("skill_name and skill_type must be included in the request"),400)
		elif type(request.json["skill_name"]) != str or type(request.json["skill_type"]) != str:
			return (jsonify("skill_name and skill_type need to be in string format"),400)
		else:
			skill_name = request.json["skill_name"]
			skill_type = request.json["skill_type"]
		
		temp_list = ["Hard skill","Soft skill"]
		
		if skill_type not in temp_list:
			return(jsonify("Skill_type only accepts values 'Hard skill' or 'Soft skill', case sensitive"),400)
		else:
			valid_skill_name = Skill.query.filter_by(skill_name=skill_name).first()

			if valid_skill_name is not None:
				return(jsonify("The skill you are trying to add already exists"),400)
			else:
				new_entry = Skill(skill_name=skill_name,skill_type=skill_type)
				db.session.add(new_entry)
				db.session.commit()
		
			return (jsonify("{} has been added to the database".format(new_entry.skill_name)),200)
	
	except Exception as e:
		return(str(e),400)
Beispiel #9
0
def parse_skills(skills_json):
    skill_objs = []
    for skill in skills_json:
        # import ipdb; ipdb.set_trace()# BREAKPOINT)
        skill_objs.append(Skill(id=skill['id'], name=skill['name']))

    return skill_objs
Beispiel #10
0
def retrieve_skills():
    junctions = list(
        map(lambda junction: junction.represent_as_skill(),
            Junction.retrieve_all()))

    try:
        min_rating = float(request.args.get('min_rating') or 0)
        max_rating = float(request.args.get('max_rating') or 10)
        min_frequency = float(request.args.get('min_frequency') or 0)
        max_frequency = float(request.args.get('max_frequency') or -1)
    except ValueError:
        abort(400)

    skills = Skill.retrieve_all()
    stats = []
    for skill in skills:
        stats.append({
            "average": average_skill_rating(skill['id']),
            "count": users_with_skill(skill['id']),
            "name": skill['name'],
            "id": skill['id']
        })

    print(stats)

    return jsonify(
        list(
            filter(
                lambda stat: filter_stats(stat, min_rating, max_rating,
                                          min_frequency, max_frequency),
                stats)))
Beispiel #11
0
def skill():
    Entry = namedtuple('Entry', ['skill_name'])
    skill_value = Skill.load(current_user.id)
    if skill_value.skill_list:
        data = {'skill_list': []}
        for skill_name in skill_value.skill_list:
            data['skill_list'].append(Entry(skill_name))
        form = SkillListForm(data=data)
    else:
        form = SkillListForm()
    if form.validate_on_submit():
        if form.add.data:
            if bool(form.new_skill.data):
                skill_value.add(form.new_skill.data)
                flash('Skill added', 'success')
                commit()
            else:
                flash('Empty skill', 'danger')
            return redirect(url_for('skill.skill'))
        else:
            for index in range(len(form.skill_list)):
                if form.skill_list[index].save.data:
                    if bool(form.skill_list[index].skill_name.data):
                        skill_value.update(index, form.skill_list[index].skill_name.data)
                        commit()
                        flash('Updated successfully', 'success')
                    else:
                        flash('Empty skill', 'danger')
                    return redirect(url_for('skill.skill'))
                if form.skill_list[index].delete.data:
                    skill_value.delete(index)
                    commit()
                    flash('Deleted successfully', 'success')
                    return redirect(url_for('skill.skill'))
    return render_template('skill.html', form=form)
Beispiel #12
0
def create_embed(author, level, ascendency_name, class_name,
                 main_skill: Skill):
    """
    Create the basic embed we add information to
    :param author: of the parsed message - str
    :param tree: enclosed tree information
    :param level: of the build
    :param ascendency_name: to display
    :param class_name: to display if no ascendency has been chosen
    :param main_skill: main skill to display
    :return (Embed): the created Embed with the options set.
    """
    embed = Embed(title='tmp', color=config.color)
    gem_name = "Undefined"
    if main_skill:
        main_gem = main_skill.get_selected()
        if isinstance(main_gem, Gem):
            gem_name = main_gem.name

    if ascendency_name or class_name:
        url = 'https://raw.githubusercontent.com/FWidm/discord-pob/master/_img/' + (
            ascendency_name
            if ascendency_name != "None" else class_name) + '.png'
        embed.set_thumbnail(url=url)
        # url='http://web.poecdn.com/image/Art/2DArt/SkillIcons/passives/Ascendants/' + ascendency_name + '.png')

    embed.title = "{gem} - {char} (Lvl: {level})".format(
        char=class_name
        if ascendency_name.lower() == 'none' else ascendency_name,
        gem=gem_name,
        level=level)
    if author:
        embed.title += " by: " + author.name
    return embed
Beispiel #13
0
  def post(self):
    user = self.user_model
    employer = cgi.escape(self.request.get('employer')).strip()
    profession = cgi.escape(self.request.get('job')).strip()
    field = cgi.escape(self.request.get('field')).strip()
    tools = cgi.escape(self.request.get('tools'))
    specialty = cgi.escape(self.request.get('specialty')).strip()
    tool_list = tools.split(',')
    new_skills_count = 0 #for field and specialty
    for i in tool_list:
      if i != " ":
        i = i.lower().strip()
        skill_query = Skill.query(Skill.name == i).get()
        #don't add duplicate skill
        if skill_query == None:
          new_skill = Skill(name=i)
          new_skill.put()
          user.skills.append(new_skill.key)
          user.subscriptions.append(new_skill.name.replace(" ",""))
        else:
          user.skills.append(skill_query.key)
          user.subscriptions.append(skill_query.name.replace(" ", ""))
        new_skills_count += 1
    
    # Add new User Info
    if field != "":
      field_skill = Skill(name=field.lower())
      field_skill.put()
      user.skills.append(field_skill.key)
      new_skills_count += 1
    if specialty != "":
      specialty_skill = Skill(name=specialty.lower())
      specialty_skill.put()
      user.skills.append(specialty_skill.key)
      new_skills_count += 1
    if employer != " ":
      user.employer = employer
      user.lower_employer = employer.lower()
    if profession != " ":
      user.profession = profession
      user.lower_profession = profession.lower()

    user.skills_count += new_skills_count
    user.subscriptions.append(employer.lower().replace(" ", ""))
    user.put()
Beispiel #14
0
  def get(self):
    user = self.user_model
    search = cgi.escape(self.request.get('search'))
    #TODO normalize names in User model to ignore case
    search_list = search.split(',')
    results = []
    # For recuiters' advance search #
    jobs = []
    employers = []
    skills = []
    names = []
    forum_query = []
    search_type = " "
    if user.account_type == "Recruiter":
      search_type = "advanced"

    #Search Algorithm
    for search_string in search_list:
      search_string = search_string.strip(' ').lower()
      if "@" in search_string:
        q = User.query(User.email_address == search_string)
        if q:
          results.append(q.get())
      elif " " in search_string:
        person = search_string.split(' ')
        first_name = person[0]
        last_name = person[1]
        full_name = User.query(ndb.OR(User.lower_profession == search_string, 
          User.lower_employer == search_string, ndb.AND(User.lower_first_name == first_name, User.lower_last_name == last_name))).fetch()
        if search_type is "advanced":
          profession_name = User.query(User.lower_profession == search_string).fetch()
          employer_name = User.query(User.lower_employer == search_string).fetch()
          jobs.extend(profession_name)
          employers.extend(employer_name) 
        if full_name:
          results.extend(full_name)
      else:
        if search_type is "advanced":
          jobs_list = User.query(ndb.OR(User.lower_profession == search_string, User.profession == search_string)).fetch()
          employers_list = User.query(ndb.OR(User.lower_employer == search_string, User.employer == search_string)).fetch()
          jobs.extend(jobs_list)
          employers.extend(employers_list)
          # Get Users with skills
          skill_query = Skill.query(Skill.name == search_string).get()
          if skill_query != None:
            users_with_skills = []
            # TODO limit fetch returns entities
            skilled_users = User.query(User.skills == skill_query.key).fetch()
            skills.extend(skilled_users)
            results.extend(skilled_users)
          forum_query = Forum.query(Forum.name == search_string).get()

        name_list = User.query(ndb.OR(User.username == search_string, User.lower_first_name == search_string, User.lower_last_name == search_string, 
          User.lower_employer == search_string, User.lower_profession == search_string)).fetch()
        results.extend(name_list)
      self.response.out.write(template.render('views/search.html', {'results':results, 'users':name_list, 'employers': employers,
        'jobs': jobs, 'search_string':search_string, 'viewer':user, 'skills':skills, 'forums':forum_query}))
Beispiel #15
0
  def get(self):
    user = self.user_model
    search = cgi.escape(self.request.get('search'))
    #TODO normalize names in User model to ignore case
    search_list = search.split(',')
    results = []
    # For recuiters' advance search #
    jobs = []
    employers = []
    skills = []
    names = []
    forum_query = []
    search_type = " "
    if user.account_type == "Recruiter":
      search_type = "advanced"

    #Search Algorithm
    for search_string in search_list:
      search_string = search_string.strip(' ').lower()
      if "@" in search_string:
        q = User.query(User.email_address == search_string)
        if q:
          results.append(q.get())
      elif " " in search_string:
        person = search_string.split(' ')
        first_name = person[0]
        last_name = person[1]
        full_name = User.query(ndb.OR(User.lower_profession == search_string, 
          User.lower_employer == search_string, ndb.AND(User.lower_first_name == first_name, User.lower_last_name == last_name))).fetch()
        if search_type is "advanced":
          profession_name = User.query(User.lower_profession == search_string).fetch()
          employer_name = User.query(User.lower_employer == search_string).fetch()
          jobs.extend(profession_name)
          employers.extend(employer_name) 
        if full_name:
          results.extend(full_name)
      else:
        if search_type is "advanced":
          jobs_list = User.query(ndb.OR(User.lower_profession == search_string, User.profession == search_string)).fetch()
          employers_list = User.query(ndb.OR(User.lower_employer == search_string, User.employer == search_string)).fetch()
          jobs.extend(jobs_list)
          employers.extend(employers_list)
          # Get Users with skills
          skill_query = Skill.query(Skill.name == search_string).get()
          if skill_query != None:
            users_with_skills = []
            # TODO limit fetch returns entities
            skilled_users = User.query(User.skills == skill_query.key).fetch()
            skills.extend(skilled_users)
            results.extend(skilled_users)
          forum_query = Forum.query(Forum.name == search_string).get()

        name_list = User.query(ndb.OR(User.username == search_string, User.lower_first_name == search_string, User.lower_last_name == search_string, 
          User.lower_employer == search_string, User.lower_profession == search_string)).fetch()
        results.extend(name_list)
      self.response.out.write(template.render('views/search.html', {'results':results, 'users':name_list, 'employers': employers,
        'jobs': jobs, 'search_string':search_string, 'viewer':user, 'skills':skills, 'forums':forum_query}))
Beispiel #16
0
    def restore_object(self, attrs, instance=None):
        classgroup = attrs.get('classgroup')
        name = attrs.get('name')

        attributes = ['grading_policy']
        user = self.context['request'].user

        if instance is None:
            instance = Skill(classgroup=classgroup, name=alphanumeric_name(name), display_name=name)
            instance.save()
        else:
            if not ClassGroupPermissions.is_teacher(classgroup, user):
                raise serializers.ValidationError("You do not have permission to modify this skill.")
            instance.name = alphanumeric_name(name)
            instance.display_name = name

        resources = self.context['request'].DATA.get('resources')
        if isinstance(resources, basestring):
            resources = [resources]
        if resources is not None:
            resources = [str(r).strip() for r in resources]
        else:
            resources = []

        skill_resources = []
        for (i, r) in enumerate(resources):
            if len(r) < 1:
                continue
            resource = Resource.objects.get(display_name=r, classgroup=classgroup)
            skill_resource, created = SkillResource.objects.get_or_create(
                resource=resource,
                skill=instance
            )
            skill_resource.priority = i
            skill_resource.save()
            skill_resources.append(skill_resource)

        for s in SkillResource.objects.filter(skill=instance):
            if s not in skill_resources:
                s.delete()

        instance = set_attributes(attributes, attrs, instance)
        return instance
Beispiel #17
0
def save_skill(request):
    data = request.json
    skill = Skill({
        "name": data["name"],
        "icon": data["icon"],
        "type": data["type"]
    })
    skill.m.save()
    skill = decode.decode_object_id(skill)
    return skill
Beispiel #18
0
 def post(self):
   user = self.user_model
   skills = cgi.escape(self.request.get('skills'))
   new_skills = skills.split(',')
   new_skills = [skill for skill in new_skills if len(skill) >0]
   to_add_skills = []
   to_add_subscriptions = []
   for i in new_skills:
     i = i.lower().strip()
     skill_query = Skill.query(Skill.name == i).get()
     if skill_query == None: # Not in skills database
       new_skill = Skill(name=i)
       new_skill_key = new_skill.put()
       print "New Skill Added to Database"
       print new_skill.name
       to_add_subscriptions.append(new_skill.name.replace(" ", ""))
       to_add_skills.append(new_skill_key)
     else: # In skills database
       # Search user skills to see if exists
       flag = " "
       for skill in user.skills:
         skill = skill.get()
         if skill.name == i:
           flag = "exists"
           print skill.name
           print "already exists in user skills"
           break
       if flag != "exists":
         new_skill = Skill.query(Skill.name == i).get()
         print("Added to user skills:")
         print(new_skill.name)
         to_add_subscriptions.append(new_skill.name.replace(" ", ""))
         to_add_skills.append(new_skill.key)
     
     # Add to user skills
   user.skills.extend(to_add_skills)
   user.skills_count += len(to_add_skills)
     # Add to user subscriptions
   user.subscriptions.extend(to_add_subscriptions)
   time.sleep(1)
   user.put()
Beispiel #19
0
 def post(self):
   user = self.user_model
   skills = cgi.escape(self.request.get('skills'))
   new_skills = skills.split(',')
   new_skills = [skill for skill in new_skills if len(skill) >0]
   to_add_skills = []
   to_add_subscriptions = []
   for i in new_skills:
     i = i.lower().strip()
     skill_query = Skill.query(Skill.name == i).get()
     if skill_query == None: # Not in skills database
       new_skill = Skill(name=i)
       new_skill_key = new_skill.put()
       print "New Skill Added to Database"
       print new_skill.name
       to_add_subscriptions.append(new_skill.name.replace(" ", ""))
       to_add_skills.append(new_skill_key)
     else: # In skills database
       # Search user skills to see if exists
       flag = " "
       for skill in user.skills:
         skill = skill.get()
         if skill.name == i:
           flag = "exists"
           print skill.name
           print "already exists in user skills"
           break
       if flag != "exists":
         new_skill = Skill.query(Skill.name == i).get()
         print("Added to user skills:")
         print(new_skill.name)
         to_add_subscriptions.append(new_skill.name.replace(" ", ""))
         to_add_skills.append(new_skill.key)
     
     # Add to user skills
   user.skills.extend(to_add_skills)
   user.skills_count += len(to_add_skills)
     # Add to user subscriptions
   user.subscriptions.extend(to_add_subscriptions)
   time.sleep(1)
   user.put()
Beispiel #20
0
def add_skill():
    if session['is_admin']:
        form = AddSkill()
        if form.validate_on_submit():
            skill_name = form.skill_name.data
            new_skill = Skill(skill_name)
            db.session.add(new_skill)
            db.session.commit()
            return redirect(url_for('list_skill'))
        return render_template('skill/addSkill.html', form=form)
    else:
        abort(404, description="You dont have access to this URL.")
Beispiel #21
0
def sample_describe_graph():
    """this demonstrates use of cypher query and interpretation of result returned from the query"""
    rows, cols = db.cypher_query(
        "MATCH (t:TeamMember)-[p:PROFICIENCY_FOR]-(s:Skill) RETURN t, p, s")
    # cols {0: TeamMember, 1: Proficiency, 2: Skill}
    for r in rows:
        team_member = TeamMember.inflate(r[0])
        proficiency = ProficiencyRel.inflate(r[1])
        skill = Skill.inflate(r[2])
        print(
            f"Team member {team_member.name} is proficient in skill {skill.name} with a score {proficiency.score} "
            f"in year {proficiency.year}\n")
Beispiel #22
0
def save_skill():
    try:
        cat_id = request.form['cat_id']
        title = request.form['title']
        # saving skill in db
        skill = Skill(cat_id, title)
        db.session.add(skill)
        db.session.commit()
    except Exception as exp:
        print "save_skill() :: Got Excetion: %s" % exp
        print(traceback.format_exc())
    return "Save Skill"
Beispiel #23
0
def handle_skill():
    """
    Create person and retrieve all persons
    """
    # POST request
   
    body = request.get_json()
    if body is None:
        raise APIException("You need to specify the request body as a json object", status_code=400)    
    skill1 = Skill(skill_type=body['skill_type'], user_id=body['user_id'])
    db.session.add(skill1)
    db.session.commit()
    return "ok", 200
Beispiel #24
0
def sample_queries():
    """sample queries, using both techniques provided by neomodel and cypher query"""

    # use object graph mapping (OGM) to query for information
    print(f"Skill Python: {Skill.nodes.get_or_none(name='Python')}")
    print(
        f"Skill Java that doesn't exist: {Skill.nodes.get_or_none(name='Java')}"
    )
    print("All team members name that starts with T:\n")
    team_members = TeamMember.nodes.filter(Q(first_name__startswith="T"))
    for n in team_members:
        print(f"\tTeam member: {n}\n")

    print(
        "All team members name that starts with T with proficiencies more than 3 in:\n"
    )
    excellencies = team_members.skill.match(score__gt=4.0)
    for ex in excellencies:
        print(f"\t Skills: {ex}\n")

    # use cypher queries
    print("Current graph description:")
    sample_describe_graph()

    print(
        "The skills in which team member first name starting with T has score more than 3 in any year"
    )
    rows, cols = db.cypher_query(
        "MATCH(t: TeamMember)-[p: PROFICIENCY_FOR]-(s:Skill) "
        "WHERE t.first_name STARTS WITH 'T' AND p.score > 3.0 "
        "RETURN DISTINCT (s)")
    # cols: {0: Skill}
    for r in rows:
        skill = Skill.inflate(r[0])
        print(f"Skill name {skill.name}")

    print(
        "For each of the available skills, find out the list of team members who has proficiency in it\n"
    )
    skills = Skill.nodes.all()
    for skill in skills:
        rows, cols = db.cypher_query(
            "MATCH (s:Skill)-[p:PROFICIENCY_FOR]-(t:TeamMember) "
            "WHERE s.name = $name RETURN DISTINCT (t)",
            params={"name": skill.name})
        print(f"\nSkill name: {skill.name}")
        for r in rows:
            team_member = TeamMember.inflate(r[0])  # cols: {0: TeamMember}
            print(f"Team member name {team_member.name}")
    print("Queried sample queries ...")
Beispiel #25
0
    def post_new_skill(jwt):
        try:
            # Get request data
            req_data = request.get_json()
            name = req_data.get('name')
            description = req_data.get('description', None)
            
            # Create new Skill instance
            new_skill = Skill(
                name = name,
                description = description
            )

            # Create new entry in database
            new_skill.insert()
            
            return jsonify({
                'success':True,
                'skill': new_skill.format()
            })
        except:
            db.session.rollback()
            abort(422)
Beispiel #26
0
def read_skill_csv():
    import csv
    with open('skill.csv', newline='') as csvfile:
        spamreader = csv.DictReader(csvfile)
        for row in spamreader:
            icon = get_skill_icon(row['Name'], row['Grade Value'],
                                  row['Type 1'], row['Float Value 1'])
            name = row['Name']
            name_kr = row['NameKr']
            description = row['Description']
            condition = row['Condition']
            if icon[0] > -1 or icon[1] > -1:
                icon_uri = f"i_skill{icon[0]}_{icon[1]}.png"
                skill = Skill(name, name_kr, description, condition, icon_uri)
                db_session.add(skill)
    db_session.commit()
Beispiel #27
0
def get_or_make_skill():
    if request.method == "GET":
        skills = session.query(Skill).all()
        if len(skills) == 0:
            return "No skills added yet, how sad!"
        return jsonify(skills=[skill.serialize for skill in skills])

    elif request.method == "POST":
        if request.json.get('name'):
            name = request.json.get('name').lower().strip()
        if request.json.get('level'):
            level = request.json.get('level')
        skill = Skill(name=name, level=level)
        session.add(skill)
        session.commit()
        return jsonify(skill.serialize), 201
Beispiel #28
0
def parse_teams(teams_json, session):
    team_objs = []
    for team in teams_json:
        new_team = Team(name=team['name'],
            idea_description=team['idea_description'], repository=team['repository'],
            need_more_members=team['need_more_members'], room=team['room'],
            place=team['place'])
        if team['technologies_full']:
            for skill in team['technologies_full']:
                try:
                    skill = session.query(Skill).filter(Skill.name == skill['name']).one()
                    # print(skill)
                    new_team.skill.append(skill)
                except Exception:
                    new_team.skill = [Skill(name=skill['name'])]
        team_objs.append(new_team)

    return team_objs
Beispiel #29
0
 def parse_skills(self, xml_skills):
     """
     Parse all active skill setups from the given xml
     :param xml_skills: root node containing the skills
     :return: list of skills
     """
     skills = []
     # parse skills and the supported gems
     for skill in xml_skills:
         gems = []
         for gem in skill:
             gems.append(
                 Gem(Parser.get_attrib_if_exists(gem, 'skillId'),
                     gem.attrib['nameSpec'], gem.attrib['level'],
                     gem.attrib['quality'],
                     Parser.get_attrib_if_exists(gem, 'skillPart'),
                     gem.attrib['enabled']))
         slot = Parser.get_attrib_if_exists(skill, 'slot')
         if slot:
             pass
         skills.append(Skill(gems, skill.attrib['mainActiveSkill'], slot))
     return skills
Beispiel #30
0
    def restore_object(self, attrs, instance=None):
        classgroup = attrs.get('classgroup')
        name = attrs.get('name')

        attributes = ['grading_policy']
        user = self.context['request'].user

        if instance is None:
            instance = Skill(classgroup=classgroup,
                             name=alphanumeric_name(name),
                             display_name=name)
            instance.save()
        else:
            if not ClassGroupPermissions.is_teacher(classgroup, user):
                raise serializers.ValidationError(
                    "You do not have permission to modify this skill.")
            instance.name = alphanumeric_name(name)
            instance.display_name = name

        resources = self.context['request'].DATA.get('resources')
        if isinstance(resources, basestring):
            resources = [resources]
        if resources is not None:
            resources = [str(r).strip() for r in resources]
        else:
            resources = []

        skill_resources = []
        for (i, r) in enumerate(resources):
            if len(r) < 1:
                continue
            resource = Resource.objects.get(display_name=r,
                                            classgroup=classgroup)
            skill_resource, created = SkillResource.objects.get_or_create(
                resource=resource, skill=instance)
            skill_resource.priority = i
            skill_resource.save()
            skill_resources.append(skill_resource)

        for s in SkillResource.objects.filter(skill=instance):
            if s not in skill_resources:
                s.delete()

        instance = set_attributes(attributes, attrs, instance)
        return instance
Beispiel #31
0
    def parse(self, response):
        for hero in response.xpath(
                '//body//span[@class="character_icon"]/a/@href'):
            yield response.follow(
                'http://dota.wikia.com' + str(hero.extract()), self.parse)
            # yield {'heroe': 'http://dota.wikia.com' + str(hero.extract())}

        names = []
        lore = ''
        for skill in response.xpath('//body//div[@title="Dota 2"]/table/tr'):
            skill_names = skill.xpath('//td[1]/b/text()')
            for name in skill_names.extract():
                if 'Ability Name' not in name and name not in names:
                    names.append(name)

        descs = response.xpath(
            '//body//div[@title="Dota 2"]/table/tr/td[2]').extract()[1:]

        descs = [re.sub('<.*?>', '', x) for x in descs]
        self.log(descs)

        for lore_found in response.xpath('//body//div[@title="Lore"]'):
            value = lore_found.xpath('//p[2]').extract()
            lore = ' '.join(value).strip().replace('  ', '').replace('\n', '')
            if len(lore) < 20:
                value = lore_found.xpath('//p[3]').extract()
                lore = ' '.join(value).strip().replace('  ',
                                                       '').replace('\n', '')
            lore = re.sub('<.*?>', '', lore)

        hero_type = response.xpath(
            '//body//tr[contains(td, " Attributes")]').extract()[0]
        if 'Agility' in hero_type:
            hero_type = 'Agility'
        if 'Intelligence' in hero_type:
            hero_type = 'Intelligence'
        if 'Strength' in hero_type:
            hero_type = 'Strength'

        hero_name = response.url.split('/')[-1]

        hero = Hero()
        hero.lore = lore
        hero.name = hero_name
        hero.type = hero_type
        session.add(hero)
        session.commit()

        mongo_skills = []
        mongo_hero = {'lore': lore, 'name': hero_name, 'type': hero_type}

        i = 0
        for name in names:
            db_skill = Skill()
            db_skill.name = name
            db_skill.description = descs[i]
            db_skill.hero_id = hero.id
            session.add(db_skill)
            mongo_skills.append({
                'name': name,
                'description': descs[i],
            })
            i += 1

        mongo_hero['skills'] = mongo_skills
        heroes.insert_one(mongo_hero)

        session.commit()

        session.close()
Beispiel #32
0
  def post(self):
    user = self.user_model
    employer = cgi.escape(self.request.get('employer')).strip()
    profession = cgi.escape(self.request.get('job')).strip()
    field = cgi.escape(self.request.get('field')).strip()
    tools = cgi.escape(self.request.get('tools'))
    specialty = cgi.escape(self.request.get('specialty')).strip()
    tool_list = tools.split(',')
    new_skills_count = 0 #for field and specialty
    for i in tool_list:
      if i != " ":
        i = i.lower().strip()
        skill_query = Skill.query(Skill.name == i).get()
        #don't add duplicate skill
        if skill_query == None:
          new_skill = Skill(name=i)
          new_skill.put()
          user.skills.append(new_skill.key)
          user.subscriptions.append(new_skill.name.replace(" ",""))
        else:
          user.skills.append(skill_query.key)
          user.subscriptions.append(skill_query.name.replace(" ", ""))
        new_skills_count += 1
    
    # Add new User Info
    if field != "":
      field_skill = Skill(name=field.lower())
      field_skill.put()
      user.skills.append(field_skill.key)
      new_skills_count += 1
    if specialty != "":
      specialty_skill = Skill(name=specialty.lower())
      specialty_skill.put()
      user.skills.append(specialty_skill.key)
      new_skills_count += 1
    if employer != " ":
      user.employer = employer
      user.lower_employer = employer.lower()
    if profession != " ":
      user.profession = profession
      user.lower_profession = profession.lower()

    user.skills_count += new_skills_count
    user.subscriptions.append(employer.lower().replace(" ", ""))
    user.put()
from models import db, Task, Member, Skill
from task import app
# if "createdb" in sys.argv:
with app.app_context():
    db.create_all()
print("Database created!")

# elif "seeddb" in sys.argv:
with app.app_context():

    s1 = Skill(name="python", level=5)
    db.session.add(s1)
    s2 = Skill(name="finance", level=2)
    db.session.add(s2)
    s3 = Skill(name="sql", level=4)
    db.session.add(s3)
    s4 = Skill(name="critical thinking", level=3)
    db.session.add(s4)
    s5 = Skill(name="react", level=4)
    db.session.add(s5)
    s6 = Skill(name="scrum master", level=5)
    db.session.add(s6)
    s7 = Skill(name="sap consulting", level=5)
    db.session.add(s7)
    s8 = Skill(name="abap", level=5)
    db.session.add(s8)

    t1 = Task(name="Create Git", desc="We need to create a microservice for calulating the amount of materials that we will have to use in production. We have to use cloud environment for this task. It can use MachineLearning algorithms to utilize our past data. While working on this service we should focus on high-availability.", status="OPEN")
    db.session.add(t1)
    t2 = Task(name="Create UI", desc="Frontend with buttons", status="DONE")
    db.session.add(t2)
Beispiel #34
0
from sqlalchemy.orm import sessionmaker
from models import Base, Skill, Person
import json

engine = create_engine('sqlite://')
Session = sessionmaker(bind=engine)
session = Session()

# Setup of in memory database, from data.json if tables doesn´t exist
if not engine.dialect.has_table(engine.connect(), "skills"):
    Base.metadata.create_all(bind=engine)
    data = json.load(open('../datasource/data.json'))

    skills = data['skills']
    for skill in skills:
        new_skill = Skill(**skill)
        session.add(new_skill)
        session.commit()

    persons = data['persons']
    for person in persons:
        friends = []
        skills = []
        if 'friends' in person:
            person_ids = person.pop('friends')
            friends = session.query(Person).filter(
                Person.id.in_(person_ids)).all()
        if 'skills' in person:
            skill_ids = person.pop('skills')
            skills = session.query(Skill).filter(Skill.id.in_(skill_ids)).all()
Beispiel #35
0
 def test_delete_skill(self):
     skill = Skill(title='foo').put()
     s = Skill.get(skill.id())
     s.enabled = False
     s.put()
     self.assertEquals(0, len(Skill.all()))
Beispiel #36
0
from datetime import date

from models import Skill


web_engineering = Skill(
    'Web Engineering',
    'Django',
    'Angular',
    'Rails',
    'Ractive',
    'Chef',
    'Jenkins',
    'AWS',
    'Protractor'
)

print web_engineering.render()
Beispiel #37
0
 def test_skills_handler(self):
     load()
     response = self.testapp.get('/skills')
     self.assertEquals(response.status_int, 200)
     self.assertEquals(response.content_type, 'application/json')
     data = json.loads(response.normal_body)
     self.assertEquals(4, len(data))
     # Approve skill
     skill = Skill(title="Math").put()
     response = self.testapp.post_json('/skills/approve/',
                                       {'_id': skill.id()})
     self.assertEquals(response.status_int, 201)
     self.assertEquals(Skill.get(skill.id()).approved, 1)
     # Create skill
     before = len(Skill.all())
     post_data = {'action': 'new',
                  'data': {'title': 'Python',
                           'desc': 'Love it!',
                           'links': [{'url': 'http://www.github.com',
                                      'title': 'My Github'}]}}
     response = self.testapp.post_json('/skills', post_data)
     self.assertEquals(response.status_int, 201)
     self.assertEquals(response.content_type, 'application/json')
     self.assertEquals(before + 1, len(Skill.all()))
     # Remove skill
     before = len(Skill.all())
     response = self.testapp.post_json('/skills',
                                       {'_id': skill.id(),
                                        'action': 'delete'})
     self.assertEquals(response.status_int, 200)
     self.assertEquals(before - 1, len(Skill.all()))
     # Updte skill
     links_before = len(Link.query().fetch())
     skill = Skill(title='Foo', desc='Bar').put()
     post_data = {'action': 'update',
                  'data': {'_id': skill.id(),
                           'title': 'Noob',
                           'desc': 'Noob!',
                           'links': [{'url': 'http://www.noob.com',
                                      'title': 'Noob Com'}]}}
     response = self.testapp.post_json('/skills', post_data)
     self.assertEquals(200, response.status_int)
     self.assertEquals(links_before + 1, len(Link.query().fetch()),
                       msg="Should create new link.")
     skill = Skill.get(skill.id())
     self.assertEquals(len(skill.links), 1)
     self.assertEquals(skill.title, 'Noob')
Beispiel #38
0
keywords = [
    "python", "javascript", "html", "css", "ruby", "bash", "linux", "unix",
    "rest", "restful", "api", "aws", "cloud", "svn", "git", "junit", "testng",
    "java", "php", "agile", "scrum", "nosql", "mysql", "postgresdb",
    "postgres", "shell", "scripting", "mongodb", "puppet", "chef", "ansible",
    "nagios", "sumo", "nginx", "haproxy", "docker", "automation", "jvm",
    "scikit-learn", "tensorflow", "vue", "react", "angular", "webpack",
    "drupal", "gulp", "es6", "jquery", "sass", "scss", "less", "nodejs",
    "node.js", "graphql", "postgresql", "db2", "sql", "spring",
    "microservices", "kubernates", "swagger", "hadoop", "ci/cd", "django",
    "elasticsearch", "redis", "c++", "c", "hive", "spark", "apache", "mesos",
    "gcp", "jenkins", "azure", "allcloud", "amqp", "gcp", "objective-c",
    "kotlin"
    "kafka", "jira", "cassandra", "containers", "oop", "redis", "memcached",
    "redux", "bigquery", "bigtable", "hbase", "ec2", "s3", "gradle", ".net",
    "riak", "shell", "hudson", "maven", "j2ee", "oracle", "swarm", "sysbase",
    "dynamodb", "neo4", "allcloud", "grunt", "gulp", "apex", "rails", "mongo",
    "apis", "html5", "css3", "rails", "scala", "rasa", "soa", "soap",
    "microservices", "storm", "flink", "gitlab", "ajax", "micro-services",
    "oop", "saas", "struts", "jsp", "freemarker", "hibernate", "rlak",
    "solidity", "heroku", "ecs", "gce", "scripting", "perl", "c#", "golang",
    "xml", "newrelic", "grafana", "helm", "polymer", "closure", "backbone",
    "atlassian", "angularjs", "flask", "scikitlearn", "theano", "numpy",
    "scipy", "panda", "tableau", "gensim", "rpc", "graphql", "iaas", "paas",
    "azure", "es", "solr", "http", "iot", "kinesis", "lambda", "typescript",
    "gradle", "buck", "bazel"
]
for skill in keywords:
    new_skill = Skill(name=skill)
    new_skill.save()