Ejemplo n.º 1
0
    def disable(self):
        """ See IHomeStoriesSubtyper
        """
        if not self.can_disable:
            return self._redirect(_('Homestory not supported'))

        noLongerProvides(self.context, IHomeStory)
        self.context.reindexObject(['object_provides', ])
        self._redirect(_('This is no longer a homepage story'))
Ejemplo n.º 2
0
    def enable(self):
        """ See IHomeStoriesSubtyper
        """
        if not self.can_enable:
            return self._redirect(_('Homestory not supported'))

        alsoProvides(self.context, IHomeStory)
        self.context.reindexObject(['object_provides', ])
        objectEventNotify(HomepageStoryNotify(self.context,))
        self._redirect(_('This is now a homepage story'))
Ejemplo n.º 3
0
 def addable_types(self, include=None):
     return [
         {
             "id": "add-company-wizzard",
             "title": _("Add company"),
             "description": _("Add new company wizard"),
             "action": "%s/@@add_company" % self.context.absolute_url(),
             "selected": False,
             "icon": None,
             "extra": {"id": "add-company-wizzard", "separator": None, "class": None},
             "submenu": None,
         }
     ]
Ejemplo n.º 4
0
 def update(self):
     workflowTool = getToolByName(self.context, "portal_workflow")
     review_state = workflowTool.getInfoFor(self.context, "review_state")
     if review_state == "draft":
         self.info = _(
             u"You need to publish your company to allow other users to see it. After publishing you cannot retract it by yourself."
         )
     elif review_state == "published":
         self.info = _(
             "label_company_private_info",
             default=u'Please contact <a href="/contatti/supporto-tecnico">support</a> to remove your company.',
         )
     else:
         self.info = ""
Ejemplo n.º 5
0
def order_added(order, event):
    """Every time a order is added - change title."""
    if order.Title():
        return
    product = order.getProduct()
    quantity = order.getQuantity().decode('utf8', 'ignore')
    title = product.title_or_id().decode('utf8', 'ignore')
    unit = order.getUnit().decode('utf8', 'ignore')
    order.setTitle(u'%s %s di %s' % (quantity, unit, title))
    order.reindexObject()
    company = order.getCompany()
    if not company:
        return

    owner = order.getOwner()
    params = {'email_message': NEW_ORDER_MAIL % (owner.getProperty('fullname', 'Utente'),
                                                 quantity,
                                                 title,
                                                 '%s/@@company_owner' % order.absolute_url(),
                                                 owner.getProperty('fullname', 'Utente'),
                                                 owner.getProperty('cellphone'),
                                                 owner.getProperty('email'),
                                                 ),
              'email_subject': NEW_ORDER_SUBJECT,
              'phone_message': NEW_ORDER_SMS % (owner.getProperty('fullname', 'Utente'), owner.getProperty('cellphone', ''))}
    company_notify(company, params)
    status = IStatusMessage(order.REQUEST)
    status.add(_(u'Your order has been registered!'), type=u'order')
Ejemplo n.º 6
0
    def __call__(self):
        annotations = IAnnotations(self.context)
        if not ASSOCIATION_KEY in annotations:
            annotations[ASSOCIATION_KEY] = []
        associated = annotations[ASSOCIATION_KEY]

        membership = getToolByName(self.context, 'portal_membership')
        member = membership.getAuthenticatedMember()
        if member.getId() in associated:
            associated.remove(member.getId())
            IStatusMessage(self.request).addStatusMessage(_(u"Association removed."))
        else:
            IStatusMessage(self.request).addStatusMessage(_(u"Association added."))
            associated.append(member.getId())

        annotations[ASSOCIATION_KEY] = associated
        self.request.response.redirect(self.context.absolute_url())
Ejemplo n.º 7
0
 def update(self):
     if not self.context.canPublish():
         self.info = _(
             "label_product_private_info",
             default=u"You need to have <a href='${company_url}'>your company</a> published before publishing your products.",
             mapping={u"company_url": self.context.getCompany().absolute_url()},
         )
     else:
         self.info = ""
Ejemplo n.º 8
0
    def __call__(self):
        registry = getUtility(IRegistry)
        FB_APP_ID = registry.get('restarter.policy.browser.facebook_login.IFacebookloginSettings.fb_app_id','').encode()
        if not FB_APP_ID:
            IStatusMessage(self.request).add(_(u"Facebook not configurated."), type="error")
            self.request.response.redirect(self.context.absolute_url())
            return u""

        verificationCode = self.request.get("code", None)
        errorReason      = self.request.get("error_reason", None)

        args = {
                'client_id': FB_APP_ID,
                'scope': 'publish_actions,email',
                #'redirect_uri': "%s/%s?came_from=%s" % (self.context.absolute_url(), self.__name__, came_from),
                'redirect_uri': "%s/%s" % (self.context.absolute_url(), self.__name__,),
            }

        # Did we get an error back after a Facebook redirect?
        if errorReason is not None:
            IStatusMessage(self.request).add(_(u"Facebook authentication denied"), type="error")
            self.request.response.redirect(self.context.absolute_url())
            return u""

        # If there is no code, this is probably the first request, so redirect
        # to Facebook
        came_from        = self.request.get("came_from", self.context.absolute_url())
        #session = self.context.session_data_manager.getSessionData()
        #session['came_from'] = came_from

        if verificationCode is None:
            self.request.response.redirect(
                    "%s?%s" % (FACEBOOK_AUTH_URL, urllib.urlencode(args),)
                )
            return u""

        if self.portal_membership.isAnonymousUser():
            self.request.RESPONSE.redirect('%s/@@facebook_register' % self.portal.absolute_url())
        else:
            url = came_from# session.get('came_from')
            if url is not None:
                self.request.RESPONSE.redirect(url)
            else:
                self.request.RESPONSE.redirect('%s?ts=%s' % (self.portal.absolute_url(),time.time()))
 def handle_join_success(self, data):
     registration = getToolByName(self.context, 'portal_registration')
     session = self.context.session_data_manager.getSessionData()
     if 'facebook_profile' in session.keys():
         data['facebook_id'] = session['facebook_profile'].get('id')
         data['facebook_token'] = session['facebook_token']
     else:
         IStatusMessage(self.request).addStatusMessage(_(u'Facebook data incomplete. Please retry.'), type="error")
         return
     data['password'] = registration.generatePassword()
     return super(RegistrationForm, self).handle_join_success(data)
Ejemplo n.º 10
0
def product_added(product, event):
    """Event fired when product has been added."""
    if 'foto' in product.objectIds():
        #stupid check - plone is calling it twice, why?
        return
    media = product[product.invokeFactory('Folder', 'foto')]
    media.setTitle(u'Foto')
    media.setLayout('atct_album_view')
    directlyProvides(media, (ISimpleAddButtons,))
    media.setConstrainTypesMode(1)
    media.setLocallyAllowedTypes(['Image'])
    product.portal_workflow.doActionFor(media, "publish", comment=_("Published on product creation"))
    product.portal_workflow.doActionFor(product, "create")
Ejemplo n.º 11
0
    def form_fields(self):
        defaultFields = super(RegistrationForm, self).form_fields
        session = self.context.session_data_manager.getSessionData()
        profile = session.get('facebook_profile')
        if not profile:
            IStatusMessage(self.request).addStatusMessage(_(u'Facebook data incomplete. Please retry.'), type="error")
            return defaultFields

        if not defaultFields:
            return defaultFields
        defaultFields.get('email').get_rendered = get_email
        defaultFields.get('fullname').get_rendered = get_fullname
        defaultFields.get('username').get_rendered = get_username
        defaultFields = defaultFields.omit('rpx_identifier')
        defaultFields = defaultFields.omit('facebook_id')
        defaultFields = defaultFields.omit('facebook_token')
        return defaultFields
Ejemplo n.º 12
0
from Products.ATContentTypes.content import schemata
from Products.ATVocabularyManager import NamedVocabulary
from plone.indexer.decorator import indexer
from cioppino.twothumbs.interfaces import ILoveThumbsDontYou
from collective.contentleadimage.config import IMAGE_FIELD_NAME
from collective.contentleadimage.interfaces import ILeadImageable

from restarter.policy import policyMessageFactory as _
from restarter.policy.interfaces import ICompany
from restarter.policy.config import PROJECTNAME
from zope.component.event import objectEventNotify
from restarter.policy.events import CompanyShareNotify


PROVINCE = atapi.DisplayList((
             ("", _("-- not selected --")),
             ("Bologna", "Bologna"),
             ("Ferrara", "Ferrara"),
             ("Forli-Cesena", "Forli-Cesena"),
             ("Modena", "Modena"),
             ("Mantova", "Mantova"),
             ("Parma", "Parma"),
             ("Piacenza", "Piacenza"),
             ("Ravenna", "Ravenna"),
             ("Reggio Emilia", "Reggio Emilia"),
             ("Rovigo", "Rovigo"),
             ("Rimini", "Rimini")))


NOTIFICATION = atapi.DisplayList((
             ("", _("-- not selected --")),
Ejemplo n.º 13
0
from Products.ATContentTypes.content import schemata
from Products.ATVocabularyManager import NamedVocabulary

from restarter.policy import policyMessageFactory as _
from restarter.policy.interfaces import IOffer
from restarter.policy.config import PROJECTNAME


OfferSchema = schemata.ATContentTypeSchema.copy() + atapi.Schema((

    atapi.StringField('category',
        searchable=0,
        required=True,
        vocabulary=NamedVocabulary('demand_category'),
        widget=atapi.SelectionWidget(
            label=_("Offer category"),
            description=_("Please select your offer category."),
            size=30
            ),
        ),

    atapi.StringField('period',
        searchable=0,
        required=False,
        widget=atapi.StringWidget(
            label=_("Period"),
            description=_("Please provide offer period."),
            size=20
            ),
        ),
Ejemplo n.º 14
0
from Products.ATContentTypes.content import schemata
from Products.ATVocabularyManager import NamedVocabulary

from restarter.policy.interfaces import IDemand, ICompany
from restarter.policy.config import PROJECTNAME
from restarter.policy import policyMessageFactory as _


DemandSchema = folder.ATFolderSchema.copy() + atapi.Schema((

    atapi.StringField('category',
        searchable=0,
        required=True,
        vocabulary=NamedVocabulary('demand_category'),
        widget=atapi.SelectionWidget(
            label=_("Demand category"),
            description=_("Please select your demand category."),
            size=30
            ),
        ),

    atapi.StringField('period',
        searchable=0,
        required=False,
        widget=atapi.StringWidget(
            label=_("Period"),
            description=_("Please provide demand period."),
            size=20
            ),
        ),
Ejemplo n.º 15
0
from Products.Archetypes import atapi
from Products.ATContentTypes.content import folder
from Products.ATContentTypes.content import schemata
from Products.ATVocabularyManager import NamedVocabulary
from collective.contentleadimage.config import IMAGE_FIELD_NAME
from collective.contentleadimage.interfaces import ILeadImageable

from restarter.policy.interfaces import IProduct, ICompany
from restarter.policy.config import PROJECTNAME
from restarter.policy import policyMessageFactory as _


PRODUCT_CONDITION = atapi.DisplayList(
    (
        ("", _("-- not selected --")),
        ("new", _("New")),
        ("new_demaged", _("New demaged")),
        ("used", _("Used")),
        ("used_demaged", _("Used dameged")),
        ("other", _(u"Other")),
    )
)


ProductSchema = folder.ATFolderSchema.copy() + atapi.Schema(
    (
        atapi.StringField(
            "category",
            searchable=0,
            required=True,
Ejemplo n.º 16
0
 def roles(self):
     return [{"id": "Employee", "title": _("Employee")}]
Ejemplo n.º 17
0
def company_added(company, event):
    """Every time a company is added - create substructure."""

    if 'storie-dell-azienda' in company.objectIds():
        #stupid check - plone is calling it twice, why?
        return

    story = company[company.invokeFactory('Folder', 'storie-dell-azienda')]
    story.setTitle(u'Storie dell\'azienda')
    story.setLayout('folder_summary_view')
    story.setConstrainTypesMode(1)
    story.setLocallyAllowedTypes(['CompanyStory'])
    directlyProvides(story, (ISimpleAddButtons,))
    company.portal_workflow.doActionFor(story, "publish", comment=_("Published on company creation"))

    if 'foto' in company.objectIds():
        #stupid check - plone is calling it twice, why?
        return

    media = company[company.invokeFactory('Folder', 'foto')]
    media.setTitle(u'Foto')
    media.setLayout('atct_album_view')
    media.setConstrainTypesMode(1)
    media.setLocallyAllowedTypes(['Image'])
    directlyProvides(media, (ISimpleAddButtons,))
    company.portal_workflow.doActionFor(media, "publish", comment=_("Published on company creation"))

    if 'docs' in company.objectIds():
        #stupid check - plone is calling it twice, why?
        return

    docs = company[company.invokeFactory('Folder', 'docs')]
    docs.setTitle(u'Documenti')
    docs.setLayout('folder_summary_view')
    docs.setConstrainTypesMode(1)
    docs.setLocallyAllowedTypes(['Document', 'File'])
    directlyProvides(docs, (ISimpleAddButtons,))
    company.portal_workflow.doActionFor(docs, "publish", comment=_("Published on company creation"))

    if 'prodotti' in company.objectIds():
        #stupid check - plone is calling it twice, why?
        return

    products = company[company.invokeFactory('Products', 'prodotti')]
    products.setTitle(u'Prodotti')
    products.setLayout('folder_leadimage_view')
    products.reindexObject()
    directlyProvides(products, (ISimpleAddButtons,))

    if 'richieste' in company.objectIds():
        #stupid check - plone is calling it twice, why?
        return

    demands = company[company.invokeFactory('Demands', 'richieste')]
    demands.setTitle(u'Cerchiamo')
    demands.setLayout('folder_summary_view')
    demands.reindexObject()
    directlyProvides(products, (ISimpleAddButtons,))

    owner = company.getOwner()
    params = {'email_message': NEW_COMPANY % (owner.getProperty('fullname', 'Ciao!'),
                                              company.title_or_id(),
                                              company.absolute_url()),
              'email_subject': NEW_COMPANY_SUBJECT}
    company_notify(company, params)
    # we have handled that by regex in mailgun
    #notify('mailgun/newcompany', {'uid': company.UID()})

    company.portal_workflow.doActionFor(company, "create")
    company.manage_setLocalRoles(owner.getId(), ('Owner', 'Employee',))
Ejemplo n.º 18
0
from Products.Archetypes import atapi
from Products.ATContentTypes.content import base
from Products.ATContentTypes.content import schemata

from restarter.policy import policyMessageFactory as _
from restarter.policy.interfaces import IOrder, ICompany, IProduct
from restarter.policy.config import PROJECTNAME

OrderSchema = schemata.ATContentTypeSchema.copy() + atapi.Schema((

    atapi.FixedPointField('quantity',
        searchable=0,
        required=True,
        widget=atapi.DecimalWidget(
            label=_("Order quantity"),
            description=_("Please provide order quantity."),
            size=10
            ),
        ),

))


schemata.finalizeATCTSchema(OrderSchema, moveDiscussion=False)

OrderSchema['location'].widget.visible['view'] = 'invisible'
OrderSchema['location'].widget.visible['edit'] = 'invisible'
OrderSchema['language'].widget.visible['view'] = 'invisible'
OrderSchema['language'].widget.visible['edit'] = 'invisible'
OrderSchema['allowDiscussion'].widget.visible['view'] = 'invisible'