Example #1
0
def sync_tasks(test_run):
    tasks = Task.objects.all()
    logger.info("Syncing {0} Task objects.".format(tasks.count()))

    for task in tasks:
        logger.info("Syncing Task: {0}".format(task))

        # Find the corresponding SF tasks.
        try:
            sftask = SalesforceTask.objects.filter(external_id=task.id).get()
        except SalesforceTask.DoesNotExist:
            sftask = SalesforceTask()

        # SF Layout: Information section.
        sftask.project = SalesforceProject.objects.filter(external_id=task.project.id).get()
        sftask.deadline = task.deadline
        sftask.effort = task.time_needed
        sftask.extended_task_description = task.description
        sftask.location_of_the_task = task.location
        sftask.short_task_description = task.description
        sftask.task_expertise = task.expertise
        sftask.task_status = task.status
        sftask.title = task.title
        sftask.task_created_date = task.created
        # sftask.tags = str(task.tags.all())

        # SF Layout: System Information section.

        # SF: Other
        sftask.external_id = task.id

        # Save the SF tasks.
        if not test_run:
            sftask.save()