コード例 #1
0
ファイル: loadpriorities.py プロジェクト: paultag/mandelbrot
def scrape(sections):
    for section in sections:
        active = False
        if section.title == "Projects open for staffing":
            active = True

        for project in section.projects:
            agencies, title = project_details(project)

            db_project = Project(
                id=django.utils.text.slugify(title),
                name=title,
                active=active,
                mission=project.mission,
            )
            db_project.save()

            for agency in agencies:
                agency.save()
                db_project.agencies.add(agency)

            for employee in project.team:
                if employee.employer == "18F":
                    continue
                if "open" in employee.name.lower():
                    continue

                roles = [role(x) for x in employee.role.split("/")]
                roles = [x for x in roles if x is not None]
                part_time = employee.quantity != 1.0

                if roles == []:
                    continue

                expert = None
                try:
                    expert = Expert.by_name(employee.name)
                except Expert.DoesNotExist:
                    print(",{},priorities.md,,,False".format(employee.name))
                    continue

                membership = expert.memberships.filter(
                    project=db_project,
                    end_date__isnull=True,
                )
                if len(membership) == 0:
                    m = ProjectMember(
                        project=db_project,
                        who=expert,
                        start_date=expert.start_date,
                        part_time=part_time,
                    )
                    m.save()
                    for r in roles:
                        m.roles.add(r)
                    m.save()

            yield db_project
コード例 #2
0
ファイル: loadpriorities.py プロジェクト: alex/mandelbrot
def scrape(sections):
    for section in sections:
        active = False
        if section.title == "Projects open for staffing":
            active = True

        for project in section.projects:
            agencies, title = project_details(project)

            db_project = Project(
                id=django.utils.text.slugify(title),
                name=title,
                active=active,
                mission=project.mission,
            )
            db_project.save()

            for agency in agencies:
                agency.save()
                db_project.agencies.add(agency)

            for employee in project.team:
                if employee.employer == "18F":
                    continue
                if "open" in employee.name.lower():
                    continue

                roles = [role(x) for x in employee.role.split("/")]
                roles = [x for x in roles if x is not None]
                part_time = employee.quantity != 1.0

                if roles == []:
                    continue

                expert = None
                try:
                    expert = Expert.by_name(employee.name)
                except Expert.DoesNotExist:
                    print(",{},priorities.md,,,False".format(employee.name))
                    continue

                membership = expert.memberships.filter(
                    project=db_project,
                    end_date__isnull=True,
                )
                if len(membership) == 0:
                    m = ProjectMember(
                        project=db_project,
                        who=expert,
                        start_date=expert.start_date,
                        part_time=part_time,
                    )
                    m.save()
                    for r in roles:
                        m.roles.add(r)
                    m.save()

            yield db_project
コード例 #3
0
ファイル: loadsalesforce.py プロジェクト: alex/mandelbrot
def get_expert(name):
    try:
        return Expert.by_name(name=name)
    except Expert.DoesNotExist:
        whom = Expert.objects.create(
            id=django.utils.text.slugify(name),
            name=name,
            active=False,
            start_date=dt.date.today(),
            title="DSE",
        )
        return whom
コード例 #4
0
ファイル: loadsalesforce.py プロジェクト: paultag/mandelbrot
def get_expert(name):
    try:
        return Expert.by_name(name=name)
    except Expert.DoesNotExist:
        whom = Expert.objects.create(
            id=django.utils.text.slugify(name),
            name=name,
            active=False,
            start_date=dt.date.today(),
            title="DSE",
        )
        return whom
コード例 #5
0
ファイル: loadslack.py プロジェクト: paultag/mandelbrot
def scrape():
    team = requests.get(
        'https://slack.com/api/users.list?token={}'.format(KEY),
    ).json()['members']

    for person in team:
        if person.get('deleted', False):
            continue
        if person.get('is_bot', False):
            continue

        name = person.get('real_name', person.get('name'))
        if name == "":
            continue

        try:
            who = Expert.by_name(name)
        except Expert.DoesNotExist:
            print(",{},Slack Name,,,False".format(name))
            continue

        if who.photo_url == "":
            who.photo_url = person.get('profile', {}).get('image_original', "")

        phone = person.get("profile", {}).get("phone", None)
        if phone is not None and phone != "":
            detail, created = who.add_contact_detail(
                value=phone,
                label=None,
                type='phone',
                preferred=True,
                official=False,
            )
            if created:
                detail.label = "From Slack"
                detail.save()

        detail, created = who.add_contact_detail(
            value=person['name'],
            label=None,
            type='slack',
            preferred=True,
            official=False,
        )
        if created:
            detail.label = "From Slack"
            detail.save()

        who.save()
        yield who
コード例 #6
0
ファイル: loadslack.py プロジェクト: gmorgana-va/mandelbrot
def scrape():
    team = requests.get(
        'https://slack.com/api/users.list?token={}'.format(KEY),
    ).json()['members']

    for person in team:
        if person.get('deleted', False):
            continue
        if person.get('is_bot', False):
            continue

        name = person.get('real_name', person.get('name'))
        if name == "":
            continue

        try:
            who = Expert.by_name(name)
        except Expert.DoesNotExist:
            print(",{},Slack Name,,,False".format(name))
            continue

        if who.photo_url == "":
            who.photo_url = person.get('profile', {}).get('image_original', "")

        phone = person.get("profile", {}).get("phone", None)
        if phone is not None and phone != "":
            detail, created = who.add_contact_detail(
                value=phone,
                label=None,
                type='phone',
                preferred=True,
            )
            if created:
                detail.label = "From Slack"
                detail.save()

        detail, created = who.add_contact_detail(
            value=person['name'],
            label=None,
            type='slack',
            preferred=True,
        )
        if created:
            detail.label = "From Slack"
            detail.save()

        who.save()
        yield who
コード例 #7
0
ファイル: loadgithub.py プロジェクト: gmorgana-va/mandelbrot
def find(github_user):
    expert_name = name(github_user)

    try:
        return Expert.by_name(expert_name)
    except Expert.DoesNotExist:
        pass

    expert = Expert.objects.filter(
        contact_details__type="github",
        contact_details__value=github_user.login
    ).distinct()

    if len(expert) == 0:
        raise Expert.DoesNotExist(expert_name)
    if len(expert) != 1:
        raise Expert.MultipleObjectsReturned(expert_name)
    expert, = expert
    return expert
コード例 #8
0
ファイル: loadgithub.py プロジェクト: paultag/mandelbrot
def find(github_user):
    expert_name = name(github_user)

    try:
        return Expert.by_name(expert_name)
    except Expert.DoesNotExist:
        pass

    expert = Expert.objects.filter(
        contact_details__type="github",
        contact_details__value=github_user.login
    ).distinct()

    if len(expert) == 0:
        raise Expert.DoesNotExist(expert_name)
    if len(expert) != 1:
        raise Expert.MultipleObjectsReturned(expert_name)
    expert, = expert
    return expert
コード例 #9
0
ファイル: loadslack.py プロジェクト: paultag/mandelbrot
def scrape():
    team = requests.get("https://slack.com/api/users.list?token={}".format(KEY)).json()["members"]

    for person in team:
        if person.get("deleted", False):
            continue
        if person.get("is_bot", False):
            continue

        name = person.get("real_name", person.get("name"))
        if name == "":
            continue

        try:
            who = Expert.by_name(name)
        except Expert.DoesNotExist:
            print(",{},Slack Name,,,False".format(name))
            continue

        if who.photo_url == "":
            who.photo_url = person.get("profile", {}).get("image_original", "")

        phone = person.get("profile", {}).get("phone", None)
        if phone is not None and phone != "":
            detail, created = who.add_contact_detail(
                value=phone, label=None, type="phone", preferred=True, official=False
            )
            if created:
                detail.label = "From Slack"
                detail.save()

        detail, created = who.add_contact_detail(
            value=person["name"], label=None, type="slack", preferred=True, official=False
        )
        if created:
            detail.label = "From Slack"
            detail.save()

        who.save()
        yield who