Skip to content

Commit

Permalink
[#3012] User model is_authorized property added
Browse files Browse the repository at this point in the history
  • Loading branch information
tobes committed Nov 9, 2012
1 parent 18b3018 commit 636c786
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions ckan/lib/dictization/model_dictize.py
Expand Up @@ -415,6 +415,7 @@ def user_dictize(user, context):
del result_dict['password']

result_dict['display_name'] = user.display_name
result_dict['is_authorized'] = user.is_authorized
result_dict['email_hash'] = user.email_hash
result_dict['number_of_edits'] = user.number_of_edits()
result_dict['number_administered_packages'] = user.number_administered_packages()
Expand Down
7 changes: 7 additions & 0 deletions ckan/model/user.py
Expand Up @@ -50,6 +50,13 @@ def get(cls, user_reference):
cls.id == user_reference))
return query.first()

@property
def is_authorized(self):
# This is a shortcut property for nicer code
# sysadmins are assumed to be authorized. Authorization is turned
# on off via ckan.authorized_users_only config option
return self.sysadmin or self.authorized

@property
def display_name(self):
if self.fullname is not None and len(self.fullname.strip()) > 0:
Expand Down

0 comments on commit 636c786

Please sign in to comment.