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 @@
__doc__='''Application support
$Id: Application.py,v 1.6 1997/08/27 13:30:19 brian Exp $'''
__version__='$Revision: 1.6 $'[11:-2]
$Id: Application.py,v 1.7 1997/08/29 18:39:30 brian Exp $'''
__version__='$Revision: 1.7 $'[11:-2]
import Folder, regex
import Globals
......@@ -21,9 +21,9 @@ from AccessControl.User import UserFolder
class Application(Folder.Folder):
title='DC Web Environment'
title='Site Studio'
id =title
__roles__=None
# __roles__=None
web__form__method='GET'
manage_options=Folder.Folder.manage_options+(
{'icon':'App/arrow.jpg', 'label':'Application Management',
......@@ -136,6 +136,12 @@ if __name__ == "__main__": main()
##############################################################################
#
# $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
# Changes for UserFolder support:
# o Added support for role registration to Application.py
......
"""Document object"""
__version__='$Revision: 1.8 $'[11:-2]
__version__='$Revision: 1.9 $'[11:-2]
from STPDocumentTemplate import HTML
from Globals import HTMLFile
from string import join, split, strip, rfind
import AccessControl.ACL
from AccessControl.Role import RoleManager
import regex
class Document(HTML, AccessControl.ACL.RoleManager):
class Document(HTML, RoleManager):
"""A Document object"""
meta_type ='Document'
title=''
......@@ -16,16 +21,47 @@ class Document(HTML, AccessControl.ACL.RoleManager):
__state_names__=HTML.__state_names__+('title','__roles__')
def document_template_form_header(self):
try: roles=join(self.__roles__)
except: roles=''
return ("""<table>
<tr><th>Title:</th><td>
<input type=text name=title SIZE="50" value="%s"></td></tr>
<tr><th>Roles:</th><td>
<input type=text name=roles SIZE="50" value="%s"></td></tr>
</table>""" % (self.title, roles))
_formhead="""
<TABLE>
<TR>
<TH>Title:</TH>
<TD><INPUT TYPE="TEXT" NAME="title" SIZE="50" VALUE="%s"></TD>
</TR>
<TR>
<TD></TD>
<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):
"""Hook to override signature so we can detect whether we are
......@@ -39,15 +75,14 @@ class Document(HTML, AccessControl.ACL.RoleManager):
if RESPONSE is None: return r
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"""
self.title=title
self.parse_roles_string(roles)
self._setRoles(acl_type,acl_roles)
REQUEST['CANCEL_ACTION']="%s/manage_main" % REQUEST['URL2']
return HTML.manage_edit(self,data,REQUEST)
default_html="""<!--#var standard_html_header-->
New Document
<!--#var standard_html_footer-->"""
......@@ -59,25 +94,28 @@ class DocumentHandler:
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"""
if not file: file=default_html
i=Document(file, __name__=id)
i.title=title
i.parse_roles_string(roles)
i._setRoles(acl_type,acl_roles)
self._setObject(id,i)
if REQUEST: return self.manage_main(self,REQUEST)
def documentIds(self):
t=[]
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
def documentValues(self):
t=[]
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
def documentItems(self):
......
"""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
......@@ -11,7 +11,7 @@ from ObjectManager import ObjectManager
from Image import ImageHandler
from Document import DocumentHandler
from AccessControl.User import UserFolderHandler
from AccessControl.Role import RoleManager
class FolderHandler:
"""Folder object handler"""
......@@ -24,11 +24,12 @@ class FolderHandler:
return Folder
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"""
i=self.folderClass()()
i.id=id
i.title=title
i._setRoles(acl_type,acl_roles)
self._setObject(id,i)
return self.manage_main(self,REQUEST)
......@@ -53,8 +54,8 @@ class FolderHandler:
return t
class Folder(ObjectManager,DocumentHandler,ImageHandler,
FolderHandler,UserFolderHandler):
class Folder(ObjectManager,RoleManager,DocumentHandler,
ImageHandler,FolderHandler,UserFolderHandler):
"""Folder object"""
meta_type='Folder'
id ='folder'
......@@ -74,6 +75,8 @@ class Folder(ObjectManager,DocumentHandler,ImageHandler,
'action':'manage_main', 'target':'manage_main'},
{'icon':'OFS/Properties_icon.gif', 'label':'Properties',
'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',
'action':'manage_help', 'target':'_new'},
)
......
"""Image object"""
__version__='$Revision: 1.2 $'[11:-2]
__version__='$Revision: 1.3 $'[11:-2]
from Persistence import Persistent
from Globals import HTMLFile
from AccessControl.Role import RoleManager
class Image:
class Image(Persistent,RoleManager):
"""Image object"""
meta_type ='Image'
title=''
icon ='OFS/Image_icon.gif'
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
except: headers=None
......@@ -28,7 +29,7 @@ class Image:
self.content_type=headers['content-type']
self.data=data
self.title=title
self._setRoles(acl_type,acl_roles)
def _init(self,id,file,content_type=''):
try: headers=file.headers
......@@ -50,17 +51,20 @@ class Image:
RESPONSE['content-type']=self.content_type
return self.data
class ImageHandler:
"""Image object handler mixin"""
meta_types=({'name':'Image', 'action':'manage_addImageForm'},)
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"""
i=Image()
i._init(id,file)
i.title=title
i._setRoles(acl_type,acl_roles)
self._setObject(id,i)
return self.manage_main(self,REQUEST)
......
......@@ -5,9 +5,9 @@
<BODY BGCOLOR="#FFFFFF" LINK="#000099" VLINK="#555555" ALINK="#77003B">
<FONT SIZE="+2">New HTML Document</FONT>
<P>
You can create a new image in the system using the form below.
Select an image from your local computer by clicking the <I>Browse</I>
button. The image file you select will be uploaded to the application.
You can create a new html document using the form below.
You may choose to upload an existing html file from your
local computer by clicking the <I>Browse</I> button.
<FORM ACTION="<!--#var PARENT_URL-->/manage_addDocument" METHOD="POST"
ENCTYPE="multipart/form-data" TARGET="manage_main">
......@@ -23,17 +23,39 @@
</TD>
</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">
<INPUT TYPE="TEXT" NAME="roles" SIZE="50">
<INPUT TYPE="file" NAME="file:string" SIZE="30" VALUE="">
</TD>
</TR>
<!--#if AUTHENTICATED_USER-->
<TR>
<TD ALIGN="LEFT" VALIGN="TOP"><STRONG>File</STRONG></TD>
<TD ALIGN="LEFT" VALIGN="TOP">
<INPUT TYPE="file" NAME="file:string" SIZE="30" VALUE="">
<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>
<TD></TD>
<TD><BR><INPUT TYPE="SUBMIT" VALUE="Add Document"></TD>
......
......@@ -15,6 +15,32 @@
<TD ALIGN="LEFT" VALIGN="TOP"><B>Title</B></TD>
<TD ALIGN="LEFT" VALIGN="TOP"><INPUT TYPE="TEXT" NAME="title" SIZE="50"></TD>
</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>
<TD></TD>
<TD><BR><INPUT TYPE="SUBMIT" VALUE="Add Folder"></TD>
......
......@@ -27,6 +27,34 @@
<TD ALIGN="LEFT" VALIGN="TOP">
<INPUT TYPE="TEXT" NAME="title" SIZE="50"></TD>
</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>
<TD></TD>
<TD><BR><INPUT TYPE="SUBMIT" VALUE="Add Image"></TD>
......
......@@ -3,7 +3,7 @@
<TITLE>Edit Image</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" LINK="#000099" VLINK="#555555" ALINK="#77003B">
<FONT SIZE="+2">New Image</FONT>
<FONT SIZE="+2">Edit Image</FONT>
<P>
You can update image in the system using the form below.
Select an image from your local computer by clicking the <I>Browse</I>
......@@ -27,6 +27,34 @@
<TD ALIGN="LEFT" VALIGN="TOP">
<INPUT TYPE="TEXT" NAME="title" SIZE="50" VALUE="<!--#var title-->"></TD>
</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>
<TD></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