コード例 #1
0
def person_session_stats(request, pk, session):
    # get the person and the statistics
    person = get_object_or_404(Person, pk=pk)
    try:
        stats = person.get_session_stats(session)
    except ValueError:
        # no stats
        raise Http404()

    # get the role as stored in the file
    role = PersonRole.objects.get(id=stats["role_id"])

    # mark the role as current if the logical end date is in the future, to fix the display of Served/Serving
    role.current = (role.logical_dates()[1] > datetime.now().date())

    # clean and sort the stats for this person so they're ready for display
    from person.views_sessionstats import clean_person_stats
    clean_person_stats(stats)

    # group into an order for navigation
    nav_groups = []
    for stat in stats["stats"]:
        for group in nav_groups:
            if group["icon"] == stat["icon"]:
                group["stats"].append(stat)
                break
        else:
            nav_groups.append({"icon": stat["icon"], "stats": [stat]})

    import dateutil.parser
    from person.types import Gender, RoleType

    # what dates specifically for the congress?
    (period_min, period_max) = get_congress_dates(stats["meta"]["congress"])
    period_min = max(period_min, role.logical_dates()[0])
    period_max = min(period_max, role.logical_dates()[1])

    return {
        "publishdate": dateutil.parser.parse(stats["meta"]["as-of"]),
        "period": session_stats_period(session, stats),
        "congress_dates": (period_min, period_max),
        "person": person,
        "photo": person.get_photo()[0],
        "himher": Gender.by_value(person.gender).pronoun_object,
        "role": role,
        "class": RoleType.by_value(role.role_type).label.lower() + "s",
        "session": session,
        "meta": stats["meta"],
        "stats": stats["stats"],
        "nav_groups": nav_groups,
    }
コード例 #2
0
def person_session_stats(request, pk, session):
    # get the person and the statistics
    person = get_object_or_404(Person, pk=pk)
    try:
        stats = person.get_session_stats(session)
    except ValueError:
        # no stats
        raise Http404()

    # get the role as stored in the file
    role = PersonRole.objects.get(id=stats["role_id"])

    # mark the role as current if the logical end date is in the future, to fix the display of Served/Serving
    role.current = (role.logical_dates()[1] > datetime.now().date())

    # clean and sort the stats for this person so they're ready for display
    from person.views_sessionstats import clean_person_stats
    clean_person_stats(stats)

    # group into an order for navigation
    nav_groups = []
    for stat in stats["stats"]:
        for group in nav_groups:
            if group["icon"] == stat["icon"]:
                group["stats"].append(stat)
                break
        else:
            nav_groups.append({ "icon": stat["icon"], "stats": [stat]  })

    import dateutil.parser
    from person.types import Gender, RoleType

    # what dates specifically for the congress?
    (period_min, period_max) = get_congress_dates(stats["meta"]["congress"])
    period_min = max(period_min, role.logical_dates()[0])
    period_max = min(period_max, role.logical_dates()[1])

    return {
        "publishdate": dateutil.parser.parse(stats["meta"]["as-of"]),
        "period": session_stats_period(session, stats),
        "congress_dates": (period_min, period_max),
        "person": person,
        "photo": person.get_photo()[0],
        "himher": Gender.by_value(person.gender).pronoun_object,
        "role": role,
        "class": RoleType.by_value(role.role_type).label.lower() + "s",
        "session": session,
        "meta": stats["meta"],
        "stats": stats["stats"],
        "nav_groups": nav_groups,
    }
コード例 #3
0
ファイル: views.py プロジェクト: JayVenom/govtrack.us-web
def dynamic_call_script(issue, position, person, role):
	name = role.get_title() + " " + person.lastname

	from person.types import Gender
	pos_pro = Gender.by_value(person.gender).pronoun_posessive

	if issue.slug == "gov-shutdown-2013" and position.valence is True:
		if role.party == "Democrat":
			return position.call_script + " I ask %s to be open to a repeal or delay of the Affordable Care Act." % (name,)
		elif role.party == "Republican":
			return position.call_script + " I ask %s to hold %s ground until the Democrats come to the table to negotiate." % (name, pos_pro)
	elif issue.slug == "gov-shutdown-2013" and position.valence is False:
		if role.party == "Democrat":
			return position.call_script + " I ask %s to hold %s ground until the Republicans agree to fund the government." % (name, pos_pro)
		elif role.party == "Republican":
			return position.call_script + " I ask %s to pass a clean CR." % (name,)
	elif issue.slug == "debt-ceiling-2013":
			return position.call_script % (name,)
	return position.call_script
コード例 #4
0
ファイル: views.py プロジェクト: Web5design/govtrack.us-web
def person_session_stats(request, pk, session):
    # get the person and the statistics
    person = get_object_or_404(Person, pk=pk)
    try:
        stats = person.get_session_stats(session)
    except ValueError:
        # no stats
        raise Http404()

    # get the role as stored in the file
    role = PersonRole.objects.get(id=stats["role_id"])

    # clean and sort the stats for this person so they're ready for display
    from person.views_sessionstats import clean_person_stats
    clean_person_stats(stats)

    # group into an order for navigation
    nav_groups = []
    for stat in stats["stats"]:
        for group in nav_groups:
            if group["icon"] == stat["icon"]:
                group["stats"].append(stat)
                break
        else:
            nav_groups.append({"icon": stat["icon"], "stats": [stat]})

    import dateutil
    from person.types import Gender, RoleType

    return {
        "publishdate": dateutil.parser.parse(stats["meta"]["as-of"]),
        "person": person,
        "photo": person.get_photo()[0],
        "himher": Gender.by_value(person.gender).pronoun_object,
        "role": role,
        "class": RoleType.by_value(role.role_type).label.lower() + "s",
        "session": session,
        "meta": stats["meta"],
        "stats": stats["stats"],
        "nav_groups": nav_groups,
    }
コード例 #5
0
ファイル: views.py プロジェクト: ivicaned/govtrack.us-web
def person_session_stats(request, pk, session):
    # get the person and the statistics
    person = get_object_or_404(Person, pk=pk)
    try:
        stats = person.get_session_stats(session)
    except ValueError:
        # no stats
        raise Http404()

    # get the role as stored in the file
    role = PersonRole.objects.get(id=stats["role_id"])

    # clean and sort the stats for this person so they're ready for display
    from person.views_sessionstats import clean_person_stats
    clean_person_stats(stats)

    # group into an order for navigation
    nav_groups = []
    for stat in stats["stats"]:
        for group in nav_groups:
            if group["icon"] == stat["icon"]:
                group["stats"].append(stat)
                break
        else:
            nav_groups.append({ "icon": stat["icon"], "stats": [stat]  })

    import dateutil
    from person.types import Gender, RoleType

    return {
        "publishdate": dateutil.parser.parse(stats["meta"]["as-of"]),
        "person": person,
        "photo": person.get_photo()[0],
        "himher": Gender.by_value(person.gender).pronoun_object,
        "role": role,
        "class": RoleType.by_value(role.role_type).label.lower() + "s",
        "session": session,
        "meta": stats["meta"],
        "stats": stats["stats"],
        "nav_groups": nav_groups,
    }
コード例 #6
0
ファイル: views.py プロジェクト: wbt/govtrack.us-web
def dynamic_call_script(issue, position, person, role):
    name = role.get_title() + " " + person.lastname

    from person.types import Gender
    pos_pro = Gender.by_value(person.gender).pronoun_posessive

    if issue.slug == "gov-shutdown-2013" and position.valence is True:
        if role.party == "Democrat":
            return position.call_script + " I ask %s to be open to a repeal or delay of the Affordable Care Act." % (
                name, )
        elif role.party == "Republican":
            return position.call_script + " I ask %s to hold %s ground until the Democrats come to the table to negotiate." % (
                name, pos_pro)
    elif issue.slug == "gov-shutdown-2013" and position.valence is False:
        if role.party == "Democrat":
            return position.call_script + " I ask %s to hold %s ground until the Republicans agree to fund the government." % (
                name, pos_pro)
        elif role.party == "Republican":
            return position.call_script + " I ask %s to pass a clean CR." % (
                name, )
    elif issue.slug == "debt-ceiling-2013":
        return position.call_script % (name, )
    return position.call_script