def __init__(self, user, parent, project_id, milestone_id, *args, **kwargs):
        super(TaskForm, self).__init__(*args, **kwargs)

        self.fields['name'].label = _("Name")
        self.fields['name'].widget.attrs.update({'class': 'duplicates',
                                                 'callback': reverse('projects_ajax_task_lookup')})

        self.fields['status'].label = _("Status")
        self.fields['status'].queryset = Object.filter_permitted(
            user, TaskStatus.objects, mode='x')
        try:
            conf = ModuleSetting.get_for_module(
                'treeio.projects', 'default_task_status')[0]
            self.fields['status'].initial = long(conf.value)
        except Exception:
            pass

        self.user = user

        self.fields['assigned'].label = _("Assigned")
        self.fields['assigned'].help_text = ""
        self.fields['assigned'].widget.attrs.update({'class': 'multicomplete',
                                                     'callback': reverse('identities_ajax_user_lookup')})

        self.fields['caller'].label = _("Caller")
        self.fields['caller'].queryset = Object.filter_permitted(
            user, Contact.objects, mode='x')

        if not self.instance.id:
            contact = user.get_contact()
            if contact:
                self.fields['caller'].initial = contact.id
                self.instance.caller = contact

        self.fields['caller'].widget.attrs.update({'class': 'autocomplete',
                                                   'callback': reverse('identities_ajax_contact_lookup')})
        self.fields['caller'].widget.attrs.update(
            {'popuplink': reverse('identities_contact_add')})

        self.fields['project'].label = _("Project")
        self.fields['project'].queryset = Object.filter_permitted(
            user, Project.objects, mode='x')
        if project_id:
            self.fields['project'].initial = project_id

        self.fields['milestone'].label = _("Milestone")
        self.fields['milestone'].queryset = Object.filter_permitted(
            user, Milestone.objects, mode='x')
        if milestone_id:
            self.fields['milestone'].initial = milestone_id

        self.fields['parent'].label = _("Parent")
        self.fields['parent'].widget.attrs.update({'class': 'autocomplete',
                                                   'callback': reverse('projects_ajax_task_lookup')})

        self.fields['depends'].label = _("Depends on")
        self.fields['depends'].widget.attrs.update({'class': 'autocomplete',
                                                   'callback': reverse('projects_ajax_task_lookup')})

        self.fields['milestone'].queryset = Object.filter_permitted(
            user, Milestone.objects, mode='x')
        self.fields['parent'].queryset = Object.filter_permitted(
            user, Task.objects, mode='x')

        self.fields['priority'].label = _("Priority")
        self.fields['priority'].initial = 3
        self.fields['priority'].choices = ((5, _('Highest')), (
            4, _('High')), (3, _('Normal')), (2, _('Low')), (1, _('Lowest')))

        self.fields['parent'].queryset = Object.filter_permitted(
            user, Task.objects, mode='x')
        if parent:
            self.fields['parent'].initial = parent.id
            self.fields['project'].initial = parent.project_id
            if parent.milestone_id:
                self.fields['milestone'].initial = parent.milestone_id

        # Set datepicker
        self.fields['start_date'].label = _("Start date")
        self.fields['start_date'].widget.attrs.update(
            {'class': 'datetimepicker'})
        self.fields['end_date'].label = _("End date")
        self.fields['end_date'].widget.attrs.update(
            {'class': 'datetimepicker'})

        if 'instance' in kwargs:
            instance = kwargs['instance']
            if instance.start_date:
                self.fields['start_date'].widget.attrs.update(
                    {'initial': instance.start_date.strftime('%s')})
            if instance.end_date:
                self.fields['end_date'].widget.attrs.update(
                    {'initial': instance.end_date.strftime('%s')})

        self.fields['details'].label = _("Details")
        self.fields['details'].widget.attrs.update({'class': 'full-editor'})
        self.fields['estimated_time'].label = _("Estimated time")
        self.fields['estimated_time'].help_text = _("minutes")
Populates form with fields from given Project
dataset/ETHPy150Open treeio/treeio/treeio/projects/forms.py/TaskForm.__init__