From 33e83ee21ddc441fc27ffc328291a023e9e8557d Mon Sep 17 00:00:00 2001 From: bwarsaw Date: Mon, 15 Oct 2001 20:53:46 +0000 Subject: main(): category_suffix -> category, and get subcat from parts[0] Pass subcat to change_options() and show_results() calls. option_help(): Get both category and subcat from varhelp. Include the standard footer when no valid variable name is found. Be sure the form action url includes any subcat. Pass subcat to add_options_table_item() call. show_results(): category_suffix -> subcat. Be sure to include the subcat in the form action url. Pass subcat to the show_variables() call. show_variables(): Accept subcat, and pass it along to the add_options_table_item() call. add_options_table_item(): Accept subcat and pass it along to the get_item_gui_description() call. get_item_gui_description(): Accept subcat, and make sure that the VARHELP query url extension includes any subcat, otherwise the variable lookup will fail. member_options(): Include another column which contains the mod user-specific moderation bit. change_options(): Accept subcat, and be sure to pass that into the GetConfigInfo() calls. Also, set the user's Moderate flag based on the value of the user_mod key. --- Mailman/Cgi/admin.py | 117 +++++++++++++++++++++++++++++++++------------------ 1 file changed, 77 insertions(+), 40 deletions(-) (limited to 'Mailman/Cgi/admin.py') diff --git a/Mailman/Cgi/admin.py b/Mailman/Cgi/admin.py index 91523a167..185a361e4 100644 --- a/Mailman/Cgi/admin.py +++ b/Mailman/Cgi/admin.py @@ -85,10 +85,13 @@ def main(): # Which subcategory was requested? Default is `general' if len(parts) == 1: category = 'general' - category_suffix = '' + subcat = None + elif len(parts) == 2: + category = parts[1] + subcat = None else: category = parts[1] - category_suffix = category + subcat = parts[2] # Is this a log-out request? if category == 'logout': @@ -153,7 +156,7 @@ def main(): if cgidata.keys(): # There are options to change - change_options(mlist, category, cgidata, doc) + change_options(mlist, category, subcat, cgidata, doc) # Let the list sanity check the changed values mlist.CheckValues() # Additional sanity checks @@ -178,7 +181,7 @@ def main(): turned off. They will receive mail until you fix this problem.''')) # Glom up the results page and print it out - show_results(mlist, doc, category, category_suffix, cgidata) + show_results(mlist, doc, category, subcat, cgidata) print doc.Format() mlist.Save() finally: @@ -297,9 +300,13 @@ def option_help(mlist, varhelp): # Find out which category and variable help is being requested for. item = None reflist = varhelp.split('/') - if len(reflist) == 2: - category, varname = reflist - options = mlist.GetConfigInfo()[category] + if len(reflist) >= 2: + category = subcat = None + if len(reflist) == 2: + category, varname = reflist + elif len(reflist) == 3: + category, subcat, varname = reflist + options = mlist.GetConfigInfo(category, subcat) for i in options: if i and i[0] == varname: item = i @@ -308,6 +315,7 @@ def option_help(mlist, varhelp): if not item: bad = _('No valid variable name found.') add_error_message(doc, bad) + doc.AddItem(mlist.GetMailmanFooter()) print doc.Format() return # Get the details about the variable @@ -330,9 +338,13 @@ def option_help(mlist, varhelp): doc.AddItem("%s (%s): %s
" % (varname, category, description)) doc.AddItem("%s
" % elaboration) - form = Form("%s/%s" % (mlist.GetScriptURL('admin'), category)) + if subcat: + url = '%s/%s/%s' % (mlist.GetScriptURL('admin'), category, subcat) + else: + url = '%s/%s' % (mlist.GetScriptURL('admin'), category) + form = Form(url) valtab = Table(cellspacing=3, cellpadding=4, width='100%') - add_options_table_item(mlist, category, valtab, item, detailsp=0) + add_options_table_item(mlist, category, subcat, valtab, item, detailsp=0) form.AddItem(valtab) form.AddItem('
') form.AddItem(Center(submit_button())) @@ -343,15 +355,19 @@ def option_help(mlist, varhelp): pages that are displaying this option for this mailing list. You can also """)) - doc.AddItem(Link('%s/%s' % (mlist.GetScriptURL('admin'), category), - _('return to the %(category)s options page.'))) + adminurl = mlist.GetScriptURL('admin') + if subcat: + url = '%s/%s/%s' % (adminurl, category, subcat) + else: + url = '%s/%s' % (adminurl, category) + doc.AddItem(Link(url, _('return to the %(category)s options page.'))) doc.AddItem('') doc.AddItem(mlist.GetMailmanFooter()) print doc.Format() -def show_results(mlist, doc, category, category_suffix, cgidata): +def show_results(mlist, doc, category, subcat, cgidata): # Produce the results page adminurl = mlist.GetScriptURL('admin') categories = mlist.GetConfigCategories() @@ -395,6 +411,7 @@ def show_results(mlist, doc, category, category_suffix, cgidata): categorykeys = categories.keys() half = len(categorykeys) / 2 counter = 0 + subcat = None for k in categorykeys: label = _(categories[k][0]) url = '%s/%s' % (adminurl, k) @@ -434,14 +451,14 @@ def show_results(mlist, doc, category, category_suffix, cgidata): # Now we need to craft the form that will be submitted, which will contain # all the variable settings, etc. This is a bit of a kludge because we # know that the autoreply and members categories supports file uploads. - if category_suffix: - encoding = None - if category_suffix in ('autoreply', 'members'): - # These have file uploads - encoding = 'multipart/form-data' - form = Form('%s/%s' % (adminurl, category_suffix), encoding=encoding) + encoding = None + if category in ('autoreply', 'members'): + encoding = 'multipart/form-data' + if subcat: + form = Form('%s/%s/%s' % (adminurl, category, subcat), + encoding=encoding) else: - form = Form(adminurl) + form = Form('%s/%s' % (adminurl, category), encoding=encoding) form.AddItem( _('''Make your changes in the following section, then submit them using the Submit Your Changes button below.''') @@ -470,7 +487,7 @@ def show_results(mlist, doc, category, category_suffix, cgidata): form.AddItem(Center(password_inputs())) form.AddItem(Center(submit_button())) else: - form.AddItem(show_variables(mlist, category, cgidata, doc)) + form.AddItem(show_variables(mlist, category, subcat, cgidata, doc)) form.AddItem(Center(submit_button())) # Add the separator form.AddItem('