예제 #1
0
파일: works.py 프로젝트: madzimai/indigo
        def make_task(chosen_task):
            task = Task()
            task.country = self.country
            task.locality = self.locality
            task.work = info.get('work')
            task.created_by_user = self.request.user
            task.code = chosen_task
            for possible_task in form.possible_tasks:
                if chosen_task == possible_task['key']:
                    task.title = possible_task['label']
                    task.description = possible_task['description']

            # need to save before assigning workflow because of M2M relation
            task.save()
            task.workflows = [form.cleaned_data.get('workflow')]
            task.save()
예제 #2
0
    def create_task(self,
                    work,
                    info,
                    task_type,
                    repealing_work=None,
                    amended_work=None,
                    amendment=None):
        task = Task()

        if task_type == 'link-publication-document':
            task.title = 'Link gazette'
            task.description = f'''This work's gazette (original publication document) couldn't be linked automatically.

Find it and upload it manually.'''

        elif task_type == 'import':
            task.title = 'Import content'
            task.description = '''Import the content for this work – either the initial publication (usually a PDF of the Gazette) or a later consolidation (usually a .docx file).'''

        elif task_type == 'link-commencement':
            task.title = 'Link commencement'
            task.description = f'''It looks like this work was commenced by "{info['commenced_by']}" (see row {info['row']} of the spreadsheet), but it couldn't be linked automatically.

Possible reasons:
– a typo in the spreadsheet
– the commencing work doesn't exist on the system.

Please link the commencing work manually.'''

        elif task_type == 'link-amendment':
            task.title = 'Link amendment'
            amended_work = info['amends']
            if len(amended_work) > 256:
                amended_work = "".join(amended_work[:256] + ', etc')
            task.description = f'''It looks like this work amends "{amended_work}" (see row {info['row']} of the spreadsheet), but it couldn't be linked automatically.

Possible reasons:
– a typo in the spreadsheet
– more than one amended work was listed (it only works if there's one)
– the amended work doesn't exist on the system.

Please link the amendment manually.'''

        elif task_type == 'link-amendment-pending-commencement':
            task.title = 'Link amendment'
            task.description = f'''It looks like this work amends {amended_work.title} ({amended_work.numbered_title()}), but it couldn't be linked automatically because this work hasn't commenced yet (so there's no date for the amendment).

Please link the amendment manually (and apply it) when this work comes into force.'''

        elif task_type == 'apply-amendment':
            task.title = 'Apply amendment'
            task.description = f'''Apply the amendments made by {amendment.amending_work.title} ({amendment.amending_work.numbered_title()}) on {amendment.date}.

The amendment has already been linked, so start at Step 3 of https://docs.laws.africa/managing-works/amending-works.'''

        elif task_type == 'no-repeal-match':
            task.title = 'Link repeal'
            task.description = f'''It looks like this work was repealed by "{info['repealed_by']}" (see row {info['row']} of the spreadsheet), but it couldn't be linked automatically.

Possible reasons:
– a typo in the spreadsheet
– the repealing work doesn't exist on the system.

Please link the repeal manually.'''

        elif task_type == 'check-update-repeal':
            task.title = 'Update repeal information?'
            task.description = f'''On the spreadsheet (see row {info['row']}), it says that this work was repealed by {repealing_work.title} ({repealing_work.numbered_title()}).

But this work is already listed as having been repealed by {work.repealed_by} ({work.repealed_by.numbered_title()}), so the repeal information wasn't updated automatically.

If the old / existing repeal information was wrong, update it manually. Otherwise (if the spreadsheet was wrong), cancel this task.
'''

        elif task_type == 'link-repeal-pending-commencement':
            repealed_work = info['work']
            task.title = 'Link repeal'
            task.description = f'''It looks like this work repeals {repealed_work.title} ({repealed_work.numbered_title()}), but it couldn't be linked automatically because this work hasn't commenced yet (so there's no date for the repeal).

Please link the repeal manually when this work comes into force.'''

        elif task_type == 'link-repeal':
            task.title = 'Link repeal'
            task.description = f'''It looks like this work was repealed by {repealing_work.title} ({repealing_work.numbered_title()}), but it couldn't be linked automatically.

Please link it manually.'''

        elif task_type == 'link-primary-work':
            task.title = 'Link primary work'
            task.description = f'''It looks like this work's primary work is "{info['primary_work']}" (see row {info['row']} of the spreadsheet), but it couldn't be linked automatically.

Possible reasons:
– a typo in the spreadsheet
– the primary work doesn't exist on the system.

Please link the primary work manually.'''

        elif task_type == 'link-taxonomy':
            task.title = 'Link taxonomy'
            task.description = f'''It looks like this work has the following taxonomy: "{info['unlinked_topics']}" (see row {info['row']} of the spreadsheet), but it couldn't be linked automatically.

Possible reasons:
– a typo in the spreadsheet
– the taxonomy doesn't exist on the system.'''

        task.country = self.country
        task.locality = self.locality
        task.work = work
        task.code = task_type
        task.created_by_user = self.user

        # need to save before assigning workflow because of M2M relation
        task.save()
        if self.workflow:
            task.workflows.set([self.workflow])
            task.save()

        if 'pending-commencement' in task_type:
            # add the `pending commencement` label, if it exists
            pending_commencement_label = TaskLabel.objects.filter(
                slug='pending-commencement').first()
            if pending_commencement_label:
                task.labels.add(pending_commencement_label)
                task.save()

        return task
예제 #3
0
    def create_task(self, work, info, task_type):
        task = Task()

        if task_type == 'link-publication-document':
            task.title = 'Link gazette'
            task.description = '''This work's gazette (original publication document) could not be linked automatically – see row {}.
Find it and upload it manually.'''.format(info['row'])

        elif task_type == 'import':
            task.title = 'Import content'
            task.description = '''Import a point in time for this work; either the initial publication or a later consolidation.
Make sure the document's expression date is correct.'''

        elif task_type == 'link-commencement':
            task.title = 'Link commencement'
            task.description = '''On the spreadsheet, it says that this work is commenced by '{}' – see row {}.

The commencement work could not be linked automatically.
Possible reasons:
– a typo in the spreadsheet
– more than one work by that name exists on the system
– the commencing work doesn't exist on the system.

Check the spreadsheet for reference and link it manually.'''.format(info['commenced_by'], info['row'])

        elif task_type == 'link-amendment':
            task.title = 'Link amendment(s)'
            amended_title = info['amends']
            if len(amended_title) > 256:
                amended_title = "".join(amended_title[:256] + ', etc')
            task.description = '''On the spreadsheet, it says that this work amends '{}' – see row {}.

The amendment could not be linked automatically.
Possible reasons:
– a typo in the spreadsheet
– no date for the amendment
– more than one amended work listed
– the amended work doesn't exist on the system.

Check the spreadsheet for reference and link it/them manually,
or add the 'Pending commencement' label to this task if it doesn't have a date yet.'''.format(amended_title, info['row'])

        elif task_type == 'link-repeal':
            task.title = 'Link repeal'
            task.description = '''On the spreadsheet, it says that this work was repealed by '{}' – see row {}.

The repeal could not be linked automatically.
Possible reasons:
– a typo in the spreadsheet
– no date for the repeal
– more than one work by that name exists on the system
– the repealing work doesn't exist on the system.

Check the spreadsheet for reference and link it manually,
or add the 'Pending commencement' label to this task if it doesn't have a date yet.'''.format(info['repealed_by'], info['row'])

        elif task_type == 'link-primary-work':
            task.title = 'Link primary work'
            task.description = '''On the spreadsheet, it says that this work's primary work is '{}' – see row {}.

The primary work could not be linked automatically.
Possible reasons:
– a typo in the spreadsheet
– more than one work by that name exists on the system
– the primary work doesn't exist on the system.

Check the spreadsheet for reference and link it manually.'''.format(info['primary_work'], info['row'])

        task.country = self.country
        task.locality = self.locality
        task.work = work
        task.code = task_type
        task.created_by_user = self.user

        # need to save before assigning workflow because of M2M relation
        task.save()
        if self.workflow:
            task.workflows = [self.workflow]
            task.save()

        return task
예제 #4
0
파일: works.py 프로젝트: madzimai/indigo
    def create_task(self, info, form, task_type):
        task = Task()

        if task_type == 'link-publication-document':
            task.title = 'Link publication document'
            task.description = '''This work's publication document could not be linked automatically – see row {}.
Find it and upload it manually.'''.format(info['row'])

        elif task_type == 'link-commencement':
            task.title = 'Link commencement'
            task.description = '''On the spreadsheet, it says that this work is commenced by '{}' – see row {}.

The commencement work could not be linked automatically.
Possible reasons:
– a typo in the spreadsheet
– the commencing work hasn't been imported.

Check the spreadsheet for reference and link it manually.'''.format(
                info['commenced_by'], info['row'])

        elif task_type == 'link-amendment':
            task.title = 'Link amendment(s)'
            amended_title = info['amends']
            if len(amended_title) > 256:
                amended_title = "".join(amended_title[:256] + ', etc')
            task.description = '''On the spreadsheet, it says that this work amends '{}' – see row {}.

The amendment could not be linked automatically.
Possible reasons:
– more than one amended work listed
– a typo in the spreadsheet
– no date for the amendment
– the amended work hasn't been imported.

Check the spreadsheet for reference and link it/them manually,
or add the 'Pending commencement' label to this task if it doesn't have a date yet.'''.format(
                amended_title, info['row'])

        elif task_type == 'link-repeal':
            task.title = 'Link repeal'
            task.description = '''On the spreadsheet, it says that this work was repealed by '{}' – see row {}.

The repeal could not be linked automatically.
Possible reasons:
– a typo in the spreadsheet
– no date for the repeal
– the repealing work hasn't been imported.

Check the spreadsheet for reference and link it manually,
or add the 'Pending commencement' label to this task if it doesn't have a date yet.'''.format(
                info['repealed_by'], info['row'])

        elif task_type == 'link-primary-work':
            task.title = 'Link primary work'
            task.description = '''On the spreadsheet, it says that this work's primary work is '{}' – see row {}.

The primary work could not be linked automatically.
Possible reasons:
– a typo in the spreadsheet
– the primary work hasn't been imported.

Check the spreadsheet for reference and link it manually.'''.format(
                info['primary_work'], info['row'])

        task.country = self.country
        task.locality = self.locality
        task.work = info['work']
        task.code = task_type
        task.created_by_user = self.request.user

        # need to save before assigning workflow because of M2M relation
        task.save()
        task.workflows = [form.cleaned_data.get('workflow')]
        task.save()