Skip to content

Commit

Permalink
[#368] Add num_followers to group schema
Browse files Browse the repository at this point in the history
  • Loading branch information
domoritz committed Feb 21, 2013
1 parent c81edd2 commit c7bc315
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
3 changes: 3 additions & 0 deletions ckan/lib/navl/validators.py
Expand Up @@ -92,3 +92,6 @@ def convert_int(value, context):
except ValueError:
raise Invalid(_('Please enter an integer value'))

def read_only_validator(value, context):

return value
7 changes: 4 additions & 3 deletions ckan/logic/action/get.py
Expand Up @@ -845,12 +845,13 @@ def _group_or_org_show(context, data_dict, is_org=False):
except AttributeError:
schema = group_plugin.db_to_form_schema()

if schema:
group_dict, errors = _validate(group_dict, schema, context=context)

group_dict['num_followers'] = logic.get_action('group_follower_count')(
{'model': model, 'session': model.Session},
{'id': group_dict['id']})

if schema:
group_dict, errors = _validate(group_dict, schema, context=context)

return group_dict


Expand Down
4 changes: 3 additions & 1 deletion ckan/logic/schema.py
Expand Up @@ -5,7 +5,8 @@
ignore,
if_empty_same_as,
not_missing,
ignore_empty
ignore_empty,
read_only_validator
)
from ckan.logic.validators import (package_id_not_changed,
package_id_exists,
Expand Down Expand Up @@ -306,6 +307,7 @@ def default_group_schema():
def group_form_schema():
schema = default_group_schema()
#schema['extras_validation'] = [duplicate_extras_key, ignore]
schema['num_followers'] = [ignore_missing, int_validator, read_only_validator]
schema['packages'] = {
"name": [not_empty, unicode],
"title": [ignore_missing],
Expand Down

0 comments on commit c7bc315

Please sign in to comment.