Adding the first bit of permissions checking as an example. See cmd_who and the Object class's user_has_perm method for examples. We'll need to start fleshing this stuff out before adding many more new commands. For existing games, remove your auth_permissions table and re-sync your DB.

This commit is contained in:
Greg Taylor 2007-05-09 15:53:53 +00:00
parent f1dd985294
commit 2fc06adcfa
3 changed files with 51 additions and 17 deletions

View file

@ -129,6 +129,22 @@ class Object(models.Model):
else:
return profile[0].is_superuser
def user_has_perm(self, perm):
"""
Checks to see whether a user has the specified permission or is a super
user.
"""
if not self.is_player():
return False
if self.is_superuser():
return True
if self.get_user_account().has_perm(perm):
return True
else:
return False
def owns_other(self, other_obj):
"""
See if the envoked object owns another object.