Exemple #1
0
 def get_major_events(self):
     if self.congress < 93: return []
     ret = []
     saw_intro = False
     for datestr, st, text in self.major_actions:
         date = eval(datestr)
         if (st == BillStatus.passed_bill and self.bill_type in (BillType.senate_bill, BillType.senate_joint_resolution)) or (st == BillStatus.passed_concurrentres and self.bill_type == BillType.senate_concurrent_resolution):
             st = "Passed House"
         elif (st == BillStatus.passed_bill and self.bill_type in (BillType.house_bill, BillType.house_joint_resolution)) or (st == BillStatus.passed_concurrentres and self.bill_type == BillType.house_concurrent_resolution):
             st = "Passed Senate"
         else:
             if st == BillStatus.introduced: saw_intro = True
             st = BillStatus.by_value(st).label
         ret.append({
             "label": st,
             "date": date,
             "extra": text,
         })
     if not saw_intro: ret.insert(0, { "label": "Introduced", "date": self.introduced_date })
     
     if self.docs_house_gov_postdate: ret.append({ "label": "On House Schedule", "date": self.docs_house_gov_postdate })
     if self.senate_floor_schedule_postdate: ret.append({ "label": "On Senate Schedule", "date": self.senate_floor_schedule_postdate })
     def as_dt(x):
         if isinstance(x, datetime.datetime): return x
         return datetime.datetime.combine(x, datetime.time.min)
     ret.sort(key = lambda x : as_dt(x["date"])) # only needed because of the previous two
     
     return ret
Exemple #2
0
    def render_event_state(self, ev_code, feeds):
        from status import BillStatus
        status = BillStatus.by_value(int(ev_code))
        date = self.introduced_date
        action = None
        action_type = None
       
        if status == BillStatus.introduced:
            action_type = "introduced"
        else:
            for datestr, st, text in self.major_actions:
                if st == status:
                    date = eval(datestr)
                    action = text
                    break
            else:
                raise Exception("Invalid %s event in %s." % (status, str(self)))
                
        return {
            "type": status.label,
            "date": date,
            "date_has_no_time": isinstance(date, datetime.date) or date.time() == datetime.time.min,
            "title": self.title,
            "url": self.get_absolute_url(),
            "body_text_template":
"""{% if sponsor and action_type == 'introduced' %}Sponsor: {{sponsor|safe}}{% endif %}
{% if action %}Last Action: {{action|safe}}{% endif %}
{% if action %}Explanation: {% endif %}{{summary|safe}}""",
            "body_html_template":
"""{% if sponsor and action_type == 'introduced' %}<p>Sponsor: <a href="{{SITE_ROOT}}{{sponsor.get_absolute_url}}">{{sponsor}}</a></p>{% endif %}
{% if action %}<p>Last Action: {{action}}</p>{% endif %}
<p>{% if action %}Explanation: {% endif %}{{summary}}</p>
""",
            "context": {
                "sponsor": self.sponsor,
                "action": action,
                "action_type": action_type,
                "summary": self.get_status_text(status, date),
                }
            }
Exemple #3
0
from bill.status import BillStatus


class Died:
    label = "Died"
    sort_order = 999


Died = Died()

T = {}
for b in Bill.objects.filter(congress__in=(110, 111),
                             bill_type=BillType.house_bill):
    s0 = BillStatus.introduced
    for d, s, t in b.major_actions:
        s = BillStatus.by_value(s)
        if s0:
            if s.key == "referred":
                # data error
                s = BillStatus.introduced  # map to introduced next xycle
                pass
            elif s0.key == "pass_over_house" and s.key == "enacted_signed":
                # data error
                T[(s0, BillStatus.passed_bill)] = T.get(
                    (s0, BillStatus.passed_bill), 0) + 1
                T[(BillStatus.passed_bill, s)] = T.get(
                    (BillStatus.passed_bill, s), 0) + 1
            else:
                T[(s0, s)] = T.get((s0, s), 0) + 1
        s0 = s
    T[(s0, Died)] = T.get((s0, Died), 0) + 1
Exemple #4
0
 def get_status_text(self, status, date) :
     status = BillStatus.by_value(status).xml_code
     date = date.strftime("%B %d, %Y").replace(" 0", " ")
     status = get_bill_status_string(self.congress == settings.CURRENT_CONGRESS, status)       
     return status % (self.noun, date)
#!script

from bill.models import *
from bill.status import BillStatus

class Died:
	label = "Died"
	sort_order = 999
Died = Died()

T = { }
for b in Bill.objects.filter(congress__in=(110,111), bill_type=BillType.house_bill):
	s0 = BillStatus.introduced
	for d, s, t in b.major_actions:
		s = BillStatus.by_value(s)
		if s0:
			if s.key == "referred":
				# data error
				s = BillStatus.introduced # map to introduced next xycle
				pass
			elif s0.key == "pass_over_house" and s.key == "enacted_signed":
				# data error
				T[(s0, BillStatus.passed_bill)] = T.get((s0, BillStatus.passed_bill), 0) + 1
				T[(BillStatus.passed_bill, s)] = T.get((BillStatus.passed_bill, s), 0) + 1
			else:
				T[(s0, s)] = T.get((s0, s), 0) + 1
		s0 = s
	T[(s0, Died)] = T.get((s0, Died), 0) + 1

import pygraphviz as pgv
G = pgv.AGraph(directed=True, dpi=120, overlap=False, splines=True, bgcolor="transparent")