class IResourceRegistry(zope.interface.Interface): url = schema.ASCIILine(title=_(u"Resources base URL"), required=False) js = schema.ASCIILine(title=_(u"Main js file"), required=False) css = schema.List(title=_(u"CSS/LESS files"), value_type=schema.ASCIILine(title=_(u"URL")), default=[], required=False) init = schema.ASCIILine(title=_(u"Init instruction for shim"), required=False) deps = schema.ASCIILine( title=_(u"Dependencies for shim"), description=_(u"Comma separated values of resource for shim"), required=False) export = schema.ASCIILine(title=_(u"Export vars for shim"), required=False) conf = schema.Text( title=_(u"Configuration in JSON for the widget"), description=_(u"Should be accessible on @@getWCconfig?id=name"), required=False)
class ITile(Interface): """Interface for the tile configuration in the registry""" name = schema.TextLine(title=_(u"Name")) label = schema.TextLine(title=_(u"Label")) category = schema.TextLine(title=_(u"Category")) tile_type = schema.TextLine(title=_(u"Type")) default_value = schema.TextLine(title=_(u"Default value"), required=False) read_only = schema.Bool(title=_(u"Read only")) settings = schema.Bool(title=_(u"Settings")) favorite = schema.Bool(title=_(u"Favorite")) rich_text = schema.Bool(title=_(u"Rich Text")) weight = schema.Int(title=_(u"Weight"))
class ITile(Interface): """Interface for the tile configuration in the registry""" name = schema.TextLine(title=_(u'Name')) label = schema.TextLine(title=_(u'Label')) category = schema.TextLine(title=_(u'Category')) tile_type = schema.TextLine(title=_(u'Type')) default_value = schema.TextLine(title=_(u'Default value'), required=False) read_only = schema.Bool(title=_(u'Read only')) settings = schema.Bool(title=_(u'Settings')) favorite = schema.Bool(title=_(u'Favorite')) rich_text = schema.Bool(title=_(u'Rich Text')) weight = schema.Int(title=_(u'Weight'))
class IFieldTile(Interface): """Interface for the field tile configuration in the registry """ id = schema.TextLine(title=_(u"The widget id")) name = schema.TextLine(title=_(u"Name")) label = schema.TextLine(title=_(u"Label")) category = schema.TextLine(title=_(u"Category")) tile_type = schema.TextLine(title=_(u"Type")) read_only = schema.Bool(title=_(u"Read only")) favorite = schema.Bool(title=_(u"Favorite")) widget = schema.TextLine(title=_(u"Field widget")) available_actions = schema.List(title=_(u"Actions"), value_type=schema.TextLine())
class IFieldTile(Interface): """Interface for the field tile configuration in the registry """ id = schema.TextLine(title=_(u'The widget id')) name = schema.TextLine(title=_(u'Name')) label = schema.TextLine(title=_(u'Label')) category = schema.TextLine(title=_(u'Category')) tile_type = schema.TextLine(title=_(u'Type')) read_only = schema.Bool(title=_(u'Read only')) favorite = schema.Bool(title=_(u'Favorite')) widget = schema.TextLine(title=_(u'Field widget')) available_actions = schema.List(title=_(u'Actions'), value_type=schema.TextLine())
class IAction(Interface): name = schema.TextLine(title=_(u"Name")) fieldset = schema.TextLine(title=_(u"Fieldset")) label = schema.TextLine(title=_(u"Label")) action = schema.TextLine(title=_(u"Action")) icon = schema.Bool(title=_(u"Icon")) menu = schema.Bool(title=_(u"Menu")) weight = schema.Int(title=_(u"Weight"))
class IAction(Interface): name = schema.TextLine(title=_(u'Name')) fieldset = schema.TextLine(title=_(u'Fieldset')) label = schema.TextLine(title=_(u'Label')) action = schema.TextLine(title=_(u'Action')) icon = schema.Bool(title=_(u'Icon')) menu = schema.Bool(title=_(u'Menu')) weight = schema.Int(title=_(u'Weight'))
class IFormat(Interface): """Interface for the format configuration in the registry""" name = schema.TextLine(title=_(u'Name')) category = schema.TextLine(title=_(u'Category')) label = schema.TextLine(title=_(u'Label')) action = schema.TextLine(title=_(u'Action')) icon = schema.Bool(title=_(u'Icon')) favorite = schema.Bool(title=_(u'Favorite')) weight = schema.Int(title=_(u'Weight'))
class IFormat(Interface): """Interface for the format configuration in the registry""" name = schema.TextLine(title=_(u"Name")) category = schema.TextLine(title=_(u"Category")) label = schema.TextLine(title=_(u"Label")) action = schema.TextLine(title=_(u"Action")) icon = schema.Bool(title=_(u"Icon")) favorite = schema.Bool(title=_(u"Favorite")) weight = schema.Int(title=_(u"Weight"))
class IBundleRegistry(zope.interface.Interface): jscompilation = schema.ASCIILine( title=_(u"URL of the last js compilation"), required=False) csscompilation = schema.ASCIILine( title=_(u"URL of the last css compilation"), required=False) last_compilation = schema.Datetime( title=_(u"Last compiled date"), description=_(u"Date time of the last compilation of this bundle"), required=False) expression = schema.ASCIILine( title=_(u"Expression to render"), description=_( u"In case its a bundle we can have a condition to render it"), required=False) conditionalcomment = schema.ASCIILine( title=_(u"Conditional comment"), description=_( u"In case you want to render this resource on conditional comment" ), required=False) resources = schema.List( title=_(u"Loaded resources"), description=_( u"The resources that is going to be loaded on this bundle in order" ), value_type=schema.ASCIILine(title=_(u"Resource name")), required=False) enabled = schema.Bool(title=_(u"It's enabled?"), default=True, required=False) compile = schema.Bool( title=_(u"Does your bundle contains any RequireJS or LESS file?"), description= _(u"If its true and you modify this bundle you need to build it before production" ), default=True, required=False) depends = schema.ASCIILine( title=_(u"Depends on another bundle"), description= _(u"In case you want to be the last: *, in case its the first should be empty" ), required=False)
class IWidgetAction(Interface): name = schema.TextLine(title=_(u"Name")) actions = schema.List(title=_(u"Actions"), value_type=schema.TextLine())
class IWeightedDict(Interface): name = schema.TextLine(title=_(u"Name")) label = schema.TextLine(title=_(u"Label")) weight = schema.Int(title=_(u"Weight"))
def __call__(self): context = self.context request = self.request # Set header to json request.response.setHeader('Content-Type', 'application/json') ctr_tool = getToolByName(self.context, 'content_type_registry') id = request['uploadfile'].filename content_type = request['uploadfile'].headers["Content-Type"] typename = ctr_tool.findTypeName(id, content_type, "") # 1) check if we are allowed to create an Image in folder if not typename in [t.id for t in context.getAllowedTypes()]: error = {} error['status'] = 1 error['message'] =\ _(u"Not allowed to upload a file of this type to this folder") return json.dumps(error) # 2) check if the current user has permissions to add stuff if not context.portal_membership.checkPermission('Add portal content', context): error = {} error['status'] = 1 error['message'] =\ _(u"You do not have permission to upload files in this folder") return json.dumps(error) # Get an unused filename without path id = self.cleanupFilename(id) title = request['uploadfile'].filename newid = context.invokeFactory(type_name=typename, id=id) if newid is None or newid == '': newid = id obj = getattr(context, newid, None) # Set title # Attempt to use Archetypes mutator if there is one, # in case it uses a custom storage if title: try: obj.setTitle(title) except AttributeError: obj.title = title # set primary field pf = obj.getPrimaryField() pf.set(obj, request['uploadfile']) if not obj: error = {} error['status'] = 1 error['message'] = _(u"Could not upload the file") return json.dumps(error) obj.reindexObject() message = {} message['status'] = 0 message['url'] = obj.absolute_url() message['title'] = title return json.dumps(message)
class IWidgetAction(Interface): name = schema.TextLine(title=_(u'Name')) actions = schema.List(title=_(u'Actions'), value_type=schema.TextLine())
class IBundleRegistry(zope.interface.Interface): jscompilation = schema.ASCIILine( title=_(u"URL of the last js compilation"), required=False) csscompilation = schema.ASCIILine( title=_(u"URL of the last css compilation"), required=False) last_compilation = schema.Datetime( title=_(u"Last compiled date"), description=_(u"Date time of the last compilation of this bundle"), required=False) expression = schema.ASCIILine( title=_(u"Expression to render"), description=_( u"In case its a bundle we can have a condition to render it (it " "does not apply if the bundle is merged)."), required=False) conditionalcomment = schema.ASCIILine( title=_(u"Conditional comment"), description=_( u"In case you want to render this resource on conditional comment " "(it does not apply if the bundle is merged)."), required=False) resources = schema.List( title=_(u"Loaded resources"), description=_( u"The resources that is going to be loaded on this bundle in order" ), value_type=schema.ASCIILine(title=_(u"Resource name")), required=False) enabled = schema.Bool(title=_(u"It's enabled?"), default=True, required=False) compile = schema.Bool( title=_(u"Does your bundle contains any RequireJS or LESS file?"), description= _(u"If its true and you modify this bundle you need to build it before production" ), default=True, required=False) depends = schema.ASCIILine( title=_(u"Depends on another bundle"), description= _(u"In case you want to be the last: *, in case its the first should be empty" ), required=False) develop_javascript = schema.Bool(title=_(u'Develop JavaScript'), default=False) develop_css = schema.Bool(title=_(u'Develop CSS'), default=False) stub_js_modules = schema.List( title=_(u'Stub JavaScript modules'), description=_( u'Define list of modules that will be defined empty ' u'on RequireJS build steps to prevent loading modules multiple times.' ), value_type=schema.ASCIILine(title=_(u"Resource name")), required=False, missing_value=[], default=[]) merge_with = schema.Choice( title=_(u"Merge with"), description=_( u"In production mode, bundles are merged together to reduce the " "quantity of JS and CSS resources loaded by the browser. Choose " "'default' if this bundle must be available for all the visitors, " "choose 'logged-in' if it must be available for logged-in users " "only, or leave it empty if it must not be merged."), vocabulary=SimpleVocabulary([ SimpleTerm('', '', _(u"")), SimpleTerm('default', 'default', 'default'), SimpleTerm('logged-in', 'logged-in', 'logged-in') ]), default=u"", required=False)
def __call__(self): context = self.context request = self.request # Set header to json request.response.setHeader('Content-Type', 'application/json') ctr_tool = api.portal.get_tool('content_type_registry') id = request['uploadfile'].filename content_type = request['uploadfile'].headers["Content-Type"] typename = ctr_tool.findTypeName(id, content_type, "") # 1) check if we are allowed to create an Image in folder if typename not in [t.id for t in context.getAllowedTypes()]: error = {} error['status'] = 1 error['message'] =\ _(u"Not allowed to upload a file of this type to this folder") return json.dumps(error) # 2) check if the current user has permissions to add stuff if not context.portal_membership.checkPermission( 'Add portal content', context): error = {} error['status'] = 1 error['message'] =\ _(u"You do not have permission to upload files in this folder") return json.dumps(error) # Get an unused filename without path id = self.cleanupFilename(id) title = request['uploadfile'].filename newid = context.invokeFactory(type_name=typename, id=id) if newid is None or newid == '': newid = id obj = getattr(context, newid, None) # Set title # Attempt to use Archetypes mutator if there is one, # in case it uses a custom storage if title: try: obj.setTitle(title) except AttributeError: obj.title = title # set primary field pf = obj.getPrimaryField() pf.set(obj, request['uploadfile']) if not obj: error = {} error['status'] = 1 error['message'] = _(u"Could not upload the file") return json.dumps(error) obj.reindexObject() message = {} message['status'] = 0 message['url'] = obj.absolute_url() message['title'] = title return json.dumps(message)
class IWeightedDict(Interface): name = schema.TextLine(title=_(u'Name')) label = schema.TextLine(title=_(u'Label')) weight = schema.Int(title=_(u'Weight'))