예제 #1
0
def randomise_uris(apps, schema_editor):
    # randomise the FRBR URIs that are the old-style generic "/za/act/1980/01" URIs.
    Document = apps.get_model("indigo_api", "Document")
    for doc in Document.objects.filter(frbr_uri='/za/act/1980/01'):
        uri = random_frbr_uri()
        uri.date = str(doc.created_at.year)

        act = Act(doc.document_xml)
        act.frbr_uri = uri.work_uri(False)
        doc.frbr_uri = uri.work_uri(False)
        doc.document_xml = act.to_xml()
        doc.save()
예제 #2
0
def set_repeal_details(apps, schema_editor):
    Document = apps.get_model("indigo_api", "Document")
    db_alias = schema_editor.connection.alias
    for doc in Document.objects.using(db_alias).all():
        a = Act(doc.document_xml)
        repeal = a.repeal
        if repeal:
            doc.repeal_event = {
                'date': datestring(repeal.date),
                'repealing_title': repeal.repealing_title,
                'repealing_uri': repeal.repealing_uri,
            }
            doc.save()
예제 #3
0
def set_amendment_details(apps, schema_editor):
    Document = apps.get_model("indigo_api", "Document")
    db_alias = schema_editor.connection.alias
    for doc in Document.objects.using(db_alias).all():
        a = Act(doc.document_xml)
        amendments = a.amendments
        if amendments:
            doc.amendment_events = [{
                'date': datestring(e.date),
                'amending_title': e.amending_title,
                'amending_uri': e.amending_uri,
            } for e in amendments]
            doc.save()
예제 #4
0
    def test_migration_without_heading(self):
        migration = ScheduleArticleToHcontainer()

        xml = OLD_SCHEDULE % ("""
        <paragraph id="schedule2.paragraph-0">
          <content>
            <p>None</p>
          </content>
        </paragraph>""")
        act = Act(xml)
        migration.migrate_act(act)

        expected = NEW_SCHEDULE % """
        <heading>Schedule</heading><paragraph id="schedule2.paragraph-0">
          <content>
            <p>None</p>
          </content>
        </paragraph>"""
        self.assertMultiLineEqual(
            expected,
            etree.tostring(act.root, encoding='utf-8',
                           pretty_print=True).decode('utf-8'))
예제 #5
0
파일: models.py 프로젝트: nickyspag/indigo
 def _make_act(self, xml):
     id = re.sub(r'[^a-zA-Z0-9]', '-', settings.INDIGO_ORGANISATION)
     doc = Act(xml)
     doc.source = [settings.INDIGO_ORGANISATION, id, settings.INDIGO_URL]
     return doc