Created
December 13, 2013 13:30
-
-
Save nigelbabu/7944232 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
class PartnerGroupClass(plugins.SingletonPlugin, DefaultGroupForm): | |
plugins.implements(plugins.IGroupForm, inherit=True) | |
## IGroupForm | |
def is_fallback(self): | |
return True | |
def group_types(self): | |
return ['organization'] | |
def _modify_schema(self, schema): | |
schema.update({ | |
'ilri_partner': [tk.get_converter('convert_to_extras'), | |
tk.get_validator('ignore_missing')], | |
}) | |
return schema | |
def form_to_db_schema(self): | |
schema = super(PartnerGroupClass, self).form_to_db_schema() | |
schema = self._modify_schema(schema) | |
return schema | |
def form_to_db_schema_api_create(self): | |
schema = super(PartnerGroupClass, self).form_to_db_schema_api_create() | |
schema = self._modify_schema(schema) | |
return schema | |
def form_to_db_schema_api_update(self): | |
schema = super(PartnerGroupClass, self).form_to_db_schema_api_update() | |
schema = self._modify_schema(schema) | |
return schema | |
def db_to_form_schema(self): | |
_not_empty = tk.get_validator('not_empty') | |
schema = super(PartnerGroupClass, self).form_to_db_schema() | |
schema.update({ | |
'ilri_partner': [tk.get_converter('convert_from_extras'), | |
tk.get_validator('ignore_missing')], | |
#TODO: this should be handled in core | |
'num_followers': [_not_empty], | |
'package_count': [_not_empty], | |
}) | |
return schema | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment