forked from toutpt/collective.etherpad
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Add dexterity support. The field choice is achieved by looking for an
IRichText field in the schema. [toutpt]
- Loading branch information
Showing
3 changed files
with
24 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,36 @@ | ||
# there are no import of archetypes in .archetypes just the way fields are | ||
# retrieved | ||
from z3c.form import button | ||
from zope import schema | ||
from collective.etherpad import archetypes | ||
from plone.dexterity.schema import SCHEMA_CACHE | ||
from plone.app.textfield.interfaces import IRichText | ||
|
||
|
||
class EtherpadSyncForm(archetypes.EtherpadSyncForm): | ||
|
||
def save(self): | ||
#get the content from etherpad | ||
import pdb;pdb.set_trace() | ||
field = self.context.getField(self.archetypes_fieldname) | ||
context_schema = SCHEMA_CACHE.get(self.context.portal_type) | ||
fields = schema.getFields(context_schema) | ||
for name in fields: | ||
field = fields[name] | ||
if IRichText.providedBy(field): | ||
break | ||
|
||
html = self.etherpad.getHTML(padID=self.padID) | ||
if html and 'html' in html: | ||
field.set(self.context, html['html'], mimetype='text/html') | ||
|
||
|
||
class EtherpadEditView(archetypes.EtherpadEditView): | ||
"""Implement etherpad for Archetypes content types""" | ||
form_instance_class = EtherpadSyncForm | ||
|
||
def getEtherpadFieldName(self): | ||
import pdb;pdb.set_trace() | ||
primary = self.context.getPrimaryField() | ||
if primary: | ||
return primary.getName() | ||
context_schema = SCHEMA_CACHE.get(self.context.portal_type) | ||
fields = schema.getFields(context_schema) | ||
for name in fields: | ||
field = fields[name] | ||
if IRichText.providedBy(field): | ||
break | ||
return name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters