Beispiel #1
0
    class child(twf.TableForm):
        action = 'post_edit'
        id = twf.HiddenField()
        subject = twf.LabelField()
        exam = twf.LabelField()
        timestamp = twf.LabelField()
        notes = twf.TextArea(validator=twc.StringLengthValidator(max=2048),
                             rows=10,
                             cols=40)

        class operator(twf.TableLayout):
            uid = twf.SingleSelectField(label="SUNetID",
                                        options=twc.Deferred(user_list),
                                        validator=twc.Any(
                                            twc.StringLengthValidator(min=0,
                                                                      max=0),
                                            UserExists()))

        class subject(twf.TableLayout):
            id = twf.HiddenField()
            code = twf.TextField(validator=twc.StringLengthValidator(max=31))
            firstname = twf.TextField(
                label="First Name",
                validator=twc.StringLengthValidator(max=63))
            lastname = twf.TextField(
                label="Last Name", validator=twc.StringLengthValidator(max=63))
            dob = twf.TextField(
                label="Date of Birth",
                validator=twc.DateTimeValidator(format="%m/%d/%Y"))
Beispiel #2
0
class NewTrackHub(twf.TableForm):
    #fields
    name = twf.TextField(label_text="Name : ", help_text="no space, use '_'")
    assembly = twf.LabelField(
        help_text=" is the assembly related to these files")
    files = twf.MultipleSelectField(label_text="Files used : ")
    extension = twf.LabelField(
        help_text=" is your files extensions for this TrackHub")

    submit = twf.SubmitButton(value="Visualise")
Beispiel #3
0
class EditMeas(twf.TableForm):
    #fields
    IDselected = twf.HiddenField(label_text="ID selected :")
    name = twf.TextField(label_text="Name :",
                         placeholder="Measurement name...",
                         validator=twc.Required)
    description = twf.TextArea(label_text="Description :")

    samples = twf.MultipleSelectField(
        label_text="Your samples : ",
        help_text="You can add some of your existing data to this project.")

    status_type = twf.CheckBox(
        label_text="Privacy : ",
        help_text=
        "Check it if you want a public data (available for UCSC visualisation)"
    )
    type = twf.CheckBox(label_text="Raw data : ",
                        help_text="Check it is a raw data")

    #parents management
    parents = twf.MultipleSelectField(
        label_text="Parents : ", help_text="Parent(s) of this measurement.")

    uploaded = twf.LabelField(
        help_text=
        "is attached to this measurement. If you want to change, it's better to delete this measurement and create a new one."
    )

    url_path = twf.TextField(label_text="File's url",
                             placeholder="http://www....")

    submit = twf.SubmitButton(value="Edit my measurement")
Beispiel #4
0
def build_form_edit_th(t_length):
    form_widget = MyForm()
    form_widget.submit = twf.SubmitButton(value="Edit the colors")
    all_fields = []
    cpt = 1
    for i in range(t_length / 2):
        all_fields.append(twf.LabelField(id="Track_name_" + str(cpt)))
        all_fields.append(
            twf.TextField(id="Color_Track_" + str(cpt),
                          help_text=" (R,G,B colors)"))
        cpt += 1
    form_widget.children = all_fields
    return form_widget
Beispiel #5
0
 class child(twf.TableForm):
     action = 'post_edit'
     id = twf.HiddenField()
     series = twf.LabelField()
     acq = twf.LabelField()
     description = twf.TextArea(validator=twc.StringLengthValidator(
         max=255))
     notes = twf.LabelField()
     psd = twf.LabelField()
     physio_flag = twf.LabelField()
     tr = twf.LabelField()
     te = twf.LabelField()
     flip_angle = twf.LabelField()
     num_timepoints = twf.LabelField()
     num_slices = twf.LabelField()
     protocol_name = twf.LabelField()
     scan_type = twf.LabelField()
     num_bands = twf.LabelField()
     prescribed_duration = twf.LabelField()
     mm_per_vox = twf.LabelField()
     fov = twf.LabelField()
     acquisition_matrix = twf.LabelField()
     phase_encode_undersample = twf.LabelField()
     slice_encode_undersample = twf.LabelField()
Beispiel #6
0
 class child(twf.GridLayout):
     extra_reps = 0
     id = twf.LinkField(link='detail?id=$', text='View', label=None)
     a = twf.LabelField()
     b = twf.LabelField()
Beispiel #7
0
 class child(twf.GridLayout):
     id = twf.LinkField(link='order?id=$', text='Edit', label=None)
     name = twf.LabelField()
     status = twf.LabelField()
     customer = twf.LabelField()
     assignee = twf.LabelField()
Beispiel #8
0
def edit_form(user_lab, owner, id_object):
    '''
    to edit dynamic form
    '''
    lab = DBSession.query(Labs).filter(Labs.name == user_lab).first()
    #static lists
    list_static_samples = [
        twf.HiddenField(id="IDselected", label_text="ID selected :"),
        twf.SingleSelectField(
            id="project",
            label_text="Your projects : ",
            help_text="the project which contains your sample is selected",
            prompt_text=None),
        twf.TextField(id="name", label_text="Name :", validator=twc.Required),
        twf.SingleSelectField(id="type",
                              label_text="Type : ",
                              help_text="What technique do you use ?",
                              prompt_text=None),
        twf.TextArea(
            id="protocole",
            label_text="Protocole :",
        ),
        twf.MultipleSelectField(id="measurements",
                                label_text="Attached measurement(s) : ")
    ]
    list_static_measurements = [
        twf.HiddenField(id="IDselected", label_text="ID selected :"),
        twf.TextField(id="name",
                      label_text="Name :",
                      placeholder="Measurement name...",
                      validator=twc.Required),
        twf.TextArea(id="description", label_text="Description :"),
        twf.MultipleSelectField(
            id="samples",
            label_text="Your samples : ",
            help_text="You can add some of your existing data to this project."
        ),
        twf.CheckBox(
            id="status_type",
            label_text="Privacy : ",
            help_text=
            "Check to have it available from outside EPFL (required for UCSC visualisation)"
        ),
        twf.CheckBox(id="type",
                     label_text="Raw data : ",
                     help_text="Check if raw data"),
        twf.MultipleSelectField(id="parents",
                                label_text="Parents : ",
                                help_text="Parent(s) of this measurement."),
        twf.LabelField(
            id="uploaded",
            help_text=
            "is attached to this measurement. If you want to change, it's better to delete this measurement and create a new one."
        ),
        twf.TextField(
            id="url_path",
            help_text=
            "If you want to add a new URL, your old URL will be stored into the description",
            placeholder="http://www...")
        #twf.CheckBox(id="url_up", label_text="I want to upload the file from this URL : ",
        #help_text="tick it if you want to download it in BioRepo")
    ]

    list_dynamic_samples = []
    list_dynamic_measurements = []
    if lab is None:
        print "----- no dynamic fields detected ---------"
        list_fields = [
            list_static_samples, list_dynamic_samples,
            list_static_measurements, list_dynamic_measurements
        ]
        return list_fields
    else:
        if owner == "sample":
            object_edited = DBSession.query(Samples).filter(
                Samples.id == int(id_object)).first()
            list_dynamic = list_dynamic_samples
            tag = "samples"
        elif owner == "meas":
            object_edited = DBSession.query(Measurements).filter(
                Measurements.id == int(id_object)).first()
            list_dynamic = list_dynamic_measurements
            tag = "measurements"
        else:
            print "----------------- owner error : ", owner, " <----owner --------------------"
            raise

        if object_edited is not None:
            list_dynamic_attributes = object_edited.attributs
            for att in list_dynamic_attributes:
                if att.deprecated == False:
                    twf_type = convert_widget(att.widget)
                    twf_type.id = att.key
                    list_a_values = att.values

                    if att.widget == "textfield" or att.widget == "textarea" or att.widget == "hiding_textfield" or att.widget == "hiding_textarea":
                        for v in list_a_values:
                            if hasattr(v, tag):
                                value_object = getattr(v, tag)
                            if object_edited in value_object:
                                twf_type.value = v.value
                        list_dynamic.append(twf_type)
                    elif att.widget == "checkbox" or att.widget == "hiding_checkbox":
                        for v in list_a_values:
                            if hasattr(v, tag):
                                value_object = getattr(v, tag)
                            if object_edited in value_object:
                                #dynamic boolean are stored in varchar in the db, we have to cast them in boolean for the display
                                value_2_display = check_boolean(v.value)
                                twf_type.value = value_2_display
                        list_dynamic.append(twf_type)
                    elif att.widget == "multipleselectfield" or att.widget == "hiding_multipleselectfield":
                        list_possible_values = []
                        for v in list_a_values:
                            list_possible_values.append(v.value)
                        twf_type.options = list_possible_values
                        selected_values = []
                        for v in list_a_values:
                            if hasattr(v, tag):
                                value_object = getattr(v, tag)
                            if object_edited in value_object:
                                selected_values.append(v.value)
                        twf_type.value = selected_values
                        list_dynamic.append(twf_type)

                    elif att.widget == "singleselectfield" or att.widget == "hiding_singleselectfield":
                        list_possible_values = []
                        for v in list_a_values:
                            if v.value not in list_possible_values:
                                list_possible_values.append(v.value)
                        twf_type.options = list_possible_values
                        for v in list_a_values:
                            if hasattr(v, tag):
                                value_object = getattr(v, tag)
                            if object_edited in value_object:
                                twf_type.value = v.value
                        list_dynamic.append(twf_type)

        else:
            print "Your ", owner, " was not found. ID problem. id :", id_object
            raise

        list_fields = [
            list_static_samples, list_dynamic_samples,
            list_static_measurements, list_dynamic_measurements
        ]
        return list_fields
Beispiel #9
0
 class child(twf.TableForm):
     action = 'post_edit'
     id = twf.HiddenField()
     owner = twf.SingleSelectField(options=twc.Deferred(get_owners), validator=twc.Required)
     name = twf.TextField(validator=twc.All(twc.StringLengthValidator(min=1), ExperimentDoesntExist('owner')))
     timestamp = twf.LabelField()
Beispiel #10
0
 class child(twf.TableForm):
     action = 'post_edit'
     uid = twf.LabelField(label='SUNet ID', validator=None)
     firstname = twf.TextField(label='First Name', validator=twc.StringLengthValidator(min=1))
     lastname = twf.TextField(label='Last Name', validator=twc.StringLengthValidator(min=1))