Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improved Dexterity support #50

Merged
merged 3 commits into from Mar 4, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 19 additions & 6 deletions Solgema/fullcalendar/browser/adapters.py
Expand Up @@ -1009,6 +1009,21 @@ def getEvents(self):
return result


def convert(value):
query = value['query']
if isinstance(query, unicode):
query = query.encode("utf-8")
elif isinstance(query, list):
query = [
item.encode("utf-8") if isinstance(item, unicode) else item
for item in query
]
else:
pass
value['query'] = query
return value


class DXCollectionEventSource(TopicEventSource):
"""Event source that get events from the collection
"""
Expand All @@ -1021,12 +1036,10 @@ def _getCriteriaArgs(self):

listCriteria = context.query

# Handle operator-only query strings accordingly.
# Also convert to str since unicode breaks the catalog-query
query = dict(['v' in a and (str(a['i']),
[str(value) for value in a['v']]) or
(str(a['i']), [str(value) for value in a['o']])
for a in listCriteria])
query = dict([
(key, convert(value))
for key, value in queryparser.parseFormquery(context, listCriteria).items()
])

topicCriteria = interfaces.IListCriterias(context)()
_args = {}
Expand Down
7 changes: 6 additions & 1 deletion Solgema/fullcalendar/browser/views.py
Expand Up @@ -691,7 +691,12 @@ def __call__(self):
css = ''
if not colorsDict or not availableSubFolders:
return css
folderIds = [a.getId for a in self.context.getFolderContents(contentFilter={'object_provides':'Products.ATContentTypes.interfaces.folder.IATFolder'})]
folderIds = [a.getId for a in self.context.getFolderContents(contentFilter={
'object_provides': [
'Products.ATContentTypes.interfaces.folder.IATFolder',
'plone.dexterity.interfaces.IDexterityContainer',
]
})]
if not folderIds:
return css
fieldid = 'subFolders'
Expand Down
7 changes: 6 additions & 1 deletion Solgema/fullcalendar/vocabularies.py
Expand Up @@ -59,7 +59,12 @@ def availableCriterias( context ):
return TitledVocabulary.fromTitles([(crit['id'], crit['title']) for crit in li])

def availableSubFolders( context ):
folderContents = context.getFolderContents(contentFilter={'object_provides':'Products.ATContentTypes.interfaces.folder.IATFolder'})
folderContents = context.getFolderContents(contentFilter={
'object_provides': [
'Products.ATContentTypes.interfaces.folder.IATFolder',
'plone.dexterity.interfaces.IDexterityContainer',
]
})
return TitledVocabulary.fromTitles([(a.getId, a.Title) for a in folderContents])

def shortNameFormats(context):
Expand Down
9 changes: 8 additions & 1 deletion Solgema/fullcalendar/widgets/widgets.py
Expand Up @@ -20,6 +20,11 @@ class ICollection(Interface): pass
except:
class IDXCollection(Interface): pass

try:
from plone.dexterity.interfaces import IDexterityContainer
except:
IDexterityContainer = IATFolder

from Solgema.fullcalendar.interfaces import ICustomUpdatingDict, ISolgemaFullcalendarProperties, IListBaseQueryCriteria
from Solgema.fullcalendar import msg_fact as _

Expand Down Expand Up @@ -58,6 +63,8 @@ def render(self):
fieldname = index.friendlyName or index.index
if selectedItems:
html += '<br/><b>%s</b><br/><table>' % (fieldname)
if isinstance(selectedItems, unicode):
selectedItems = [selectedItems]
for item in selectedItems:
name = safe_unicode(item)
item = str(component.queryUtility(IURLNormalizer).normalize(name))
Expand Down Expand Up @@ -100,7 +107,7 @@ def render(self):
value, value)
html+='</table>'
availableSubFolders = getattr(calendar, 'availableSubFolders', [])
if IATFolder.providedBy(self.context) and availableSubFolders:
if (IATFolder.providedBy(self.context) or IDexterityContainer.providedBy(self.context)) and availableSubFolders:
html += '<br/><b>%s</b><br/><table>' % (_('Sub-Folders'))
fieldid = 'subFolders'
for folderId in availableSubFolders:
Expand Down