def __call__(self):
     form = self.request.form
     messages = []
     pprops = getToolByName(self.context, 'portal_properties')
     properties = pprops.realestatebroker_properties
     names = list(properties.getProperty('floor_names'))
     first_available_floor = names[0]
     catalog = getToolByName(self.context, 'portal_catalog')
     brains = catalog(object_provides=IATImage.__identifier__,
                      sort_on='sortable_title',
                      path='/'.join(self.context.getPhysicalPath()))
     for image_brain in brains:
         image_id = image_brain['id']
         floor = form.get(image_id)
         obj = image_brain.getObject()
         annotation = IFloorInfo(obj)
         existing_floor = annotation.floor
         is_floorplan = bool(image_id in form.get('floorplan', []))
         if is_floorplan and not floor:
             # A floorplan must be attached to a floor.
             floor = first_available_floor
         if floor != existing_floor:
             annotation.floor = floor
             messages.append(_(u"${image} is now attached to ${floor}.",
                               mapping={'image':
                                        image_id, 'floor': floor}))
         if is_floorplan != annotation.is_floorplan:
             annotation.is_floorplan = is_floorplan
             if is_floorplan:
                 messages.append(_(u"${image} is now marked as floor "
                                   "plan.", mapping={'image': image_id}))
             else:
                 messages.append(_(u"${image} is no longer marked as "
                                   "floorplan.", mapping={'image':
                                                           image_id}))
         obj.reindexObject()
     current_default = brains[0]['id']
     default = form.get('default')
     if default != current_default:
         self.context.moveObjectsToTop(default)
         self.context.plone_utils.reindexOnReorder(self.context)
         messages.append(_(u"${image} is now the default.",
                           mapping={'image': default}))
     for message in messages:
         self.context.plone_utils.addPortalMessage(message)
     response = self.request.response
     here_url = self.context.absolute_url()
     response.redirect(here_url)
    def __init__(self, context, request):
        RealEstateBaseView.__init__(self, context, request)

        self.query = dict(object_provides = [ICommercial.__identifier__,
                                             IResidential.__identifier__],
                          sort_on = 'review_state',
                          path = '/'.join(self.context.getPhysicalPath()))

        self.formerror=u""
        form = self.request.form
        reset_action = form.get('form.button.reset', False)

        if not reset_action:
            if 'search_city' in form and form['search_city'] != 'Any city':
                self.query['getCity'] = form['search_city']
            if 'min_price' in form and 'max_price' in form:
                min_price=int(form['min_price'])
                max_price=int(form['max_price'])
                if min_price < max_price:
                    # range search
                    self.query['getPrice'] = {"query": [min_price, max_price],
                                              "range": "minmax"}
                elif min_price == 0 and max_price == 0:
                    # do nothing, empty select
                    pass
                elif min_price > 0 and max_price == 0:
                    # only minimum price selected, no maximum price
                    self.query['getPrice']={"query": min_price, "range": "min"}
                elif min_price >= max_price:
                    # Wrong price range
                    self.formerror=_(u'Please select a valid price range.')
        if reset_action:
            response = self.request.response
            here_url = self.context.absolute_url()
            response.redirect(here_url)
    def photos_for_pdf(self):
        """Return list for displaying photos

        Return a list like this:

        [{'floorname': '1st floor', 'photos': ['obj1', 'obj2']}]

        Make sure to filter out floors that don't have any photos.

        """
        floors = {}
        pprops = getToolByName(self.context, 'portal_properties')
        properties = pprops.realestatebroker_properties
        names = list(properties.getProperty('floor_names'))
        if not names:
            return
        for name in names:
            floors[name] = []
        # Grab photos.
        catalog = getToolByName(self.context, 'portal_catalog')
        brains = catalog(object_provides=IATImage.__identifier__,
                         is_floorplan=False,
                         sort_on='getObjPositionInParent',
                         path='/'.join(self.context.getPhysicalPath()))
        used_floors = []
        for brain in brains:
            obj = brain.getObject()
            floor = IFloorInfo(obj).floor
            used_floors.append(floor)
            if not floor in floors:
                # List of floors changed, we still have an old one.
                # Or we have a None here: unassigned photos.
                floors[floor] = []
            floors[floor].append(obj)
        # Filter out unused floors
        unused = [name for name in names
                  if name not in used_floors]
        for name in unused:
            del floors[name]
        # Now pack 'em up in a list: in the right order.
        result = []
        for name in names:
            if name in floors:
                result.append({'floorname': name,
                               'photos': floors[name]})
        # If there are no assigned photos, show 'em all.
        if result == []:
            if None in floors:
                if len(floors[None]):
                    name = _(u'All photos')
                    result.append({'floorname': name,
                                   'photos': floors[None]})
        return result
# - default
# - financial
# - measurements
# - details
# - environment
# - location


GeneralSchema =  atapi.Schema((
    # Generic data (common)
    # ---------------------
    atapi.StringField('zipCode',
        storage=atapi.AnnotationStorage(),
        schemata=u'default',
        selfrendered=True, # For REB-specific template rendering.
        widget = atapi.StringWidget(label = _(u'Zip code'),
                 )
        ),
    atapi.StringField('city',
        storage=atapi.AnnotationStorage(),
        schemata=u'default',
        selfrendered=True, # For REB-specific template rendering.
        vocabulary_factory="collective.realestatebroker.city_list",
        widget = atapi.SelectionWidget(label = _(u'City'),
                 )
        ),
    atapi.TextField('text',
        storage=atapi.AnnotationStorage(),
        schemata=u"default",
        validators = ('isTidyHtmlWithCleanup',),
        selfrendered=True, # For REB-specific template rendering.
from collective.realestatebroker.config import PROJECTNAME
from collective.realestatebroker.content import schemata
from collective.realestatebroker.interfaces import ICommercial
from zope.interface import implements
from Products.PloneFlashUpload.interfaces import IUploadingCapable
from archetypes.schemaextender.interfaces import IExtensible
from Products.CMFCore.utils import getToolByName

from collective.realestatebroker import REBMessageFactory as _

CommercialSchema = (atapi.OrderedBaseFolderSchema.copy() +
                     schemata.GeneralSchema +
                     schemata.CommercialSpecificSchema
                     )
CommercialSchema['title'].storage = atapi.AnnotationStorage()
CommercialSchema['title'].widget.label = _(u'Address')
CommercialSchema['title'].widget.description = _(u'Fill in the address of this object')
CommercialSchema['description'].storage = atapi.AnnotationStorage()
CommercialSchema['description'].schemata = 'default'

# Move text and descriptionfield to put them at the bottom of the default tab
CommercialSchema.moveField('text',pos='bottom')
CommercialSchema.moveField('description',before='text')

# Move related kk_von and rent_buy field after the price field
CommercialSchema.moveField('rent_buy',after='price')


class Commercial(atapi.OrderedBaseFolder):
    """Folderish content type for commercial real estate."""
    portal_type = "Commercial"
예제 #6
0
 def contents(self):
     text = self.context.getText(mimetype="text/plain").strip()
     if text:
         return ({'title': _("Info"),
                  'text': self.context.getText()},)
from collective.realestatebroker import REBMessageFactory as _
from collective.realestatebroker.interfaces import IResidential, ICommercial
from plone.app.content.batching import Batch
from plone.memoize.view import memoize
from zope.app.pagetemplate import ViewPageTemplateFile
from zope.component import getUtility
from zope.interface import implements
from zope.schema.interfaces import IVocabularyFactory
from zope.cachedescriptors.property import Lazy

from interfaces import IRealEstateListing
from interfaces import IRealEstateView
from interfaces import IUpdateWorkflowStatesView


SCHEMATA_I18N = {'measurements': _(u'measurements'),
                 'details': _(u'details'),
                 'environment': _(u'environment'),
                 'financial': _(u'financial'),
                 }

ESTATE_LISTING_BATCHSIZE=10


class RealEstateBaseView(BrowserView):
    """Base view with some tools attached"""

    def __init__(self, context, request):
        BrowserView.__init__(self, context, request)
        self.catalog = getToolByName(self.context, 'portal_catalog')
        self.wftool = getToolByName(self.context, 'portal_workflow')