def _checkout(self):
        # NOTE: this code is copied from plone.app.iterate.browser.checkout
        context = aq_inner(self.context)

        containers = list(self._containers())
        location = containers[0]["name"]

        # We want to redirect to a specific template, else we might
        # end up downloading a file
        control = getMultiAdapter((context, self.request), name=u"iterate_control")
        if not control.checkout_allowed():
            raise CheckoutException(u"Not allowed")

        locator = None
        try:
            locator = [c["locator"] for c in containers if c["name"] == location][0]
        except IndexError:
            IStatusMessage(self.request).addStatusMessage(_("Cannot find checkout location"), type="stop")
            view_url = context.restrictedTraverse("@@plone_context_state").view_url()
            self.request.response.redirect(view_url)
            return

        policy = ICheckinCheckoutPolicy(context)
        wc = policy.checkout(locator())

        # we do this for metadata update side affects which will update lock info
        context.reindexObject("review_state")

        IStatusMessage(self.request).addStatusMessage(_("Check-out created"), type="info")
        # view_url = wc.restrictedTraverse("@@plone_context_state").view_url()
        return wc
예제 #2
0
파일: checkout.py 프로젝트: CGTIC/Plone_SP
    def __call__(self):
        context = aq_inner(self.context)

        # We want to redirect to a specific template, else we might
        # end up downloading a file
        if self.request.form.has_key('form.button.Checkout'):
            control = getMultiAdapter((context, self.request), name=u"iterate_control")
            if not control.checkout_allowed():
                raise CheckoutException(u"Not allowed")

            location = self.request.form.get('checkout_location', None)
            locator = None
            try:
                locator = [c['locator'] for c in self.containers() if c['name'] == location][0]
            except IndexError:
                IStatusMessage(self.request).addStatusMessage(_("Cannot find checkout location"), type='stop')
                view_url = context.restrictedTraverse("@@plone_context_state").view_url()
                self.request.response.redirect(view_url)
                return

            policy = ICheckinCheckoutPolicy(context)
            wc = policy.checkout(locator())
            
            # we do this for metadata update side affects which will update lock info
            context.reindexObject('review_state')
            
            IStatusMessage(self.request).addStatusMessage(_("Check-out created"), type='info')
            view_url = wc.restrictedTraverse("@@plone_context_state").view_url()
            self.request.response.redirect(view_url)
        elif self.request.form.has_key('form.button.Cancel'):
            view_url = context.restrictedTraverse("@@plone_context_state").view_url()
            self.request.response.redirect(view_url)
        else:
            return self.index()
예제 #3
0
class ILoginLockoutSettings(Interface):

    max_attempts = schema.Int(
        title=_(u'Max Attempts'),
        description=u'Number of unsuccessful logins before account locked',
        default=3,
        required=True)

    reset_period = schema.Float(
        title=_(u'Reset Period (hours)'),
        description=u'Locked accounts are reenabled after this time',
        default=24.0,
        required=True)

    whitelist_ips = schema.Text(
        title=_(u'Lock logins to IP Ranges'),
        description=
        u'List of IP Ranges which Client IP must be in to login. Empty disables',
        default=u'',
        required=False)

    fake_client_ip = schema.Bool(
        title=_(u'Fake Client IP'),
        description=u'Ignore X-Forward-For and REMOTE_ADDR headers',
        default=False,
        required=False)
예제 #4
0
    def __call__(self):
        context = aq_inner(self.context)

        containers = list(self.containers())
        if len(containers) == 1:
            # Special case for when there's only when folder to select
            self.request.form['form.button.Checkout'] = 1
            self.request.form['checkout_location'] = containers[0]['name']

        # We want to redirect to a specific template, else we might
        # end up downloading a file
        if self.request.form.has_key('form.button.Checkout'):
            control = getMultiAdapter((context, self.request),
                                      name=u"iterate_control")
            if not control.checkout_allowed():
                raise CheckoutException(u"Not allowed")

            location = self.request.form.get('checkout_location', None)
            locator = None
            try:
                locator = [
                    c['locator'] for c in self.containers()
                    if c['name'] == location
                ][0]
            except IndexError:
                IStatusMessage(self.request).addStatusMessage(
                    _("Cannot find checkout location"), type='stop')
                view_url = context.restrictedTraverse(
                    "@@plone_context_state").view_url()
                self.request.response.redirect(view_url)
                return

            policy = ICheckinCheckoutPolicy(context)
            wc = policy.checkout(locator())

            # we do this for metadata update side affects which will update lock info
            context.reindexObject('review_state')

            IStatusMessage(self.request).addStatusMessage(
                _("Check-out created"), type='info')
            view_url = wc.restrictedTraverse(
                "@@plone_context_state").view_url()
            self.request.response.redirect(view_url)
        elif self.request.form.has_key('form.button.Cancel'):
            view_url = context.restrictedTraverse(
                "@@plone_context_state").view_url()
            self.request.response.redirect(view_url)
        else:
            return self.index()
예제 #5
0
class IIterateSettings(Interface):

    enable_checkout_workflow = schema.Bool(
        title=_(u'Enable checkout workflow'),
        description=u'',
        default=False,
        required=False
    )

    checkout_workflow_policy = schema.TextLine(
        title=_(u'Checkout workflow policy'),
        description=u'',
        default=u'checkout_workflow_policy',
        required=True
    )
예제 #6
0
    def __call__(self):
        context = aq_inner(self.context)

        if 'form.button.Checkin' in self.request.form:
            control = getMultiAdapter((context, self.request),
                                      name=u'iterate_control')
            if not control.checkin_allowed():
                raise CheckinException(u'Not a checkout')

            message = self.request.form.get('checkin_message', '')

            policy = ICheckinCheckoutPolicy(context)
            baseline = policy.checkin(message)

            IStatusMessage(self.request).addStatusMessage(_('Checked in'),
                                                          type='info')
            view_url = baseline.restrictedTraverse(
                '@@plone_context_state').view_url()
            self.request.response.redirect(view_url)
        elif 'form.button.Cancel' in self.request.form:
            view_url = context.restrictedTraverse(
                '@@plone_context_state').view_url()
            self.request.response.redirect(view_url)
        else:
            return self.index()
예제 #7
0
    def _checkout(self):
        # NOTE: this code is copied from plone.app.iterate.browser.checkout
        context = aq_inner(self.context)

        # containers = list(self._containers())
        location = self.context.aq_parent   #containers[0]['name']

        # We want to redirect to a specific template, else we might
        # end up downloading a file
        control = getMultiAdapter((context, self.request),
                                  name=u"iterate_control")
        if not control.checkout_allowed():
            raise CheckoutException(u"Not allowed")

        policy = ICheckinCheckoutPolicy(context)
        wc = policy.checkout(location)
        transition(wc, to_state='sent')

        # we do this for metadata update side affects which will update lock info
        context.reindexObject('review_state')

        IStatusMessage(self.request).addStatusMessage(_("Check-out created"),
                                                      type='info')
        #view_url = wc.restrictedTraverse("@@plone_context_state").view_url()
        return wc
예제 #8
0
    def __call__(self):
        context = aq_inner(self.context)

        if 'form.button.Checkin' in self.request.form:
            control = getMultiAdapter(
                (context, self.request), name=u'iterate_control')
            if not control.checkin_allowed():
                raise CheckinException(u'Not a checkout')

            message = self.request.form.get('checkin_message', '')

            policy = ICheckinCheckoutPolicy(context)
            baseline = policy.checkin(message)

            IStatusMessage(self.request).addStatusMessage(
                _('Checked in'), type='info')
            view_url = baseline.restrictedTraverse(
                '@@plone_context_state').view_url()
            self.request.response.redirect(view_url)
        elif 'form.button.Cancel'in self.request.form:
            view_url = context.restrictedTraverse(
                '@@plone_context_state').view_url()
            self.request.response.redirect(view_url)
        else:
            return self.index()
예제 #9
0
파일: iterate.py 프로젝트: eea/bise.country
class CheckoutFolderLocator(object):
    """Locate the parent of the context, if the user has the
    Add portal content permission.
    """
    def __init__(self, context):
        self.context = context

    title = _(u'Special Checkout location')

    def checkout_location(self):
        site = hooks.getSite()

        if 'checkout-folder' in site.contentIds():
            return site['checkout-folder']

    @property
    def available(self):
        folder = self.checkout_location()

        if folder is None:
            return False

        return bool(getSecurityManager().checkPermission(
            AddPortalContent, aq_inner(folder)))

    def __call__(self):
        if not self.available:
            return None

        return aq_inner(self.checkout_location())
예제 #10
0
    def __call__(self):
        context = aq_inner(self.context)

        # We want to redirect to a specific template, else we might
        # end up downloading a file
        if 'form.button.Checkout' in self.request.form:
            control = getMultiAdapter((context, self.request),
                                      name=u'iterate_control')
            if not control.checkout_allowed():
                raise CheckoutException(u'Not allowed')

            location = self.request.form.get('checkout_location', None)
            locator = None
            try:
                locator = [
                    c['locator'] for c in self.containers()
                    if c['name'] == location
                ][0]
            except IndexError:
                IStatusMessage(self.request).addStatusMessage(
                    _('Cannot find checkout location'), type='error')
                view_url = context.restrictedTraverse(
                    '@@plone_context_state').view_url()
                self.request.response.redirect(view_url)
                return

            policy = ICheckinCheckoutPolicy(context)
            wc = policy.checkout(locator())

            # we do this for metadata update side affects which will update
            # lock info
            context.reindexObject('review_state')

            IStatusMessage(self.request).addStatusMessage(
                _('Check-out created'), type='info')
            view_url = wc.restrictedTraverse(
                '@@plone_context_state').view_url()
            self.request.response.redirect(view_url)
        elif 'form.button.Cancel' in self.request.form:
            view_url = context.restrictedTraverse(
                '@@plone_context_state').view_url()
            self.request.response.redirect(view_url)
        else:
            return self.index()
def checkInIfNeeded(document, event):
    context = aq_inner(document)
    workflowTool = getToolByName(context, "portal_workflow")
    status = workflowTool.getStatusOf("1MX_wiki_workflow", document)
    if IWorkingCopy.providedBy(context) and status["review_state"] == "internally_published":
       policy = ICheckinCheckoutPolicy(context)
       baseline = policy.checkin("")
       IStatusMessage(context.REQUEST).addStatusMessage(
            _("Checked in"), type='info')
       view_url = baseline.unrestrictedTraverse("@@plone_context_state").view_url()
       transaction.commit()
       raise Redirect(view_url)
예제 #12
0
파일: iterate.py 프로젝트: eea/bise.country
class FactsheetParentFolderLocator(ParentFolderLocator):
    """ Override for factsheets
    """
    def __init__(self, context):
        self.context = context

    title = _(u'')

    @property
    def available(self):
        return False

    def __call__(self):
        return None
예제 #13
0
    def _checkout(self):
        # NOTE: this code is copied from plone.app.iterate.browser.checkout
        context = aq_inner(self.context)

        containers = list(self._containers())
        location = containers[0]['name']

        # We want to redirect to a specific template, else we might
        # end up downloading a file
        control = getMultiAdapter((context, self.request),
                                  name=u"iterate_control")
        if not control.checkout_allowed():
            raise CheckoutException(u"Not allowed")

        locator = None
        try:
            locator = [
                c['locator'] for c in containers if c['name'] == location
            ][0]
        except IndexError:
            IStatusMessage(self.request).addStatusMessage(
                _("Cannot find checkout location"), type='stop')
            view_url = context.restrictedTraverse(
                "@@plone_context_state").view_url()
            self.request.response.redirect(view_url)
            return

        policy = ICheckinCheckoutPolicy(context)
        wc = policy.checkout(locator())

        # we do this for metadata update side affects which will update lock info
        context.reindexObject('review_state')

        IStatusMessage(self.request).addStatusMessage(_("Check-out created"),
                                                      type='info')
        #view_url = wc.restrictedTraverse("@@plone_context_state").view_url()
        return wc
예제 #14
0
class HomeFolderLocator(object):
    """Locate the current user's home folder, if possible.
    """

    def __init__(self, context):
        self.context = context

    title = _(u'Home folder')

    @property
    def available(self):
        return self() is not None

    def __call__(self):
        return getToolByName(self.context, 'portal_membership').getHomeFolder()
예제 #15
0
class HomeFolderLocator(object):
    """Locate the current user's home folder, if possible.
    """
    implements(IWCContainerLocator)
    adapts(IDynamicType)

    def __init__(self, context):
        self.context = context

    title = _(u"Home folder")

    @property
    def available(self):
        return self() is not None

    def __call__(self):
        return getToolByName(self.context, 'portal_membership').getHomeFolder()
예제 #16
0
    def __call__(self):
        context = aq_inner(self.context)
        
        if self.request.form.has_key('form.button.Cancel'):
            control = getMultiAdapter((context, self.request), name=u"iterate_control")
            if not control.cancel_allowed():
                raise CheckoutException(u"Not a checkout")

            policy = ICheckinCheckoutPolicy(context)
            baseline = policy.cancelCheckout()
            baseline.reindexObject()
            
            IStatusMessage(self.request).addStatusMessage(_(u"Checkout cancelled"), type='info')
            view_url = baseline.restrictedTraverse("@@plone_context_state").view_url()
            self.request.response.redirect(view_url)
        elif self.request.form.has_key('form.button.Keep'):
            view_url = context.restrictedTraverse("@@plone_context_state").view_url()
            self.request.response.redirect(view_url)
        else:
            return self.template()
예제 #17
0
class ParentFolderLocator(object):
    """Locate the parent of the context, if the user has the
    Add portal content permission.
    """
    implements(IWCContainerLocator)
    adapts(IDynamicType)
    
    def __init__(self, context):
        self.context = context
    
    title = _(u"Parent folder")
    
    @property
    def available(self):
        return bool(getSecurityManager().checkPermission(AddPortalContent, aq_parent(aq_inner(self.context))))
        
    def __call__(self):
        if not self.available:
            return None
        return aq_parent(aq_inner(self.context))
예제 #18
0
    def __call__(self):
        context = aq_inner(self.context)

        if self.request.form.has_key('form.button.Cancel'):
            control = getMultiAdapter((context, self.request),
                                      name=u"iterate_control")
            if not control.cancel_allowed():
                raise CheckoutException(u"Not a checkout")

            policy = ICheckinCheckoutPolicy(context)
            baseline = policy.cancelCheckout()
            baseline.reindexObject()

            IStatusMessage(self.request).addStatusMessage(
                _(u"Checkout cancelled"), type='info')
            view_url = baseline.restrictedTraverse(
                "@@plone_context_state").view_url()
            self.request.response.redirect(view_url)
        elif self.request.form.has_key('form.button.Keep'):
            view_url = context.restrictedTraverse(
                "@@plone_context_state").view_url()
            self.request.response.redirect(view_url)
        else:
            return self.index()
# _*_ coding: utf-8 _*_
from .interfaces import ILoginLockoutSettings
from plone.app.registry.browser import controlpanel
from plone.app.iterate import PloneMessageFactory as _
from z3c.form import form
from plone.z3cform import layout


class LoginLockoutSettingsForm(controlpanel.RegistryEditForm):

    schema = ILoginLockoutSettings
    schema_prefix = 'Products.LoginLockout'
    form.extends(controlpanel.RegistryEditForm)


LoginLockoutSetting = layout.wrap_form(LoginLockoutSettingsForm,
                                       controlpanel.ControlPanelFormWrapper)
LoginLockoutSetting.label = _(u'LoginLockout Settings')