Commit 9d1e8fed authored by 's avatar

Added role management and fixed a few bugs:

  o images/manage went nowhere
  o text on document add form talked about adding images...
  o added role mgmgt to add forms for Folder,Document,Image
parent 217e0d7b
...@@ -11,8 +11,8 @@ ...@@ -11,8 +11,8 @@
__doc__='''Application support __doc__='''Application support
$Id: Application.py,v 1.6 1997/08/27 13:30:19 brian Exp $''' $Id: Application.py,v 1.7 1997/08/29 18:39:30 brian Exp $'''
__version__='$Revision: 1.6 $'[11:-2] __version__='$Revision: 1.7 $'[11:-2]
import Folder, regex import Folder, regex
import Globals import Globals
...@@ -21,9 +21,9 @@ from AccessControl.User import UserFolder ...@@ -21,9 +21,9 @@ from AccessControl.User import UserFolder
class Application(Folder.Folder): class Application(Folder.Folder):
title='DC Web Environment' title='Site Studio'
id =title id =title
__roles__=None # __roles__=None
web__form__method='GET' web__form__method='GET'
manage_options=Folder.Folder.manage_options+( manage_options=Folder.Folder.manage_options+(
{'icon':'App/arrow.jpg', 'label':'Application Management', {'icon':'App/arrow.jpg', 'label':'Application Management',
...@@ -136,6 +136,12 @@ if __name__ == "__main__": main() ...@@ -136,6 +136,12 @@ if __name__ == "__main__": main()
############################################################################## ##############################################################################
# #
# $Log: Application.py,v $ # $Log: Application.py,v $
# Revision 1.7 1997/08/29 18:39:30 brian
# Added role management and fixed a few bugs:
# o images/manage went nowhere
# o text on document add form talked about adding images...
# o added role mgmgt to add forms for Folder,Document,Image
#
# Revision 1.6 1997/08/27 13:30:19 brian # Revision 1.6 1997/08/27 13:30:19 brian
# Changes for UserFolder support: # Changes for UserFolder support:
# o Added support for role registration to Application.py # o Added support for role registration to Application.py
......
"""Document object""" """Document object"""
__version__='$Revision: 1.8 $'[11:-2] __version__='$Revision: 1.9 $'[11:-2]
from STPDocumentTemplate import HTML from STPDocumentTemplate import HTML
from Globals import HTMLFile from Globals import HTMLFile
from string import join, split, strip, rfind from string import join, split, strip, rfind
import AccessControl.ACL from AccessControl.Role import RoleManager
import regex import regex
class Document(HTML, AccessControl.ACL.RoleManager):
class Document(HTML, RoleManager):
"""A Document object""" """A Document object"""
meta_type ='Document' meta_type ='Document'
title='' title=''
...@@ -16,16 +21,47 @@ class Document(HTML, AccessControl.ACL.RoleManager): ...@@ -16,16 +21,47 @@ class Document(HTML, AccessControl.ACL.RoleManager):
__state_names__=HTML.__state_names__+('title','__roles__') __state_names__=HTML.__state_names__+('title','__roles__')
def document_template_form_header(self): _formhead="""
try: roles=join(self.__roles__) <TABLE>
except: roles='' <TR>
return ("""<table> <TH>Title:</TH>
<tr><th>Title:</th><td> <TD><INPUT TYPE="TEXT" NAME="title" SIZE="50" VALUE="%s"></TD>
<input type=text name=title SIZE="50" value="%s"></td></tr> </TR>
<tr><th>Roles:</th><td> <TR>
<input type=text name=roles SIZE="50" value="%s"></td></tr> <TD></TD>
</table>""" % (self.title, roles)) <TD>
<TABLE>
<TR>
<TD VALIGN="TOP">
<INPUT TYPE="RADIO" NAME="acl_type" VALUE="E"%s>
Allow users with selected roles
<BR>
<INPUT TYPE="RADIO" NAME="acl_type" VALUE="A"%s>
Allow based on default roles
<BR>
<INPUT TYPE="RADIO" NAME="acl_type" VALUE="P"%s>
Allow all users
</TD>
<TD VALIGN="TOP">
<SELECT NAME="acl_roles:list" SIZE="3" MULTIPLE>
%s
</SELECT>
</TD>
</TR>
</TABLE>
</TD>
</TR>
</TABLE><P>"""
def document_template_form_header(self):
try:
return self._formhead % (self.title, self.aclEChecked(),
self.aclAChecked(),self.aclPChecked(),
join(self.selectedRoles(),'\n')
)
except:
import sys
return '%s %s' % (sys.exc_type, sys.exc_value)
def initvars(self, mapping, vars): def initvars(self, mapping, vars):
"""Hook to override signature so we can detect whether we are """Hook to override signature so we can detect whether we are
...@@ -39,15 +75,14 @@ class Document(HTML, AccessControl.ACL.RoleManager): ...@@ -39,15 +75,14 @@ class Document(HTML, AccessControl.ACL.RoleManager):
if RESPONSE is None: return r if RESPONSE is None: return r
return decapitate(r, RESPONSE) return decapitate(r, RESPONSE)
def manage_edit(self,data,title,roles,REQUEST=None): def manage_edit(self,data,title,acl_type='A',acl_roles=[],REQUEST=None):
"""Edit method""" """Edit method"""
self.title=title self.title=title
self.parse_roles_string(roles) self._setRoles(acl_type,acl_roles)
REQUEST['CANCEL_ACTION']="%s/manage_main" % REQUEST['URL2'] REQUEST['CANCEL_ACTION']="%s/manage_main" % REQUEST['URL2']
return HTML.manage_edit(self,data,REQUEST) return HTML.manage_edit(self,data,REQUEST)
default_html="""<!--#var standard_html_header--> default_html="""<!--#var standard_html_header-->
New Document New Document
<!--#var standard_html_footer-->""" <!--#var standard_html_footer-->"""
...@@ -59,25 +94,28 @@ class DocumentHandler: ...@@ -59,25 +94,28 @@ class DocumentHandler:
manage_addDocumentForm=HTMLFile('OFS/documentAdd') manage_addDocumentForm=HTMLFile('OFS/documentAdd')
def manage_addDocument(self,id,title,roles,REQUEST,file=''): def manage_addDocument(self,REQUEST,id,title,file='',
acl_type='A',acl_roles=[]):
"""Add a new Document object""" """Add a new Document object"""
if not file: file=default_html if not file: file=default_html
i=Document(file, __name__=id) i=Document(file, __name__=id)
i.title=title i.title=title
i.parse_roles_string(roles) i._setRoles(acl_type,acl_roles)
self._setObject(id,i) self._setObject(id,i)
if REQUEST: return self.manage_main(self,REQUEST) if REQUEST: return self.manage_main(self,REQUEST)
def documentIds(self): def documentIds(self):
t=[] t=[]
for i in self.objectMap(): for i in self.objectMap():
if i['meta_type']=='Document': t.append(i['id']) if i['meta_type']=='Document':
t.append(i['id'])
return t return t
def documentValues(self): def documentValues(self):
t=[] t=[]
for i in self.objectMap(): for i in self.objectMap():
if i['meta_type']=='Document': t.append(getattr(self,i['id'])) if i['meta_type']=='Document':
t.append(getattr(self,i['id']))
return t return t
def documentItems(self): def documentItems(self):
......
"""Folder object """Folder object
$Id: Folder.py,v 1.7 1997/08/27 13:30:20 brian Exp $""" $Id: Folder.py,v 1.8 1997/08/29 18:39:31 brian Exp $"""
__version__='$Revision: 1.7 $'[11:-2] __version__='$Revision: 1.8 $'[11:-2]
from Globals import HTMLFile from Globals import HTMLFile
...@@ -11,7 +11,7 @@ from ObjectManager import ObjectManager ...@@ -11,7 +11,7 @@ from ObjectManager import ObjectManager
from Image import ImageHandler from Image import ImageHandler
from Document import DocumentHandler from Document import DocumentHandler
from AccessControl.User import UserFolderHandler from AccessControl.User import UserFolderHandler
from AccessControl.Role import RoleManager
class FolderHandler: class FolderHandler:
"""Folder object handler""" """Folder object handler"""
...@@ -24,11 +24,12 @@ class FolderHandler: ...@@ -24,11 +24,12 @@ class FolderHandler:
return Folder return Folder
return self.__class__ return self.__class__
def manage_addFolder(self,id,title,REQUEST): def manage_addFolder(self,id,title,REQUEST,acl_type='A',acl_roles=[]):
"""Add a new Folder object""" """Add a new Folder object"""
i=self.folderClass()() i=self.folderClass()()
i.id=id i.id=id
i.title=title i.title=title
i._setRoles(acl_type,acl_roles)
self._setObject(id,i) self._setObject(id,i)
return self.manage_main(self,REQUEST) return self.manage_main(self,REQUEST)
...@@ -53,8 +54,8 @@ class FolderHandler: ...@@ -53,8 +54,8 @@ class FolderHandler:
return t return t
class Folder(ObjectManager,DocumentHandler,ImageHandler, class Folder(ObjectManager,RoleManager,DocumentHandler,
FolderHandler,UserFolderHandler): ImageHandler,FolderHandler,UserFolderHandler):
"""Folder object""" """Folder object"""
meta_type='Folder' meta_type='Folder'
id ='folder' id ='folder'
...@@ -74,6 +75,8 @@ class Folder(ObjectManager,DocumentHandler,ImageHandler, ...@@ -74,6 +75,8 @@ class Folder(ObjectManager,DocumentHandler,ImageHandler,
'action':'manage_main', 'target':'manage_main'}, 'action':'manage_main', 'target':'manage_main'},
{'icon':'OFS/Properties_icon.gif', 'label':'Properties', {'icon':'OFS/Properties_icon.gif', 'label':'Properties',
'action':'manage_propertiesForm', 'target':'manage_main'}, 'action':'manage_propertiesForm', 'target':'manage_main'},
{'icon':'AccessControl/AccessControl_icon.gif', 'label':'Access Control',
'action':'manage_rolesForm', 'target':'manage_main'},
{'icon':'OFS/Help_icon.gif', 'label':'Help', {'icon':'OFS/Help_icon.gif', 'label':'Help',
'action':'manage_help', 'target':'_new'}, 'action':'manage_help', 'target':'_new'},
) )
......
"""Image object""" """Image object"""
__version__='$Revision: 1.2 $'[11:-2] __version__='$Revision: 1.3 $'[11:-2]
from Persistence import Persistent
from Globals import HTMLFile from Globals import HTMLFile
from AccessControl.Role import RoleManager
class Image(Persistent,RoleManager):
class Image:
"""Image object""" """Image object"""
meta_type ='Image' meta_type ='Image'
title='' title=''
icon ='OFS/Image_icon.gif' icon ='OFS/Image_icon.gif'
manage_editForm=HTMLFile('OFS/imageEdit') manage_editForm=HTMLFile('OFS/imageEdit')
manage =manage_editForm
def manage_edit(self,file,title,content_type=''): def manage_edit(self,file,title,content_type='',acl_type='A',acl_roles=[]):
try: headers=file.headers try: headers=file.headers
except: headers=None except: headers=None
...@@ -28,7 +29,7 @@ class Image: ...@@ -28,7 +29,7 @@ class Image:
self.content_type=headers['content-type'] self.content_type=headers['content-type']
self.data=data self.data=data
self.title=title self.title=title
self._setRoles(acl_type,acl_roles)
def _init(self,id,file,content_type=''): def _init(self,id,file,content_type=''):
try: headers=file.headers try: headers=file.headers
...@@ -50,17 +51,20 @@ class Image: ...@@ -50,17 +51,20 @@ class Image:
RESPONSE['content-type']=self.content_type RESPONSE['content-type']=self.content_type
return self.data return self.data
class ImageHandler: class ImageHandler:
"""Image object handler mixin""" """Image object handler mixin"""
meta_types=({'name':'Image', 'action':'manage_addImageForm'},) meta_types=({'name':'Image', 'action':'manage_addImageForm'},)
manage_addImageForm=HTMLFile('OFS/imageAdd') manage_addImageForm=HTMLFile('OFS/imageAdd')
def manage_addImage(self,id,file,title,REQUEST): def manage_addImage(self,id,file,title,REQUEST,acl_type='A',acl_roles=[]):
"""Add a new Image object""" """Add a new Image object"""
i=Image() i=Image()
i._init(id,file) i._init(id,file)
i.title=title i.title=title
i._setRoles(acl_type,acl_roles)
self._setObject(id,i) self._setObject(id,i)
return self.manage_main(self,REQUEST) return self.manage_main(self,REQUEST)
......
...@@ -5,9 +5,9 @@ ...@@ -5,9 +5,9 @@
<BODY BGCOLOR="#FFFFFF" LINK="#000099" VLINK="#555555" ALINK="#77003B"> <BODY BGCOLOR="#FFFFFF" LINK="#000099" VLINK="#555555" ALINK="#77003B">
<FONT SIZE="+2">New HTML Document</FONT> <FONT SIZE="+2">New HTML Document</FONT>
<P> <P>
You can create a new image in the system using the form below. You can create a new html document using the form below.
Select an image from your local computer by clicking the <I>Browse</I> You may choose to upload an existing html file from your
button. The image file you select will be uploaded to the application. local computer by clicking the <I>Browse</I> button.
<FORM ACTION="<!--#var PARENT_URL-->/manage_addDocument" METHOD="POST" <FORM ACTION="<!--#var PARENT_URL-->/manage_addDocument" METHOD="POST"
ENCTYPE="multipart/form-data" TARGET="manage_main"> ENCTYPE="multipart/form-data" TARGET="manage_main">
...@@ -23,17 +23,39 @@ ...@@ -23,17 +23,39 @@
</TD> </TD>
</TR> </TR>
<TR> <TR>
<TD ALIGN="LEFT" VALIGN="TOP"><STRONG>Roles of authorized users</STRONG></TD> <TD ALIGN="LEFT" VALIGN="TOP"><STRONG>File</STRONG></TD>
<TD ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT" VALIGN="TOP">
<INPUT TYPE="TEXT" NAME="roles" SIZE="50"> <INPUT TYPE="file" NAME="file:string" SIZE="30" VALUE="">
</TD> </TD>
</TR> </TR>
<!--#if AUTHENTICATED_USER-->
<TR> <TR>
<TD ALIGN="LEFT" VALIGN="TOP"><STRONG>File</STRONG></TD> <TD></TD>
<TD ALIGN="LEFT" VALIGN="TOP"> <TD>
<INPUT TYPE="file" NAME="file:string" SIZE="30" VALUE=""> <TABLE>
<TR>
<TD VALIGN="TOP">
<INPUT TYPE="RADIO" NAME="acl_type" VALUE="E">
Allow users with selected roles
<BR>
<INPUT TYPE="RADIO" NAME="acl_type" VALUE="A" CHECKED>
Allow based on default roles
<BR>
<INPUT TYPE="RADIO" NAME="acl_type" VALUE="P">
Allow all users
</TD>
<TD VALIGN="TOP">
<SELECT NAME="acl_roles:list" SIZE="3" MULTIPLE>
<!--#in selectedRoles-->
<!--#var sequence-item-->
<!--#/in selectedRoles-->
</SELECT>
</TD>
</TR>
</TABLE>
</TD> </TD>
</TR> </TR>
<!--#/if AUTHENTICATED_USER-->
<TR> <TR>
<TD></TD> <TD></TD>
<TD><BR><INPUT TYPE="SUBMIT" VALUE="Add Document"></TD> <TD><BR><INPUT TYPE="SUBMIT" VALUE="Add Document"></TD>
......
...@@ -15,6 +15,32 @@ ...@@ -15,6 +15,32 @@
<TD ALIGN="LEFT" VALIGN="TOP"><B>Title</B></TD> <TD ALIGN="LEFT" VALIGN="TOP"><B>Title</B></TD>
<TD ALIGN="LEFT" VALIGN="TOP"><INPUT TYPE="TEXT" NAME="title" SIZE="50"></TD> <TD ALIGN="LEFT" VALIGN="TOP"><INPUT TYPE="TEXT" NAME="title" SIZE="50"></TD>
</TR> </TR>
<TR>
<TD></TD>
<TD>
<TABLE>
<TR>
<TD VALIGN="TOP">
<INPUT TYPE="RADIO" NAME="acl_type" VALUE="E">
Allow users with selected roles
<BR>
<INPUT TYPE="RADIO" NAME="acl_type" VALUE="A" CHECKED>
Allow based on default roles
<BR>
<INPUT TYPE="RADIO" NAME="acl_type" VALUE="P">
Allow all users
</TD>
<TD VALIGN="TOP">
<SELECT NAME="acl_roles:list" SIZE="3" MULTIPLE>
<!--#in selectedRoles-->
<!--#var sequence-item-->
<!--#/in selectedRoles-->
</SELECT>
</TD>
</TR>
</TABLE>
</TD>
</TR>
<TR> <TR>
<TD></TD> <TD></TD>
<TD><BR><INPUT TYPE="SUBMIT" VALUE="Add Folder"></TD> <TD><BR><INPUT TYPE="SUBMIT" VALUE="Add Folder"></TD>
......
...@@ -27,6 +27,34 @@ ...@@ -27,6 +27,34 @@
<TD ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT" VALIGN="TOP">
<INPUT TYPE="TEXT" NAME="title" SIZE="50"></TD> <INPUT TYPE="TEXT" NAME="title" SIZE="50"></TD>
</TR> </TR>
<!--#if AUTHENTICATED_USER-->
<TR>
<TD></TD>
<TD>
<TABLE>
<TR>
<TD VALIGN="TOP">
<INPUT TYPE="RADIO" NAME="acl_type" VALUE="E">
Allow users with selected roles
<BR>
<INPUT TYPE="RADIO" NAME="acl_type" VALUE="A" CHECKED>
Allow based on default roles
<BR>
<INPUT TYPE="RADIO" NAME="acl_type" VALUE="P">
Allow all users
</TD>
<TD VALIGN="TOP">
<SELECT NAME="acl_roles:list" SIZE="3" MULTIPLE>
<!--#in selectedRoles-->
<!--#var sequence-item-->
<!--#/in selectedRoles-->
</SELECT>
</TD>
</TR>
</TABLE>
</TD>
</TR>
<!--#/if AUTHENTICATED_USER-->
<TR> <TR>
<TD></TD> <TD></TD>
<TD><BR><INPUT TYPE="SUBMIT" VALUE="Add Image"></TD> <TD><BR><INPUT TYPE="SUBMIT" VALUE="Add Image"></TD>
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<TITLE>Edit Image</TITLE> <TITLE>Edit Image</TITLE>
</HEAD> </HEAD>
<BODY BGCOLOR="#FFFFFF" LINK="#000099" VLINK="#555555" ALINK="#77003B"> <BODY BGCOLOR="#FFFFFF" LINK="#000099" VLINK="#555555" ALINK="#77003B">
<FONT SIZE="+2">New Image</FONT> <FONT SIZE="+2">Edit Image</FONT>
<P> <P>
You can update image in the system using the form below. You can update image in the system using the form below.
Select an image from your local computer by clicking the <I>Browse</I> Select an image from your local computer by clicking the <I>Browse</I>
...@@ -27,6 +27,34 @@ ...@@ -27,6 +27,34 @@
<TD ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT" VALIGN="TOP">
<INPUT TYPE="TEXT" NAME="title" SIZE="50" VALUE="<!--#var title-->"></TD> <INPUT TYPE="TEXT" NAME="title" SIZE="50" VALUE="<!--#var title-->"></TD>
</TR> </TR>
<!--#if AUTHENTICATED_USER-->
<TR>
<TD></TD>
<TD>
<TABLE>
<TR>
<TD VALIGN="TOP">
<INPUT TYPE="RADIO" NAME="acl_type" VALUE="E"<!--#var aclEChecked-->>
Allow users with selected roles
<BR>
<INPUT TYPE="RADIO" NAME="acl_type" VALUE="A"<!--#var aclAChecked-->>
Allow based on default roles
<BR>
<INPUT TYPE="RADIO" NAME="acl_type" VALUE="P"<!--#var aclPChecked-->>
Allow all users
</TD>
<TD VALIGN="TOP">
<SELECT NAME="acl_roles:list" SIZE="3" MULTIPLE>
<!--#in selectedRoles-->
<!--#var sequence-item-->
<!--#/in selectedRoles-->
</SELECT>
</TD>
</TR>
</TABLE>
</TD>
</TR>
<!--#/if AUTHENTICATED_USER-->
<TR> <TR>
<TD></TD> <TD></TD>
<TD><BR><INPUT TYPE="SUBMIT" VALUE="Change Image"></TD> <TD><BR><INPUT TYPE="SUBMIT" VALUE="Change Image"></TD>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment