'* Process the additional fields: Project/Activity/Milestone
* Log changes as comments
* If the task is assigned to someone then notify them'

@staticmethod
def project_task_update_onaccept(form):

    db = current.db
    s3db = current.s3db
    form_vars = form.vars
    task_id = form_vars.id
    record = form.record
    table = db.project_task
    changed = {}
    if record:
        for var in form_vars:
            vvar = form_vars[var]
            rvar = record[var]
            if (vvar != rvar):
                type = table[var].type
                if ((type == 'integer') or type.startswith('reference')):
                    if vvar:
                        vvar = int(vvar)
                    if (vvar == rvar):
                        continue
                represent = table[var].represent
                if (not represent):
                    represent = (lambda o: o)
                if rvar:
                    changed[var] = ('%s    changed    from    %s    to    %s' % (table[var].label, represent(rvar), represent(vvar)))
                else:
                    changed[var] = ('%s    changed    to    %s' % (table[var].label, represent(vvar)))
    if changed:
        table = db.project_comment
        text = s3_auth_user_represent(current.auth.user.id)
        for var in changed:
            text = ('%s\n%s' % (text, changed[var]))
        table.insert(task_id=task_id, body=text)
    post_vars = current.request.post_vars
    if ('project_id' in post_vars):
        ltable = db.project_task_project
        filter = (ltable.task_id == task_id)
        project = post_vars.project_id
        if project:
            query = ((ltable.task_id == task_id) & (ltable.project_id == project))
            record = db(query).select(ltable.id, limitby=(0, 1)).first()
            if record:
                link_id = record.id
            else:
                link_id = ltable.insert(task_id=task_id, project_id=project)
            filter = (filter & (ltable.id != link_id))
        links = s3db.resource('project_task_project', filter=filter)
        links.delete()
    if ('activity_id' in post_vars):
        ltable = db.project_task_activity
        filter = (ltable.task_id == task_id)
        activity = post_vars.activity_id
        if post_vars.activity_id:
            query = ((ltable.task_id == task_id) & (ltable.activity_id == activity))
            record = db(query).select(ltable.id, limitby=(0, 1)).first()
            if record:
                link_id = record.id
            else:
                link_id = ltable.insert(task_id=task_id, activity_id=activity)
            filter = (filter & (ltable.id != link_id))
        links = s3db.resource('project_task_activity', filter=filter)
        links.delete()
    if ('milestone_id' in post_vars):
        ltable = db.project_task_milestone
        filter = (ltable.task_id == task_id)
        milestone = post_vars.milestone_id
        if milestone:
            query = ((ltable.task_id == task_id) & (ltable.milestone_id == milestone))
            record = db(query).select(ltable.id, limitby=(0, 1)).first()
            if record:
                link_id = record.id
            else:
                link_id = ltable.insert(task_id=task_id, milestone_id=milestone)
            filter = (filter & (ltable.id != link_id))
        links = s3db.resource('project_task_milestone', filter=filter)
        links.delete()
    task_notify(form)
    if current.deployment_settings.get_cr_shelter_inspection_tasks():
        s3db.cr_resolve_shelter_flags(task_id)
