Esempio n. 1
0
def get_project_form_from_builder(initial_data={}, data ={} , change_form=False):
    url = '/project/'
    if change_form:
        url = '%s?edit=True' % (url)
    status_code, response_object = call_service_api('project', url,'GET')
    form_builder = FormBuilder(response_object)

    new_field_order = [ 'name', 'description' ,'abbreviation', 'icon',
                       'start_date', 'managers', 'agile_coaches']

    form_builder.init_form( initial_data , data , ordered_fields=new_field_order, auto_id=False)

    for key in new_field_order:
        #Update the widget in form_dict
        if key not in form_builder.form.fields.keys():
            continue
        if key.endswith("_date"):
            form_builder.update_widget( key , extra_attrs={'class':'project_form dateinput'} )
        elif key == 'icon':
            icon_url = ""
            if initial_data.get('icon_url', None):
                icon_url = initial_data['icon_url']
            del_icon = ""
            if initial_data.get('del_icon',None):
                del_icon = initial_data['del_icon']
            form_builder.update_widget( key ,
                                        extra_attrs={
                                            'class':'project_form',
                                            'file_url': icon_url,
                                            'del_icon': del_icon
                                            } ,
                                        widget = ImageFileInput )
        else:
            form_builder.update_widget( key , extra_attrs={'class':'project_form'} )
    return form_builder.form
Esempio n. 2
0
def get_release_form_from_builder(project_pk, initial_data={}, data ={}):
    url = '/project/'+ project_pk + '/release/'
    status_code, response_object = call_service_api('project', url,'GET')
    form_builder = FormBuilder(response_object)

    del form_builder.form_dict[ 'project' ]

    new_field_order = [ 'name', 'number', 'iteration_length', 'estimated_velocity', 'start_date', 'release_date']

    form_builder.init_form( initial_data=initial_data , data=data , ordered_fields=new_field_order , auto_id=False)

    for key in new_field_order:
        #Update the widget in form_dict
        if key.endswith("_date"):
            form_builder.update_widget( key , extra_attrs={'class':'release_form dateinput'} )
        else:
            form_builder.update_widget( key , extra_attrs={'class':'release_form'} )
    return form_builder.form