Ejemplo n.º 1
0
def project_create(request):
  if request.method == 'POST':
    ln_user_id = str(request.user)[3:]
    ln_user = LinkedInUserProfile.objects.get(linkedin_uid = ln_user_id)
    name = request.POST['name']
    skills = extract_skills_from_user_string(request.POST['skills'])
    project = Project(name=name, skills_set=skills, creator = ln_user)
    project.save()

    """ prepare object with connections and skills """
    li = LinkedIn(settings.LINKEDIN_CONSUMER_KEY,\
      settings.LINKEDIN_CONSUMER_SECRET)
    access_token = request.session['access_token']
    connections = li.connections_api.getMyConnections(access_token)
    members = []

    for conn in connections:
      member = Member()
      member.proj = project
      member.linkedin_url = conn.profile_url
      member.pic = conn.picture_url
      member.first_name = conn.firstname
      member.last_name = conn.lastname
      member.info = {}
      member.info['summary'] = conn.summary.lower()
      member.info['specialties'] = conn.specialties.lower()
      members.append(member)
      
    request.session['members_' + str(project.id)] = members

    return redirect('web.views.project', project.id)
  return render_to_response('project/create.html', {}, RequestContext(request))
Ejemplo n.º 2
0
def build_member_data(project, access_token):
  li = LinkedIn(settings.LINKEDIN_CONSUMER_KEY,\
      settings.LINKEDIN_CONSUMER_SECRET)
  connections = li.connections_api.getMyConnections(access_token)
  members = []

  for conn in connections:
    member = Member()
    member.proj = project
    member.linkedin_url = conn.profile_url
    member.pic = conn.picture_url
    member.first_name = conn.firstname
    member.last_name = conn.lastname
    member.info = {}
    member.info['summary'] = conn.summary.lower()
    member.info['specialties'] = conn.specialties.lower()
    members.append(member)

  return members
Ejemplo n.º 3
0
def build_member_data(project, access_token):
    li = LinkedIn(settings.LINKEDIN_CONSUMER_KEY,\
        settings.LINKEDIN_CONSUMER_SECRET)
    connections = li.connections_api.getMyConnections(access_token)
    members = []

    for conn in connections:
        member = Member()
        member.proj = project
        member.linkedin_url = conn.profile_url
        member.pic = conn.picture_url
        member.first_name = conn.firstname
        member.last_name = conn.lastname
        member.info = {}
        member.info['summary'] = conn.summary.lower()
        member.info['specialties'] = conn.specialties.lower()
        members.append(member)

    return members
Ejemplo n.º 4
0
def member_add(request):
  # get member info from session
  idem_member = Member()
  project = Project.objects.get(pk = request.GET['project_id'])
  all_members = request.session['members_' + str(project.id)]
  for member in all_members:
    if member.linkedin_url == request.GET['url']:
      # add member to database
      idem_member.proj = project
      idem_member.linkedin_url = member.linkedin_url
      idem_member.first_name = member.first_name
      idem_member.last_name = member.last_name
      idem_member.pic = member.pic
      idem_member.info = member.info
      update_skills_for_member(project, idem_member)
      idem_member.save()
      break

  # update project score
  score = compute_score(project)
  project.score = score
  project.nr_members = project.nr_members + 1
  project.save()
  return HttpResponse('')
Ejemplo n.º 5
0
def member_add(request):
    # get member info from session
    idem_member = Member()
    project = Project.objects.get(pk=request.GET['project_id'])
    all_members = request.session['members_' + str(project.id)]
    for member in all_members:
        if member.linkedin_url == request.GET['url']:
            # add member to database
            idem_member.proj = project
            idem_member.linkedin_url = member.linkedin_url
            idem_member.first_name = member.first_name
            idem_member.last_name = member.last_name
            idem_member.pic = member.pic
            idem_member.info = member.info
            update_skills_for_member(project, idem_member)
            idem_member.save()
            break

    # update project score
    score = compute_score(project)
    project.score = score
    project.nr_members = project.nr_members + 1
    project.save()
    return HttpResponse('')