[Mailman-Developers] admindb.py heldmsg template

Ricardo Kustner ricardo@rixhq.nu
Mon, 14 Feb 2000 16:44:07 +0100


--h31gzZEtNLTqOjlF
Content-Type: text/plain; charset=us-ascii

Hi,

well... I've made some more changes in admindb.py in my local copy of MM
(cvs version) ... I've replaced the part that generates the html for messages
that are held for approval with a template (using the neat mlist.ParseTags() function)... 
so this way it's much easier (IMHO) to make changes in the functionality 
and gives the admin more freedom in designing the admin pages. 
I've seen a lot of place in the MM code where html is being generated by python
code... I personally think that the html should be left outside the code as much
as possible ... would also make it a lot easier to translate the output to other
languages, doesn't it?
Maybe it seems a bit silly that i focus so much on such a small part of MM, but
the admindb pages are important for the way i handle our mailinglist plus I have
some ideas i'd like to implement.
In case anyone is interested, below is my updated patch, and I'll attach a
sample heldmsg.html template (oh look a html attachment! :) )

Ricardo.

*** admindb.py	Mon Feb 14 16:25:43 2000
--- /usr/local/cvs/mailman/Mailman/Cgi/admindb.py	Mon Nov 15 23:29:46 1999
***************
*** 195,211 ****
      form.AddItem(Center(Header(2, msg)))
      try:
          fp = open(os.path.join(mm_cfg.DATA_DIR, filename))
! 	msg_header = ""
! 	msg_body = ""
! 	for line in fp.readlines(mm_cfg.ADMINDB_PAGE_TEXT_LIMIT):
! 		if msg_body == "":
! 			if line != "\n":
! 				msg_header = msg_header + line
! 			else:
! 				msg_body = line
! 		else:
! 			msg_body = msg_body + line	
! 
          fp.close()
      except IOError, (code, msg):
          if code == ENOENT:
--- 195,201 ----
      form.AddItem(Center(Header(2, msg)))
      try:
          fp = open(os.path.join(mm_cfg.DATA_DIR, filename))
!         text = fp.read(mm_cfg.ADMINDB_PAGE_TEXT_LIMIT)
          fp.close()
      except IOError, (code, msg):
          if code == ENOENT:
***************
*** 219,242 ****
                  pass
              return
          raise
! 
!     replacements = mlist.GetStandardReplacements()
! 
!     replacements['<mm-heldmsg-from>'] = sender
!     replacements['<mm-heldmsg-reason>'] = reason
!     replacements['<mm-heldmsg-subject>'] = subject 
!     replacements['<mm-heldmsg-id>'] = `id`
!     replacements['<mm-heldmsg-comment>'] = ("Please do *not* post administrative requests"
                         " to the mailing list!  If you wish to subscribe,"
                         " visit %s or send a 'help' message to the"
                         " the request address, %s , for instructions"
                         % (mlist.GetAbsoluteScriptURL('listinfo'),
!                           mlist.GetRequestEmail()))
!     replacements['<mm-heldmsg-header>'] = msg_header
!     replacements['<mm-heldmsg-excerpt>'] = msg_body
! 
!     form.AddItem(mlist.ParseTags('heldmsg.html', replacements))
! 
      form.AddItem('<p>')
  
  
--- 209,239 ----
                  pass
              return
          raise
!     t = Table(cellspacing=0, cellpadding=0)
!     t.AddRow([Bold('From:'), sender])
!     t.AddRow([Bold('Reason:'), reason])
!     t.AddRow([Bold('Subject:'), subject])
!     t.AddRow([
!         Bold('Action:'),
!         RadioButtonArray(id, ("Approve", "Reject", "Discard (eg, spam)"))
!         ])
!     t.AddRow([
! 	Bold('If you reject this post, explain (optional):'),
! 	TextArea('comment-%d' % id, rows=4, cols=60,
!                  text=("Please do *not* post administrative requests"
                         " to the mailing list!  If you wish to subscribe,"
                         " visit %s or send a 'help' message to the"
                         " the request address, %s , for instructions"
                         % (mlist.GetAbsoluteScriptURL('listinfo'),
!                           mlist.GetRequestEmail())))
!         ])
!     row, col = t.GetCurrentRowIndex(), t.GetCurrentCellIndex()
!     t.AddCellInfo(row, col, colspan=3)
!     t.AddRow([Bold('Message Excerpt:'),
!               TextArea('fulltext-%d' % id, text, rows=10, cols=60)])
!     row, col = t.GetCurrentRowIndex(), t.GetCurrentCellIndex()
!     t.AddCellInfo(row, col, colspan=3)
!     form.AddItem(t)
      form.AddItem('<p>')
  
  



--h31gzZEtNLTqOjlF
Content-Type: text/html
Content-Disposition: attachment; filename="heldmsg.html"

<table cellpadding=0 cellspacing=0>
    <tr>
      <td><strong>From:</strong></td>
      <td><MM-heldmsg-from></td>
    </tr>
    <tr>
      <td><strong>Reason:</strong></td>
      <td><MM-heldmsg-reason></td>
    </tr>
    <tr>
      <td><strong>Subject:</strong></td>
      <td><MM-heldmsg-subject></td>
    </tr>
    <tr>
      <td><strong>If you reject this post, explain (optional):</strong></td>
      <td COLSPAN=3>
<TEXTAREA NAME=comment-<MM-heldmsg-ID> ROWS=4 COLS=60 WRAP=soft>
<MM-heldmsg-comment>
</TEXTAREA>
      </td>
    </tr>
    <tr>
      <td><strong>Message Header:</strong></td>
      <td>
<TEXTAREA NAME=header-<MM-heldmsg-ID> ROWS=3 COLS=60 WRAP=soft>
<MM-heldmsg-header>
</TEXTAREA>
      </td>
    </tr>
    <tr>
      <td><strong>Message Excerpt:</strong></td>
      <td>
<TEXTAREA NAME=fulltext-<MM-heldmsg-ID> ROWS=10 COLS=60 WRAP=soft>
<MM-heldmsg-excerpt>
</TEXTAREA>
      </td>
    </tr>
    <tr>
      <td><strong>Action:</strong></td>
      <td COLSPAN=3>
          <table CELLSPACING=5>
            <tr>
              <td><INPUT name="<MM-heldmsg-ID>" type="RADIO" value="0"></td>
              <td>Approve</td>
              <td><INPUT name="<MM-heldmsg-ID>" type="RADIO" value="1"></td>
              <td>Reject</td>
              <td><INPUT name="<MM-heldmsg-ID>" type="RADIO" value="2"></td>
              <td>Discard (eg, spam)</td>
            </tr>
          </table>
</td>
    </tr>
</table>


--h31gzZEtNLTqOjlF--