Exemplo n.º 1
0
    def action_send(self, action, data):
        """Send the email to the site administrator and redirect to the
        front page, showing a status message to say the message was received.
        """
        
        context = aq_inner(self.context)
        
        mailhost = getToolByName(context, 'MailHost')
        urltool = getToolByName(context, 'portal_url')
        
        portal = urltool.getPortalObject()
        email_charset = portal.getProperty('email_charset')

        # Construct and send a message
        to_address = portal.getProperty('email_from_address')
        source = "%s <%s>" % (data['name'], data['email_address'])
        subject = data['subject']
        message = MESSAGE_TEMPLATE % data

        mailhost.secureSend(message, to_address, str(source),
                            subject=subject, subtype='plain',
                            charset=email_charset, debug=False,
                            From=source)
        
        # Issue a status message
        confirm = _(u"Thank you! Your enquiry has been received and we will respond as soon as possible")
        IStatusMessage(self.request).addStatusMessage(confirm, type='info')
        
        # Redirect to the portal front page. Return an empty string as the
        # page body - we are redirecting anyway!
        self.request.response.redirect(portal.absolute_url())
        return ''
Exemplo n.º 2
0
 def action_cancel(self, action, data):
     """Cancel the reservation operation
     """
     context = aq_inner(self.context)
     
     confirm = _(u"Reservation cancelled.")
     IStatusMessage(self.request).addStatusMessage(confirm, type='info')
     
     self.request.response.redirect(context.absolute_url())
     return ''
Exemplo n.º 3
0
 def __call__(self, reservation):
     """Make a reservation
     """
     
     db = getUtility(IDatabase, name='optilux.reservations')
     session = db.session
     
     # Make sure there are still seats available
     screening = reservation.screening
     session.refresh(screening)
     
     if screening.remaining_tickets <= 0:
         raise ReservationError(_(u"This screening is sold out!"))
     elif screening.remaining_tickets < reservation.num_tickets:
         raise ReservationError(_(u"Not enough tickets remaining!"))
     
     # Otherwise, we can save the reservation
     screening.remaining_tickets -= reservation.num_tickets
     session.update(screening)
     session.save(reservation)
     session.flush()
Exemplo n.º 4
0
 def __call__(self, request):
     value = request.form.get(self.field_name, request.get(self.field_name, None))
     if value is not None:
         catalog = getToolByName(self.context, 'portal_catalog')
         results = catalog(film_code = value)
         if len(results) == 0:
             return None
         elif len(results) == 1 and results[0].UID == self.context.UID():
             return None
         else:
             return {self.field_name : _(u"The film code is already in use")}
     
     # Returning None means no error
     return None
Exemplo n.º 5
0
 def __call__(self, request):
     value = request.form.get(self.field_name, request.get(self.field_name, None))
     if value is not None:
         catalog = getToolByName(self.context, 'portal_catalog')
         results = catalog(cinema_code=value,
                           object_provides=ICinema.__identifier__)
         if len(results) == 0:
             return None
         elif len(results) == 1 and results[0].UID == self.context.UID():
             return None
         else:
             return {self.field_name : _(u"The cinema code is already in use")}
     
     # Returning None means no error
     return None
Exemplo n.º 6
0
    def __call__(self, request):
        value = request.form.get(self.field_name,
                                 request.get(self.field_name, None))
        if value is not None:
            catalog = getToolByName(self.context, 'portal_catalog')
            results = catalog(film_code=value,
                              object_provides=IFilm.__identifier__)
            if len(results) == 0:
                return None
            elif len(results) == 1 and results[0].UID == self.context.UID():
                return None
            else:
                return {self.field_name: _(u"The film code is already in use")}

        # Returning None means no error
        return None
Exemplo n.º 7
0
        storage=atapi.AnnotationStorage(),
        swallowResizeExceptions=True,
        # pil_quality=90,
        # pil_resize_algo='antialias',
        max_size='no',
        sizes={'large'   : (768, 768),
               'preview' : (400, 400),
               'mini'    : (200, 200),
               'thumb'   : (128, 128),
               'tile'    :  (64, 64),
               'icon'    :  (32, 32),
               'listing' :  (16, 16),
               },
        validators=(('isNonEmptyFile', V_REQUIRED),
                    ('checkImageMaxSize', V_REQUIRED),),
        widget=atapi.ImageWidget(label= _(u"Banner image"),
                                 description = _(u""),
                                 show_content_type = False,),
        ),

    atapi.TextField('details',
        required=False,
        searchable=True,
        storage=atapi.AnnotationStorage(),
        validators=('isTidyHtmlWithCleanup',),
        default_output_type='text/x-html-safe',
        widget=atapi.RichWidget(label=_(u"Promotion details"),
                                description=_(u""),
                                rows=25,
                                allow_file_upload=False),
        ),
Exemplo n.º 8
0
from Products.ATContentTypes.content import schemata
from Products.ATContentTypes.content.schemata import finalizeATCTSchema

from optilux.cinemacontent.interfaces import IFilm
from optilux.cinemacontent.interfaces import IBannerProvider
from optilux.cinemacontent.config import PROJECTNAME

from optilux.cinemacontent import CinemaMessageFactory as _

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

    atapi.StringField('filmCode',
        required=True,
        searchable=True,
        storage=atapi.AnnotationStorage(),
        widget=atapi.StringWidget(label=_(u"Film code"),
                                  description=_(u"This should match the film code used in the "
                                                  "booking system."))
        ),

    # By using the name 'image' we can have the image show up in preview
    # folder listings for free
    atapi.ImageField('image',
        required=True,
        languageIndependent=True,
        storage=atapi.AnnotationStorage(),
        swallowResizeExceptions=True,
        # pil_quality=90,
        # pil_resize_algo='antialias',
        max_size='no',
        sizes={'large'   : (768, 768),
Exemplo n.º 9
0
from Products.ATContentTypes.content import folder
from Products.ATContentTypes.content.schemata import finalizeATCTSchema

from optilux.cinemacontent.interfaces import ICinema
from optilux.cinemacontent.config import PROJECTNAME

from optilux.cinemacontent import CinemaMessageFactory as _

CinemaSchema = folder.ATFolderSchema.copy() + atapi.Schema((
    
    atapi.StringField('cinemaCode',
        required=True,
        searchable=True,
        storage=atapi.AnnotationStorage(),
        widget=atapi.StringWidget(label=_(u"Cinema code"),
                                  description=_(u"This should match the cinema code used in the "
                                                 "booking system."))
        ),
    
    atapi.StringField('phone',
        required=True,
        searchable=True,
        storage=atapi.AnnotationStorage(),
        widget=atapi.StringWidget(label=_(u"Phone number"),
                                  description=_(u""))
        ),
        
    atapi.TextField('text',
        required=False,
        searchable=True,
Exemplo n.º 10
0
 def title(self):
     return _(u"My cinema")
Exemplo n.º 11
0
 def title(self):
     return _(u"Promotions")
Exemplo n.º 12
0
    def toggle(self):
        
        portal_state = getMultiAdapter((self.context, self.request), name=u"plone_portal_state")
        if portal_state.anonymous():
            return
        
        cinema = aq_inner(self.context)
        member = portal_state.member()
        
        cinema_code = cinema.cinema_code
        home_cinemas = list(member.getProperty('home_cinemas', []))
        
        # Add or remove this cinema from the list of home cinemas
        
        enabled = True
        if cinema_code in home_cinemas:
            home_cinemas.remove(cinema_code)
            enabled = False
        else:
            home_cinemas.append(cinema_code)
        
        member.setProperties(home_cinemas=home_cinemas)
    
        # Refresh the viewlet with the toggle button
        # See ratings.py for more on this set of commands

        alsoProvides(self, IViewView)

        ksscore = self.getCommandSet('core')
        zopecommands = self.getCommandSet('zope')
        
        selector = ksscore.getHtmlIdSelector('my-cinema-toggle')
        zopecommands.refreshViewlet(selector, manager='plone.belowcontentbody', 
                                    name='optilux.cinemacontent.mycinema')
        
        plonecommands = self.getCommandSet('plone')
        
        # Issue a status message that things have changed
        
        if enabled:
            plonecommands.issuePortalMessage(_(u"This cinema is now a 'home' cinema."))
        else:
            plonecommands.issuePortalMessage(_(u"This cinema is no longer a 'home' cinema."))
            
        # Refresh any instances of the "my cinema" portlet. Here, we cheat 
        # and simply re-use the template from the mycinema portlet.

        # This approach isn't entirely perfect - if the portlet wasn't 
        # displayed before, it won't be shown until the page is reloaded,
        # and we may end up with an empty (non-hidden) portlet column if
        # the portlet ends up not being rendered.
        
        if not home_cinemas:
            # If there are no home cinemas, replace the portlet <dl /> wiht
            # a blank <div /> with the same class. We do this so that we can
            # find the node again later if the user toggles the cinema back on

            ksscore.replaceHTML('.portletMyCinema', '<div class="portletMyCinema" />')
        else:
            # There are cinemas to display - render the portlet template. This
            # view will be the 'view' variable in the template. This is okay,
            # because we provide the IMyCinemasBox interface, which as the
            # template is expecting.
            
            self.home_cinemas = home_cinemas
            ksscore.replaceHTML('.portletMyCinema', self.portlet_template())
Exemplo n.º 13
0
from optilux.cinemacontent.config import PROJECTNAME
from optilux.cinemacontent.config import PROMOTIONS_PORTLET_COLUMN

from optilux.cinemacontent import CinemaMessageFactory as _
from optilux.cinemacontent.portlets import promotions

# This is the Archetypes schema, defining fields and widgets. We extend
# the one from ATContentType's ATFolder with our additional fields.
CinemaFolderSchema = folder.ATFolderSchema.copy() + atapi.Schema((
    atapi.TextField('text',
        required=False,
        searchable=True,
        storage=atapi.AnnotationStorage(),
        validators=('isTidyHtmlWithCleanup',),
        default_output_type='text/x-html-safe',
        widget=atapi.RichWidget(label=_(u"Descriptive text"),
                                description=_(u""),
                                rows=25,
                                allow_file_upload=False),
        ),
    ))

# We want to ensure that the properties we use as field properties (see
# below), use AnnotationStorage. Without this, our property will conflict
# with the attribute with the same name that is being managed by the default
# attributestorage

CinemaFolderSchema['title'].storage = atapi.AnnotationStorage()
CinemaFolderSchema['description'].storage = atapi.AnnotationStorage()
    
# Calling this re-orders a few fields to comply with Plone conventions.
Exemplo n.º 14
0
    def action_reserve(self, action, data):
        """Reserve tickets
        """
        context = aq_inner(self.context)
        screening = self.screening()
        reservations = getUtility(ITicketReservations)

        try:
            reservations(Reservation(data['customer_name'], 
                                     data['num_tickets'],
                                     screening))
        except ReservationError, e:
            IStatusMessage(self.request).addStatusMessage(e.error_message, type='error')
        else:
                
            confirm = _(u"Thank you! Your tickets will be ready for collection at the front desk.")
            IStatusMessage(self.request).addStatusMessage(confirm, type='info')
            self.request.response.redirect(context.absolute_url())
            return ''
    
    # The null_validator ensures that we can cancel the form even if some
    # required fields are not entered
    @form.action(_(u"Cancel"), validator=null_validator)
    def action_cancel(self, action, data):
        """Cancel the reservation operation
        """
        context = aq_inner(self.context)
        
        confirm = _(u"Reservation cancelled.")
        IStatusMessage(self.request).addStatusMessage(confirm, type='info')
        
Exemplo n.º 15
0
from Products.ATContentTypes.content import schemata
from Products.ATContentTypes.content.schemata import finalizeATCTSchema

from optilux.cinemacontent.interfaces import IFilm
from optilux.cinemacontent.interfaces import IBannerProvider
from optilux.cinemacontent.config import PROJECTNAME

from optilux.cinemacontent import CinemaMessageFactory as _

FilmSchema = schemata.ATContentTypeSchema.copy() + atapi.Schema((
    atapi.StringField('filmCode',
                      required=True,
                      searchable=True,
                      storage=atapi.AnnotationStorage(),
                      widget=atapi.StringWidget(
                          label=_(u"Film code"),
                          description=_(
                              u"This should match the film code used in the "
                              "booking system."))),

    # By using the name 'image' we can have the image show up in preview
    # folder listings for free
    atapi.ImageField(
        'image',
        required=True,
        languageIndependent=True,
        storage=atapi.AnnotationStorage(),
        swallowResizeExceptions=True,
        # pil_quality=90,
        # pil_resize_algo='antialias',
        max_size='no',