class mag(twf.ListLayout): id = None mag_f = twf.HiddenField() mag_t = twf.HiddenField() mag = jqui.widgets.SliderWidget("magnitude", options={ 'range': True, 'min': -3, 'max': 10, 'step': 0.5, 'values': [0, 10], }, events={ 'slide': """ function( event, ui ) { $( "#mag_f" ).val(ui.values[ 0 ]); $( "#mag_t" ).val(ui.values[ 1 ]); $( "#lblMag" ).val(ui.values[ 0 ]+" a "+ui.values[ 1 ]); } """, }) lblMag = twf.TextField(label=None, size=15, attrs={ 'style': "border: 0;", 'readonly': 'readonly' })
class NewTrackSequence(twf.TableForm): file_upload = twf.FileField(label='Upload : ', help_text='Upload file from filesystem') url = twf.TextField(label='Url : ', help_text='Provide an url') sequence_id = twf.HiddenField() track_admin = twf.HiddenField() submit = twf.SubmitButton(id="submit", value="New")
class lat(twf.ListLayout): id = None lat_f = twf.HiddenField() lat_t = twf.HiddenField() lat = jqui.widgets.SliderWidget("Latitude", options={ 'range': True, 'min': -90, 'max': 90, 'step': 10, 'values': [-35, 6], }, events={ 'slide': """ function( event, ui ) { $( "#lat_f" ).val(ui.values[ 0 ]); $( "#lat_t" ).val(ui.values[ 1 ]); $( "#lblLat" ).val(ui.values[ 0 ]+" a "+ui.values[ 1 ]); } """, }) lblLat = twf.TextField(label=None, size=15, attrs={ 'style': "border: 0;", 'readonly': 'readonly' })
class dep(twf.ListLayout): id = None dep_f = twf.HiddenField() dep_t = twf.HiddenField() dep = jqui.widgets.SliderWidget("Elevacao", options={ 'range': True, 'min': 0, 'max': 6000, 'step': 1.0, 'values': [0, 4000], }, events={ 'slide': """ function( event, ui ) { $( "#dep_f" ).val(ui.values[ 0 ]); $( "#dep_t" ).val(ui.values[ 1 ]); $( "#lblDep" ).val(ui.values[ 0 ]+" a "+ui.values[ 1 ]); } """, }) lblDep = twf.TextField(label=None, size=8, attrs={ 'style': "border: 0;", 'readonly': 'readonly' })
class lon(twf.ListLayout): id = None lon_f = twf.HiddenField() lon_t = twf.HiddenField() lon = jqui.widgets.SliderWidget(id="Longitude", options={ 'range': True, 'min': -180, 'max': 180, 'step': 0.01, 'values': [-90, -35], }, events={ 'slide': """ function( event, ui ) { $( "#lon_f" ).val(ui.values[ 0 ]); $( "#lon_t" ).val(ui.values[ 1 ]); $( "#lblLon" ).val(ui.values[ 0 ]+" a "+ui.values[ 1 ]); } """, }) lblLon = twf.TextField(label=None, size=8, attrs={ 'style': "border: 0;", 'readonly': 'readonly' })
class bsb_dep(twf.ListLayout): id = None bsb_dep_f = twf.HiddenField() bsb_dep_t = twf.HiddenField() bsb_dep = jqui.widgets.SliderWidget(id="bsb_dep", label="profundidade", options={ 'range': True, 'min': 0, 'max': 800, 'step': 5.0, 'values': [0, 800], }, events={ 'slide': """ function( event, ui ) { $( "#bsb_dep_f" ).val(ui.values[ 0 ]); $( "#bsb_dep_t" ).val(ui.values[ 1 ]); $( "#bsb_lblDep" ).val(ui.values[ 0 ]+" a "+ui.values[ 1 ]); } """, }) bsb_lblDep = twf.TextField(label=None, size=15, attrs={ 'style': "border: 0;", 'readonly': 'readonly' })
class child(twf.TableLayout): hover_help = True email_filter = twf.HiddenField() id_filter = twf.HiddenField() name = twf.TextField(help_text='Enter user name.', validator=twc.Required) login_email = twf.TextField(help_text='Enter a login email address.', validator=twc.EmailValidator(required=True))
class EditTrack(twf.TableForm): color = twf.HiddenField() pid = twf.HiddenField() track_id = twf.HiddenField() name = twf.TextField(label='Name : ', help_text="Enter the track's name", validator=twc.Validator(required=True)) submit = twf.SubmitButton(id="submit", value="Edit")
class child(twf.TableLayout): hover_help = True email_filter = twf.HiddenField() id_filter = twf.HiddenField() user_Id= twf.TextField(help_text='Enter a user id.', validator=twc.IntValidator(required=True)) licenses = twf.MultipleSelectField(help_text='Licenses to assign.', options=[], validator=twc.Required) license_type = twf.SingleSelectField(help_text='Licenes Type.', value=0, options=[], validator=twc.Required) count = twf.SingleSelectField(help_text='Number of licenses.', value=1, options=[(i, i) for i in range(1,6)], validator=twc.Required)
class EditProject(twf.TableForm): # __omit_fields__ = ['user', 'date', 'created'] IDselected = twf.HiddenField(label_text="ID selected") project_name = twf.TextField(label_text="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 samples to this project.") selected_samples = twf.HiddenField(label_text="") submit = twf.SubmitButton(id="submit", value="Edit my project")
class EditProject(twf.TableForm): pid = twf.HiddenField() name = twf.TextField(label='Name : ', validator=twc.Validator(required=True)) tracks = twf.MultipleSelectField(label='Tracks : ', css_class='track_select') submit = twf.SubmitButton(id="submit", value="Edit")
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"))
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")
class child(twf.TableLayout): id = twf.HiddenField() name = twf.TextField() status_id = twf.SingleSelectField( options=[str(r) for r in Status.query.all()]) customer_id = twf.SingleSelectField( options=[str(r) for r in People.query.all()]) assignee_id = twf.SingleSelectField( options=[str(r) for r in People.query.all()]) delivery = twf.CheckBox() address = twf.TextArea()
class child(twf.TableForm): id = twf.HiddenField() name = twf.TextField(validator=twc.Required) image = SavingFileField description = twf.TextArea( rows=5, cols=25, validator=twc.LengthValidator(max=128, min=1), ) criteria = twf.TextField(validator=twc.Required) issuer = tws.DbRadioButtonList(entity=m.Issuer)
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"))
class EditSample(twf.TableForm): IDselected = twf.HiddenField(label_text="ID selected :") project = twf.SingleSelectField( label_text="Your projects : ", help_text="the project which contains your sample is selected") name = twf.TextField(label_text="Name :", validator=twc.Required) type = twf.SingleSelectField(label_text="Type : ") protocole = twf.TextArea(label_text="Protocole :") measurements = twf.MultipleSelectField( label_text="Attached measurement(s) : ") submit = twf.SubmitButton(value="Edit my sample")
class NewTrackPrefilled(twf.TableForm): file_upload = twf.FileField(label='Upload : ', help_text='Upload file from filesystem') url = twf.TextField(label='Url : ', help_text='Provide an url') trackname = twf.TextField(label='Name : ') extension = twf.TextField( label='Extension : ', help_text= "Specify the extension of your file if it's not already provided by your file name." ) project_id = twf.HiddenField() submit = twf.SubmitButton(id="submit", value="New")
class NewTrack(twf.TableForm): file_upload = twf.FileField(label='Upload : ', help_text='Upload file from filesystem') url = twf.TextField(label='Url : ', help_text='Provide an url') smapping = twf.HiddenField() trackname = twf.TextField(label='Name : ') extension = twf.TextField( label='Extension : ', help_text= "Specify the extension of your file if it's not already provided by your file name." ) species = twf.SingleSelectField(label='Species :') assembly = twf.SingleSelectField(label='Assembly :', options=[]) submit = twf.SubmitButton(id="submit", value="New")
class child(twd.HidingTableLayout): id = twf.HiddenField() name = twf.TextField() status_id = twf.SingleSelectField( options=[str(r) for r in Status.query.all()]) customer_id = twf.SingleSelectField( options=[str(r) for r in People.query.all()]) assignee_id = twf.SingleSelectField( options=[str(r) for r in People.query.all()]) delivery = twd.HidingCheckBox(mapping={1: ['address']}) address = twf.TextArea() class items(twd.GrowingGridLayout): id = twf.HiddenField() order_id = twf.HiddenField() code = twf.SingleSelectField(options=['Red', 'Blue', 'Green']) description = twf.TextField()
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()
class child(axf.bootstrap.BootstrapFormLayout): inline_engine_name = 'genshi' template = ''' <div xmlns:py="http://genshi.edgewall.org/" py:strip="True"> <py:for each="c in w.children_hidden"> ${c.display()} </py:for> <div> <span id="${w.compound_id}:error" class="error" > <p py:for="error in w.rollup_errors" class="alert alert-danger"> <span class="glyphicon glyphicon-exclamation-sign"></span> ${error} </p> </span> </div> <div class="form-horizontal"> <div py:for="c in w.children_non_hidden" class="form-group ${((c.validator and getattr(c.validator, 'required', getattr(c.validator, 'not_empty', False))) and ' required' or '') + (c.error_msg and ' has-error' or '')}"> <label py:if="c.label != None" class="col-sm-3 control-label" for="${c.compound_id}"> $c.label </label> <div class="col-sm-7"> ${c.display()} <span id="${c.compound_id}:error" class="error help-block" py:content="c.error_msg"/> </div> <div>${w.submit.display()}</div> </div> </div> </div> ''' uid = twf.HiddenField() name = twf.TextField(label='Dashboard Name', validator=twc.Validator(required=True)) submit = twf.SubmitButton(value=l_('Save'), css_class='btn btn-default col-sm-2')
class ShareProject(twf.TableForm): pid = twf.HiddenField() circles = twf.MultipleSelectField(label='Circles : ', css_class='circle_select') submit = twf.SubmitButton(id="submit", value="Share")
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
def clone_form(user_lab, id_object): ''' to clone dynamic measurement form ''' lab = DBSession.query(Labs).filter(Labs.name == user_lab).first() #static list ] list_static = [ twf.HiddenField(id="IDselected", label_text="ID selected :"), twf.TextField(id="name", label_text="Name :", placeholder="Measurement name...", validator=twc.Validator(required=True)), 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."), twd.HidingRadioButtonList(id="upload_way", label_text='Upload my file via...', options=('my computer', 'a Vital-IT path', 'a URL'), mapping={ 'my computer': ['upload'], 'a Vital-IT path': ['vitalit_path'], 'a URL': ['url_path', 'url_up'], }), twf.FileField(id="upload", help_text='Please provide a data'), twf.TextField(id="vitalit_path", label_text="Scratch path", placeholder="/scratch/el/biorepo/dropbox/"), twf.TextField(id="url_path", label_text="File's url", 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 = [] if lab is None: print "----- no dynamic fields detected ---------" list_fields = [list_static, list_dynamic] return list_fields else: to_clone = DBSession.query(Measurements).filter( Measurements.id == int(id_object)).first() tag = "measurements" if to_clone is not None: list_dynamic_attributes = to_clone.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 to_clone 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 to_clone 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 to_clone 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 to_clone in value_object: twf_type.value = v.value list_dynamic.append(twf_type) else: print "Your measurement was not found. ID problem. id :", id_object raise list_fields = [list_static, list_dynamic] return list_fields
class EditOrderForm(twf.ListForm): css_class = 'admin-form' order_id = twf.HiddenField(key='_id') bill = twf.HiddenField(validator=twc.BoolValidator()) class ShipmentInfo(twf.ListFieldSet): label = l_("Dati Spedizione") key = 'shipment_info' receiver = twf.TextField(validator=twc.Validator(required=True), css_class="form-control", label=l_("Destinatario")) address = twf.TextField(validator=twc.Validator(required=True), css_class="form-control", label=l_("Indirizzo")) city = twf.TextField(validator=twc.Validator(required=True), css_class="form-control", label=l_("Città")) province = twf.TextField(validator=twc.Validator(required=True), css_class="form-control", label=l_("Provincia")) zip_code = twf.TextField(validator=twc.Validator(required=True), css_class="form-control", label=l_("CAP")) country = twf.SingleSelectField( css_class="form-control", prompt_text=None, label=l_("Stato"), options=twc.Deferred(lambda: [('IT', l_('Stato'))])) class Details(twf.ListFieldSet): label = None key = 'details' email = twf.TextField(validator=twc.Validator(required=True), css_class="form-control", label=l_("Email")) phone = twf.TextField(validator=twc.Validator(), css_class="form-control", label=l_("Telefono")) class BillInfo(twf.ListFieldSet): label = l_("Dati Fatturazione") key = 'bill_info' company = twf.TextField(css_class="form-control", label=l_("Ragione Sociale")) vat = twf.TextField(css_class="form-control", label=l_("Partita IVA")) fiscal_code = twf.TextField(css_class="form-control", label=l_("Codice Fiscale")) address = twf.TextField(css_class="form-control", label=l_("Indirizzo")) city = twf.TextField(css_class="form-control", label=l_("Città")) province = twf.TextField(css_class="form-control", label=l_("Provincia")) zip_code = twf.TextField(css_class="form-control", label=l_("CAP")) country = twf.SingleSelectField( css_class="form-control", prompt_text=None, label=l_("Stato"), options=twc.Deferred(lambda: [('IT', l_('Stato'))])) submit = twf.SubmitButton(value=l_('Salva'), css_class='form-control') def prepare(self): super(EditOrderForm, self).prepare() if not self.child.children.bill.value or self.child.children.bill.value == 'false': self.child.children.BillInfo.container_attrs = { 'style': 'display:none;' }
class items(twd.GrowingGridLayout): id = twf.HiddenField() order_id = twf.HiddenField() code = twf.SingleSelectField(options=['Red', 'Blue', 'Green']) description = twf.TextField()
class AddUser(twf.TableForm): cid = twf.HiddenField() mail = twf.TextField(label='e-mail : ', help_text='Enter the user e-mail.', validator=twc.EmailValidator(required=True)) submit = twf.SubmitButton(id="submit", value="Add")
class NewProject(twf.TableForm): smapping = twf.HiddenField() name = twf.TextField(label='Name') species = twf.SingleSelectField(label='Species : ') assembly = twf.SingleSelectField(label='Assembly :', options=[]) submit = twf.SubmitButton(id="submit", value="New")
class NewSequenceForm(twf.ListForm): smapping = twf.HiddenField() species = twf.SingleSelectField(label='Species : ', options=[]) assembly = twf.SingleSelectField(label='Assembly :', options=[]) submit = twf.SubmitButton(id="submit", value="New")