Beispiel #1
0
    def create_or_update_single_bill(self, proposal):
        if not (proposal["date"]) or CUTOFF_DATE and proposal["date"] < CUTOFF_DATE:
            return
        law_name = proposal["law"]
        (law, created) = Law.objects.get_or_create(title=law_name)
        if created:
            law.save()
        if law.merged_into:
            law = law.merged_into
        title = u""
        if proposal["correction"]:
            title += proposal["correction"]
        if proposal["comment"]:
            title += " " + proposal["comment"]
        if len(title) <= 1:
            title = u"חוק חדש"
        (gp, created) = GovProposal.objects.get_or_create(
            booklet_number=proposal["booklet"],
            knesset_id=18,
            source_url=proposal["link"],
            title=title,
            law=law,
            date=proposal["date"],
        )
        if created:
            gp.save()

        b = Bill(law=law, title=title, stage="3", stage_date=proposal["date"])
        b.save()
        gp.bill = b
        gp.save()
Beispiel #2
0
    def create_or_update_single_bill(self, proposal):
        if not(proposal['date']) or CUTOFF_DATE and proposal['date'] < CUTOFF_DATE:
            return
        law_name = proposal['law']
        (law, created) = Law.objects.get_or_create(title=law_name)
        if created:
            law.save()
        if law.merged_into:
            law = law.merged_into
        title = u''
        if proposal['correction']:
            title += proposal['correction']
        if proposal['comment']:
            title += ' ' + proposal['comment']
        if len(title)<=1:
            title = u'חוק חדש'
        (gp,created) = GovProposal.objects.get_or_create(booklet_number=proposal['booklet'], knesset_id=18,
                                                             source_url=proposal['link'],
                                                             title=title, law=law, date=proposal['date'])
        if created:
            gp.save()

        b = Bill(law=law, title=title, stage='3', stage_date=proposal['date'])
        b.save()
        gp.bill = b
        gp.save()
Beispiel #3
0
    def create_or_update_single_bill(self, proposal, pdf_link, link_file):
        if not(proposal['date']) or CUTOFF_DATE and proposal['date'] < CUTOFF_DATE:
            return
        law_name = proposal['law']
        (law, created) = Law.objects.get_or_create(title=law_name)
        if created:
            law.save()
        if law.merged_into:
            law = law.merged_into
        title = u''
        if proposal['correction']:
            title += proposal['correction']
        if proposal['comment']:
            title += ' ' + proposal['comment']
        if len(title)<=1:
            title = u'חוק חדש'
        (gp,created) = GovProposal.objects.get_or_create(booklet_number=proposal['booklet'], knesset_id=18,
                                                             source_url=proposal['link'],
                                                             title=title, law=law, date=proposal['date'])
        if created:
            gp.save()
            logger.debug("created GovProposal id = %d" % gp.id)

        bill_params = dict(law=law, title=title, stage='3', stage_date=proposal['date'])
        similar_bills = Bill.objects.filter(**bill_params).order_by('id')
        if len(similar_bills) >= 1:
            b = similar_bills[0]
            if len(similar_bills) > 1:
                logger.debug("multiple bills detected")
                for bill in similar_bills:
                    if bill.id == b.id:
                        logger.debug("bill being used now   - %d" % bill.id)
                    else:
                        logger.debug("bill with same fields - %d" % bill.id)
        else:
            b = Bill(**bill_params)
            b.save()
        gp.bill = b
        gp.save()
        if link_file.link is None:
            link = Link(title=pdf_link, url=pdf_link,
                content_type=ContentType.objects.get_for_model(gp),
                object_pk=str(gp.id))
            link.save()
            link_file.link = link
            link_file.save()
            logger.debug("check updated %s" % b.get_absolute_url())