Esempio n. 1
0
class TaskSearchForm(RemoteForm): 
    template = "bkr.server.templates.task_search_form"
    params = ['options','hidden']
    fields = [HiddenField(name='system_id', validator=validators.Int()),
              HiddenField(name='distro_id', validator=validators.Int()),
              HiddenField(name='distro_tree_id', validator=validators.Int()),
              HiddenField(name='task_id', validator=validators.Int()),
              TextField(name='task', label=_(u'Task')),
              TextField(name='version', label=_(u'Version')),
              TextField(name='system', label=_(u'System')),
              SingleSelectField(name='arch_id', label=_(u'Arch'),validator=validators.Int(),
                                options=model.Arch.get_all),
              TextField(name='distro', label=_(u'Distro')),
              TextField(name='whiteboard', label=_(u'Recipe Whiteboard')),
              SingleSelectField(name='osmajor_id', label=_(u'Family'),validator=validators.Int(),
                                options=lambda: [(0, 'All')] + [(m.id, m.osmajor) for m
                                    in model.OSMajor.ordered_by_osmajor(model.OSMajor.used_by_any_recipe())]),
              SingleSelectField(name='status', label=_(u'Status'), validator=ValidEnumValue(model.TaskStatus),
                                options=lambda: [(None, 'All')] + [(status, status.value) for status in model.TaskStatus]),
              SingleSelectField(name='result', label=_(u'Result'), validator=ValidEnumValue(model.TaskResult),
                                options=lambda: [(None, 'All')] + [(result, result.value) for result in model.TaskResult]),
             ]
    before = 'task_search_before()'
    on_complete = 'task_search_complete()'
    submit_text = _(u'Submit Query')

    def __init__(self, *args, **kw):
        super(TaskSearchForm,self).__init__(*args,**kw)
        self.javascript.extend([LocalJSLink('bkr', '/static/javascript/loader_v2.js')])

    def update_params(self, d):
        super(TaskSearchForm, self).update_params(d)
        if 'arch_id' in d['options']:
            d['arch_id'] = d['options']['arch_id']
Esempio n. 2
0
def get_album_fields():
    options = []
    options.append(('edit', 'Edit'))
    options.append(('delete', 'Delete'))
    fields = [
        HiddenField(name='referer'),
        HiddenField(name='id'),
        TextField(name='name',
                  label='Name',
                  attrs={
                      'size': 64,
                      'maxlength': 256
                  },
                  validator=v.UnicodeString),
        TextField(name='mb_id',
                  label='MB id',
                  attrs={
                      'size': 37,
                      'maxlength': 64
                  },
                  validator=v.UnicodeString),
        TextField(name='asin',
                  label='ASIN',
                  attrs={
                      'size': 20,
                      'maxlength': 64
                  },
                  validator=v.UnicodeString),
        #TextField(name='trackcount', label='trackcount', attrs={'size': 4, 'maxlength': 10}, validator=v.UnicodeString),
        SingleSelectField(name='operation', options=options),
    ]
    return fields
Esempio n. 3
0
def get_artist_fields():
    options = []
    options.append(('edit', 'Edit'))
    options.append(('delete', 'Delete'))
    options.append((
        'merge',
        'Merge all records for this artist with Merge Artist Id; Then Delete'))
    fields = [
        HiddenField(name='referer'),
        HiddenField(name='id'),
        TextField(name='name',
                  label='Name',
                  attrs={
                      'size': 64,
                      'maxlength': 256
                  },
                  validator=v.UnicodeString),
        TextField(name='mb_id',
                  label='MB id',
                  attrs={
                      'size': 37,
                      'maxlength': 64
                  },
                  validator=v.UnicodeString),
        TextField(name='mergeid',
                  label='Merge Artist Id',
                  attrs={
                      'size': 12,
                      'maxlength': 12
                  }),
        SingleSelectField(name='operation', options=options),
    ]
    return fields
Esempio n. 4
0
class JobWhiteboard(RPC, CompoundWidget):
    """
    Widget for displaying/updating a job's whiteboard. Saves asynchronously using js.
    """

    template = 'bkr.server.templates.job_whiteboard'
    hidden_id = HiddenField(name='id')
    field = TextField(name='whiteboard')
    member_widgets = ['hidden_id', 'field']
    params = ['action', 'form_attrs', 'job_id', 'readonly']
    params_doc = {'action': 'Form action (URL to submit to)',
                  'form_attrs': 'Additional HTML attributes to set on the <form>',
                  'job_id': 'Job id whose whiteboard is being displayed in this widget',
                  'readonly': 'Whether changes to the whiteboard are forbidden'}
    action = '/jobs/update'
    form_attrs = {}
    readonly = False
    # these are references to js functions defined in the widget template:
    before = 'job_whiteboard_before()'
    on_complete = 'job_whiteboard_complete()'
    on_success = 'job_whiteboard_save_success()'
    on_failure = 'job_whiteboard_save_failure()'

    # taken from turbogears.widgets.RemoteForm
    def update_params(self, d):
        super(JobWhiteboard, self).update_params(d)
        d['form_attrs']['onsubmit'] = "return !remoteFormRequest(this, null, %s);" % (
            jsonify_for_html(self.get_options(d)))
Esempio n. 5
0
class SearchForm(Form):
    template = "bodhi.templates.searchform"
    fields = [
        TextField("search",
                  default="  Package | Bug # | CVE  ",
                  attrs={'size': 25}),
    ]
Esempio n. 6
0
class BidderFields(WidgetsList):
    """Replace to your Fields"""
    name = TextField(name="Bidder_name", label="Bidder Name")
    display = TextField(name="display_name", label="Display Name")
    status = SingleSelectField("status",   
                                options=["DISABLED","LOCKED","ENABLED"],  
                                default="DISABLED")
    groups = CheckBoxList(label = "Groups", name= "Bidder_groups", validator=validators.Int,
                          options=[(entry.group_id, entry.group_name) for entry in Group.select()])

    password = PasswordField(
      label=_(u'Password'),
      attrs=dict(maxlength=50),
      help_text=_(u'Specify your password.'))
    password_confirm = PasswordField(
      label=_(u'Confirm'),
      attrs=dict(maxlength=50),
     help_text=_(u'Enter the password again to confirm.')) 
Esempio n. 7
0
 def __init__(self,*args,**kw):
     super(JobMatrixReport,self).__init__(*args, **kw)
     self.class_name = self.__class__.__name__
     self.nack_list = CheckBoxList("Hide naks",validator=self.default_validator)
     self.whiteboard = MultipleSelectField('whiteboard', label='Whiteboard', attrs={'size':5, 'class':'whiteboard'}, validator=self.default_validator)
     self.job_ids = TextArea('job_ids',label='Job ID', rows=7,cols=7, validator=self.default_validator)
     self.whiteboard_filter = TextField('whiteboard_filter', label='Filter by')
     self.whiteboard_filter_button = MyButton(name='do_filter', type='button')
     self.name='remote_form'
     self.action = '.'
Esempio n. 8
0
class LabInfoForm(HorizontalForm):
    fields = [
        HiddenField(name="id"),
        HiddenField(name="labinfo"),
        TextField(name='orig_cost', label=_(u'Original Cost'),
            validator=validators.Money()),
        TextField(name='curr_cost', label=_(u'Current Cost'),
            validator=validators.Money()),
        TextField(name='dimensions', label=_(u'Dimensions')),
        TextField(name='weight', label=_(u'Weight'),
            validator=validators.Int()),
        TextField(name='wattage', label=_(u'Wattage'),
            validator=validators.Int()),
        TextField(name='cooling', label=_(u'Cooling'),
            validator=validators.Int()),
    ]
    submit_text = _(u'Save Lab Info Changes')

    def update_params(self, d):
        super(LabInfoForm, self).update_params(d)
        if 'labinfo' in d['value']:
            if d['value']['labinfo']:
                labinfo = d['value']['labinfo']
                d['value']['orig_cost'] = labinfo.orig_cost
                d['value']['curr_cost'] = labinfo.curr_cost
                d['value']['dimensions'] = labinfo.dimensions
                d['value']['weight'] = labinfo.weight
                d['value']['wattage'] = labinfo.wattage
                d['value']['cooling'] = labinfo.cooling
Esempio n. 9
0
 def __init__(self, *args, **kw):
     super(SystemInstallOptions, self).__init__(*args, **kw)
     self.id                = HiddenField(name="id")
     self.prov_arch         = SingleSelectField(name='prov_arch',
                              label=_(u'Arch'),
                              options=[],
                              validator=validators.NotEmpty())
     self.prov_osmajor      = SingleSelectField(name='prov_osmajor',
                              label=_(u'Family'),
                              options=lambda: [(0, 'All')] +
                                 [(m.id, m.osmajor) for m in model.OSMajor.ordered_by_osmajor()],
                              validator=validators.NotEmpty())
     self.prov_osversion    = SingleSelectField(name='prov_osversion',
                              label=_(u'Update'),
                              options=[(0,u'All')],
                              validator=validators.NotEmpty())
     self.prov_ksmeta       = TextField(name='prov_ksmeta', 
                                  label=_(u'Kickstart Metadata'))
     self.prov_koptions     = TextField(name='prov_koptions', 
                                    label=_(u'Kernel Options'))
     self.prov_koptionspost = TextField(name='prov_koptionspost',
                                        label=_(u'Kernel Options Post'))
Esempio n. 10
0
class CommentCaptchaForm(Form):
    template = "bodhi.templates.captchacommentform"
    submit_text = "Add Comment"
    fields = [
            TextArea(name='text', label='',
                     validator=validators.All(
                         validators.NotEmpty(),
                         validators.UnicodeString()),
                     rows=3, cols=40),
            HiddenField(name='title',
                        validator=validators.All(
                            validators.NotEmpty(),
                            validators.UnicodeString())),
            TextField(name='author', label='Author',
                      default='E-Mail Address',
                      validator=validators.Email()),
            CaptchaField(name='captcha', label='Enter the code shown')
    ]
Esempio n. 11
0
class ExternalReportsController(RPCRoot):

    id = HiddenField(name='id')
    name = TextField(name='name',
                     label=_(u'Report Name'),
                     attrs={'maxlength': 100},
                     validator=validators.NotEmpty())
    url = TextField(name='url',
                    label=_(u'URL'),
                    attrs={'maxlength': 10000},
                    validator=validators.NotEmpty())
    description = TextArea(name='description',
                           label=_(u'Description'),
                           attrs={
                               'cols': '27',
                               'rows': '10'
                           })
    external_report_form = TableForm(
        fields=[id, name, url, description],
        submit_text=_(u'Save'),
    )

    delete_link = DeleteLinkWidgetForm()

    @expose('bkr.server.templates.external_reports')
    def index(self):
        all_reports = ExternalReport.query.all()
        if not all_reports:
            all_reports = []
        return dict(
            action=url('new'),
            delete_link=self.delete_link,
            title='External Reports',
            value=all_reports,
        )

    @identity.require(identity.in_group('admin'))
    @expose(template='bkr.server.templates.form-post')
    def new(self, **kw):
        return dict(
            form=self.external_report_form,
            action=url('save'),
            options=None,
            value=kw,
            title='New External Report',
        )

    @identity.require(identity.in_group("admin"))
    @expose('bkr.server.templates.form-post')
    def edit(self, id=None, **kw):
        return dict(
            form=self.external_report_form,
            action=url('save'),
            options={},
            title='Edit External Report',
            value=id and ExternalReport.by_id(id) or kw,
        )

    @identity.require(identity.in_group("admin"))
    @expose()
    def delete(self, id):
        report = ExternalReport.by_id(id)
        report_name = report.name
        session.delete(report)
        flash(_(u'Deleted report %s' % report_name))
        redirect('.')

    @identity.require(identity.in_group("admin"))
    @expose()
    @validate(external_report_form)
    @error_handler(edit)
    def save(self, **kw):
        if kw.get('id'):
            report = ExternalReport.by_id(kw['id'])
        else:
            report = ExternalReport()
        report.name = kw.get('name')
        report.url = kw.get('url')
        report.description = kw.get('description')
        session.add(report)
        flash(_(u"%s saved" % report.name))
        redirect(".")
Esempio n. 12
0
 def __init__(self, *args, **kw):
     super(SystemKeys, self).__init__(*args, **kw)
     self.id = HiddenField(name="id")
     self.key_name = TextField(name='key_name', label=_(u'Key'))
     self.key_value = TextField(name='key_value', label=_(u'Value'))
Esempio n. 13
0
    def __init__(self, table, search_controller=None, extra_selects=None,
            extra_inputs=None, extra_hiddens=None, enable_custom_columns=False,
            *args, **kw):
        super(SearchBar,self).__init__(*args, **kw)
        self.enable_custom_columns = enable_custom_columns
        self.search_controller=search_controller
        self.repetitions = 1
        self.extra_hiddens = extra_hiddens
        self.default_result_columns = {}
        table_field = SingleSelectFieldJSON(name="table",
                options=sorted(table.keys()),
                validator=validators.NotEmpty())
        operation_field = SingleSelectFieldJSON(name="operation", options=[None], validator=validators.NotEmpty())
        value_field = TextFieldJSON(name="value")

        self.fields = [table_field, operation_field, value_field]
        new_selects = []
        self.extra_callbacks = {} 
        self.search_object = jsonify_for_html(table)
            
        if extra_selects is not None: 
            new_class = [] 
            for elem in extra_selects:
                if elem.has_key('display'):
                    if elem['display'] == 'none':
                        new_class.append('hide_parent')
                callback = elem.get('callback',None)
                if callback:
                    self.extra_callbacks[elem['name']] = callback 
                new_select = SingleSelectFieldJSON(name=elem['name'],options=[None], css_classes = new_class, validator=validators.NotEmpty(),for_column=elem['column'] )
                if elem['name'] == 'keyvalue':
                    self.keyvaluevalue = new_select
 
                if elem.has_key('pos'):
                    self.fields.insert(elem['pos'] - 1,new_select)
                else:
                    self.fields.append(new_select) 

        new_inputs = []
        if extra_inputs is not None:
            for the_name in extra_inputs:
                new_input = TextField(name=the_name,display='none')
                new_inputs.append(new_input) 

        if 'simplesearch_label' in kw:
            self.simplesearch_label = kw['simplesearch_label']
        else:
            self.simplesearch_label = 'Search'

        self.quickly_searches = []
        if 'quick_searches' in kw:
            if kw['quick_searches'] is not None: 
                for elem,name in kw['quick_searches']:
                    vals = elem.split('-')
                    if len(vals) != 3:
                        log.error('Quick searches expects vals as <column>-<operation>-<value>. The following is incorrect: %s' % (elem)) 
                    else: 
                        self.quickly_searches.append((name, '%s-%s-%s' % (vals[0],vals[1],vals[2])))
        self.date_picker = jsonify_for_html(kw.get('date_picker',list()) )
        controllers = kw.get('table_search_controllers',dict())  
        self.table_search_controllers_stringified = str(controllers)
        self.extra_callbacks_stringified = str(self.extra_callbacks)
        self.fields.extend(new_inputs)
        self.fields.extend(new_selects) 
Esempio n. 14
0
def get_track_fields():
    options = []
    options.append(('edit', 'Edit'))
    options.append(('delete', 'Delete'))
    fields = [
        HiddenField(name='referer'),
        HiddenField(name='id'),
        TextField(name='mb_id',
                  label='MB Id',
                  attrs={
                      'size': 37,
                      'maxlength': 64
                  },
                  validator=v.UnicodeString),
        TextField(name='path',
                  label='Path',
                  attrs={
                      'size': 24,
                      'maxlength': 512
                  },
                  validator=v.UnicodeString),
        TextField(name='title',
                  label='Title',
                  attrs={
                      'size': 64,
                      'maxlength': 256
                  },
                  validator=v.UnicodeString),
        TextField(name='artist',
                  label='Artist',
                  attrs={
                      'size': 64,
                      'maxlength': 256
                  },
                  validator=v.UnicodeString),
        TextField(name='album',
                  label='Album',
                  attrs={
                      'size': 64,
                      'maxlength': 256
                  },
                  validator=v.UnicodeString),
        TextField(name='tracknum',
                  label='Tracknum',
                  attrs={
                      'size': 3,
                      'maxlength': 3
                  },
                  validator=v.Int),
        TextField(name='secs',
                  label='Secs',
                  attrs={
                      'size': 10,
                      'maxlength': 10
                  },
                  validator=v.Number),
        TextField(name='zsecs',
                  label='ZSecs',
                  attrs={
                      'size': 10,
                      'maxlength': 10
                  },
                  validator=v.Number),
        TextField(name='md5',
                  label='MD5',
                  attrs={
                      'size': 32,
                      'maxlength': 64
                  },
                  validator=v.UnicodeString),
        TextField(name='source',
                  label='Source',
                  attrs={
                      'size': 32,
                      'maxlength': 64
                  },
                  validator=v.UnicodeString),
        TextField(name='bytes',
                  label='Bytes',
                  attrs={
                      'size': 12,
                      'maxlength': 32
                  },
                  validator=v.Int),
        CheckBox(name='compilation',
                 label='Compilation',
                 attrs={
                     'size': 5,
                     'maxlength': 5
                 }),
        SingleSelectField(name='operation', options=options),
    ]
    return fields
Esempio n. 15
0
class NewUpdateForm(Form):
    template = "bodhi.templates.new"
    submit_text = "Save Update"
    update_types = config.get('update_types').split()
    request_types = ['Testing', 'Stable', 'None', None]
    fields = [
            AutoCompleteField('builds', label='Package',
                              search_controller=url('/new/search'),
                              search_param='name', result_name='pkgs',
                              template='bodhi.templates.packagefield',
                              validator=AutoCompleteValidator()),
            CheckBox('inheritance', label='Follow Build inheritance',
                     validator=validators.StringBool(),
                     default=False, attrs={'title' : 'Build Inheritance - '
                                                     'TODO'}),
            SingleSelectField('type_', label='Type', options=update_types,
                              validator=validators.OneOf(update_types)),
            SingleSelectField('request', options=request_types,
                              validator=validators.OneOf(request_types +
                                  [r.lower() for r in request_types if r]),
                              default='testing'),
            TextField('bugs', validator=BugValidator(),
                      attrs={'title' : 'Bug Numbers - A space or comma '
                                       'delimited list of bug numbers or '
                                       'aliases.  Example: #1234, 789 '
                                       'CVE-2008-0001'}),
            TextArea('notes', validator=validators.UnicodeString(),
                     rows=13, cols=65,
                     attrs={'title' : 'Advisory Notes - <p>Some details '
                                      'about this update that will appear in '
                                      'the notice.</p>'
                                      '<p><strong>Example:</strong><br />'
                                      'This is an update that fixes problems with '
                                      '**<strong>connecting to a share</strong>**.</p>'
                                      '<p>The following things *<em>break</em>*:</p>'
                                      '<p>* Browsing with `<code>gnome-app-install</code>`<br />'
                                      '* Emailing</p>'}),
            CheckBox(name='close_bugs', help_text='Automatically close bugs',
                     validator=validators.StringBool(),
                     default=True, attrs={'title' : 'Close Bugs - '
                                                    'Automatically close bugs '
                                                    'when this update is '
                                                    'pushed as stable'}),
            HiddenField('edited', default=None),
            CheckBox(name='suggest_reboot', label='Suggest Reboot',
                     validator=validators.StringBool(),
                     default=False, attrs={'title': 'Suggest Reboot - '
                                                    'Recommend that the user '
                                                    'restarts their machine '
                                                    'after installing this '
                                                    'update'}),
            CheckBox(name='autokarma', label='Enable karma automatism',
                     default=True, validator=validators.StringBool(),
                     attrs={'onchange':
                         'if ($("#form_autokarma").attr("checked")) {'
                            '$("#form_stable_karma").attr("disabled", false);'
                            'if ($("#form_stable_karma").attr("value") == 0) $("#form_stable_karma").attr("value", 3);'
                            '$("#form_unstable_karma").attr("disabled", false);'
                            'if ($("#form_unstable_karma").attr("value") == 0) $("#form_unstable_karma").attr("value", -3);'
                         ' } else { '
                            '$("#form_stable_karma").attr("disabled", true);'
                            '$("#form_unstable_karma").attr("disabled", true);'
                         '}',
                    'title': 'Karma Automatism - Enable update request '
                             'automation based on user feedback',
                            }),
            TextField('stable_karma', label='Threshold for pushing to stable',
                      validator=validators.Int(), default='3',
                      attrs={'title' : 'Stable Karma - The threshold for '
                             'automatically pushing this update to stable',
                             'size' : '1'}),
            TextField('unstable_karma', label='Threshold for unpushing',
                      validator=validators.Int(), default='-3',
                      attrs={'title' : 'Unstable Karma - The threshold for '
                             'automatically unpushing an unstable update',
                             'size' : '1'})
    ]