Ejemplo n.º 1
0
from Products.PythonScripts.standard import url_quote, urlencode

portal=context.portal_url.getPortalObject()
pm=portal.portal_membership
myFolder=pm.getHomeFolder()

if not myFolder:
    kw = {
        'portal_status_message' : "You must be logged in to create a Homecoming team.",
        'came_from' : context.absolute_url() + "/createTeam",
        }
    context.REQUEST.RESPONSE.redirect(portal.absolute_url() + "/login_form?" + urlencode (kw))
else:
    new_id = myFolder.generateUniqueId('HomecomingTeam')
    newTeam = myFolder.invokeFactory('HomecomingTeam', new_id)
    newTeamURL = myFolder.absolute_url() + '/' + newTeam
    redirect_to = newTeamURL + '/edit'
    portal_status_message="A new team has been created.  You must give it a name and fill out the names and email addresses of its members. Please make sure you enter correct email addresses."

    ploneVersion = portal.portal_migration.getInstanceVersionTuple()
    #portal_status_message +=  " (Plone version is %s)" % str(ploneVersion)
    if ploneVersion[0] == 2 and ploneVersion[1] == 1:
      last_referer = newTeamURL + '/object_delete'
    else:    
      last_referer = newTeamURL + '/delete_confirmation'

    kw = {
        'portal_status_message' : portal_status_message, 
        'last_referer':last_referer,
        }
    context.REQUEST.RESPONSE.redirect(redirect_to + "?" + urlencode(kw))
Ejemplo n.º 2
0
    rights = context.Rights()

dtool.overrideDiscussionFor(context, allowDiscussion)

try:
    context.editMetadata(title=title,
                         description=description,
                         subject=subject,
                         contributors=contributors,
                         effective_date=effective_date,
                         expiration_date=expiration_date,
                         format=format,
                         language=language,
                         rights=rights)
except ResourceLockedError, msg:
    message = msg
    action_id = 'metadata'
else:
    message = 'Metadata changed.'
    if change_and_edit:
        action_id = 'edit'
    elif change_and_view:
        action_id = 'view'
    else:
        action_id = 'metadata'

target = '%s/%s' % (context.absolute_url(),
                    context.getTypeInfo().getActionById(action_id))
query = urlencode({'portal_status_message': message})
context.REQUEST.RESPONSE.redirect('%s?%s' % (target, query))
Ejemplo n.º 3
0
dtool.overrideDiscussionFor(context, allowDiscussion)

try:
    context.editMetadata( title=title
                        , description=description
                        , subject=subject
                        , contributors=contributors
                        , effective_date=effective_date
                        , expiration_date=expiration_date
                        , format=format
                        , language=language
                        , rights=rights
                        )
except ResourceLockedError, msg:
    message = msg
    action_id = 'metadata'
else:
    message = 'Metadata changed.'
    if change_and_edit:
        action_id = 'edit'
    elif change_and_view:
        action_id = 'view'
    else:
        action_id = 'metadata'

target = '%s/%s' % ( context.absolute_url(),
                     context.getTypeInfo().getActionById(action_id) )
query = urlencode( {'portal_status_message': message} )
context.REQUEST.RESPONSE.redirect( '%s?%s' % (target, query) )
Ejemplo n.º 4
0
from Products.PythonScripts.standard import url_quote, urlencode
from Products.Archetypes.utils import addStatusMessage

portal = context.portal_url.getPortalObject()
pm = portal.portal_membership
myFolder = pm.getHomeFolder()

if not myFolder:
    portal_status_message = "You must be logged in to create a Homecoming team."
    addStatusMessage(context.REQUEST, portal_status_message)
    kw = {
        'came_from': context.absolute_url() + "/createTeam",
    }
    context.REQUEST.RESPONSE.redirect(portal.absolute_url() + "/login_form?" +
                                      urlencode(kw))
else:
    new_id = myFolder.generateUniqueId('HomecomingTeam')
    newTeam = myFolder.invokeFactory('HomecomingTeam', new_id)
    newTeamURL = myFolder.absolute_url() + '/' + newTeam
    redirect_to = newTeamURL + '/edit'
    portal_status_message = "A new team has been created.  You must give it a name and fill out the names and email addresses of its members. Please make sure you enter correct email addresses."
    addStatusMessage(context.REQUEST, portal_status_message)

    ploneVersion = portal.portal_migration.getInstanceVersionTuple()
    #portal_status_message +=  " (Plone version is %s)" % str(ploneVersion)
    if ploneVersion[0] == 2 and ploneVersion[1] == 1:
        last_referer = newTeamURL + '/object_delete'
    else:
        last_referer = newTeamURL + '/delete_confirmation'

    kw = {
Ejemplo n.º 5
0
## Script (Python) "document_edit"
##parameters=text_format, text, file='', SafetyBelt='', change_and_view=''
##title=Edit a document
##
from Products.PythonScripts.standard import urlencode
from Products.CMFDefault.exceptions import EditingConflict
from Products.CMFDefault.exceptions import IllegalHTML
from Products.CMFDefault.exceptions import ResourceLockedError
from Products.CMFDefault.utils import scrubHTML

try:
    text = scrubHTML(text)  # Strip Javascript, etc.
    context.edit(text_format, text, file, safety_belt=SafetyBelt)
except (ResourceLockedError, EditingConflict, IllegalHTML), msg:
    message = msg
    action_id = "edit"
else:
    message = "Document changed."
    if change_and_view:
        action_id = "view"
    else:
        action_id = "edit"

target = "%s/%s" % (context.absolute_url(), context.getTypeInfo().getActionById(action_id))
query = urlencode({"portal_status_message": message})
context.REQUEST.RESPONSE.redirect("%s?%s" % (target, query))