Package bodhi :: Module widgets
[hide private]
[frames] | no frames]

Source Code for Module bodhi.widgets

 1  # $Id: $ 
 2  # This program is free software; you can redistribute it and/or modify 
 3  # it under the terms of the GNU General Public License as published by 
 4  # the Free Software Foundation; version 2 of the License. 
 5  # 
 6  # This program is distributed in the hope that it will be useful, 
 7  # but WITHOUT ANY WARRANTY; without even the implied warranty of 
 8  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
 9  # GNU Library General Public License for more details. 
10  # 
11  # You should have received a copy of the GNU General Public License 
12  # along with this program; if not, write to the Free Software 
13  # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 
14   
15  from bodhi.util import get_release_names, get_release_tuples 
16  from bodhi.validators import * 
17   
18  from turbogears import validators, url, config 
19  from turbogears.widgets import (Form, TextField, SubmitButton, TextArea, 
20                                  AutoCompleteField, SingleSelectField, CheckBox, 
21                                  HiddenField, RadioButtonList) 
22   
23 -class CommentForm(Form):
24 template = "bodhi.templates.commentform" 25 submit_text = "Add Comment" 26 fields = [ 27 TextArea(name='text', label='', 28 validator=validators.UnicodeString(), 29 rows=3, cols=40), 30 HiddenField(name='title'), 31 # We're currently hardcoding the karma radio buttons by hand in the 32 # commentform template, because the RadioButtonList is ugly 33 ]
34
35 -class SearchForm(Form):
36 template = "bodhi.templates.searchform" 37 fields = [ 38 TextField("search", default=" Package | Bug # | CVE ", 39 attrs={ 'size' : 20 }), 40 ]
41
42 -class NewUpdateForm(Form):
43 template = "bodhi.templates.new" 44 submit_text = "Add Update" 45 update_types = config.get('update_types').split() 46 fields = [ 47 AutoCompleteField('builds', label='Package', 48 search_controller=url('/new/search'), 49 search_param='name', result_name='pkgs', 50 template='bodhi.templates.packagefield', 51 validator=AutoCompleteValidator()), 52 SingleSelectField('release', options=get_release_names, 53 validator=validators.OneOf(get_release_tuples())), 54 SingleSelectField('type', options=update_types, 55 validator=validators.OneOf(update_types)), 56 TextField('bugs', validator=BugValidator(), 57 attrs={'title' : 'A space or comma delimited list of ' + 58 'bug numbers. Example: #1234, 56 789'}), 59 TextField('cves', validator=CVEValidator(), label='CVEs', 60 attrs={'title' : 'A space or comma delimited list of ' + 61 'CVE IDs.'}), 62 TextArea('notes', validator=validators.UnicodeString(), 63 rows=20, cols=65, 64 attrs={'title' : 'Some optional details about this ' + 65 'update that will appear in the notice'}), 66 CheckBox(name='close_bugs', help_text='Automatically close bugs', 67 default=True), 68 HiddenField('edited', default=None), 69 ]
70
71 -class OkCancelForm(Form):
72 name = "okcancelform" 73 member_widgets = ["ok", "cancel"] 74 params = ["action", "method"] 75 ok = SubmitButton('ok') 76 cancel = SubmitButton('cancel') 77 78 template = """ 79 <form xmlns:py="http://purl.org/kid/ns#" 80 name="${name}" 81 action="${action}" 82 method="${method}" 83 class="okcancelform" 84 > 85 <div > 86 <div py:content="ok.display('Ok')" /> 87 <div py:content="cancel.display('Cancel')" /> 88 </div> 89 </form> 90 """
91