- Implemented permission system management inside the game
- changed @chperm to @setperm to avoid confusion with channel commands - added @setgroup command for adding user group permissions - Moved permissions/group setup into settings file to allow admins to tweak without going into evennia engine. - Add all new players to default permission group (defined in settings) - Defined a basic group hierarchy, removed permission 'genperms.builder' in favour of a group named builders instead, containing all relevant permissions. - Filtered out all django's automatic permissions in @setperm/list to make permission system more controlled by admin. - Probably fixed bug that caused new users to not be signed up to channels (more testing needed) - Added Exception handler in unloggedin method create, this was killing tracebacks upon user creation. /Griatch
This commit is contained in:
parent
77f2186d9a
commit
7f7306a6e4
23 changed files with 341 additions and 214 deletions
|
|
@ -242,8 +242,7 @@ class ObjectManager(models.Manager):
|
|||
if match_type == "exact":
|
||||
return [prospect for prospect in searchlist
|
||||
if ostring == str(prospect.get_attribute_value(attribute_name))]
|
||||
else:
|
||||
print [type(p) for p in searchlist]
|
||||
else:
|
||||
return [prospect for prospect in searchlist
|
||||
if ostring in str(prospect.get_attribute_value(attribute_name))]
|
||||
else:
|
||||
|
|
@ -466,9 +465,7 @@ class ObjectManager(models.Manager):
|
|||
# pluck the user ID from it.
|
||||
if not str(uid).isdigit():
|
||||
uid = uid.id
|
||||
logger.log_infomsg('Next usable object ID is %d. (recycled)' % uid)
|
||||
else:
|
||||
logger.log_infomsg('Next usable object ID is %d. (new)' % uid)
|
||||
logger.log_infomsg('Create_user: Recycling object ID %d.' % uid)
|
||||
|
||||
user = User.objects.create_user(uname, email, password)
|
||||
# It stinks to have to do this but it's the only trivial way now.
|
||||
|
|
@ -480,7 +477,6 @@ class ObjectManager(models.Manager):
|
|||
|
||||
# Update the session to use the newly created User object's ID.
|
||||
command.session.uid = uid
|
||||
logger.log_infomsg('User created with id %d.' % command.session.uid)
|
||||
|
||||
# Grab the user object again since we've changed it and the old reference
|
||||
# is no longer valid.
|
||||
|
|
@ -495,16 +491,20 @@ class ObjectManager(models.Manager):
|
|||
# The User and player Object are ready, do anything needed by the
|
||||
# game to further prepare things.
|
||||
user_object.scriptlink.at_player_creation()
|
||||
|
||||
# Activate the player's session and set them loose.
|
||||
command.session.login(user, first_login=True)
|
||||
|
||||
logger.log_infomsg('Registration: %s' % user_object.get_name())
|
||||
|
||||
# Add the user to all of the CommChannel objects that are flagged
|
||||
# is_joined_by_default.
|
||||
command.session.add_default_channels()
|
||||
|
||||
# Add user to the default permission group, if defined set in preferences.
|
||||
command.session.add_default_group()
|
||||
|
||||
logger.log_infomsg("Registered new user: %s" % user_object.get_name())
|
||||
|
||||
# Activate the player's session and set them loose.
|
||||
command.session.login(user, first_login=True)
|
||||
|
||||
|
||||
#
|
||||
# ObjectManager Copy method
|
||||
#
|
||||
|
|
|
|||
|
|
@ -127,6 +127,10 @@ class Object(models.Model):
|
|||
#state system can set a particular command table to be used (not persistent).
|
||||
state = None
|
||||
|
||||
class Meta:
|
||||
ordering = ['-date_created', 'id']
|
||||
permissions = settings.PERM_OBJECTS
|
||||
|
||||
def __cmp__(self, other):
|
||||
"""
|
||||
Used to figure out if one object is the same as another.
|
||||
|
|
@ -136,9 +140,6 @@ class Object(models.Model):
|
|||
def __str__(self):
|
||||
return "%s" % (self.get_name(no_ansi=True),)
|
||||
|
||||
class Meta:
|
||||
ordering = ['-date_created', 'id']
|
||||
|
||||
def dbref(self):
|
||||
"""Returns the object's dbref id on the form #NN, directly
|
||||
usable by Object.objects.dbref_search()
|
||||
|
|
@ -206,8 +207,8 @@ class Object(models.Model):
|
|||
if self.is_player():
|
||||
return session_mgr.sessions_from_object(self)
|
||||
else:
|
||||
return []
|
||||
|
||||
return []
|
||||
|
||||
def emit_to(self, message):
|
||||
"""
|
||||
Emits something to any sessions attached to the object.
|
||||
|
|
@ -291,7 +292,7 @@ class Object(models.Model):
|
|||
looker_user = self.get_user_account()
|
||||
if looker_user:
|
||||
# Builders see dbrefs
|
||||
return looker_user.has_perm('genperms.builder')
|
||||
return looker_user.has_perm('objects.see_dbref')
|
||||
else:
|
||||
return False
|
||||
|
||||
|
|
@ -300,7 +301,9 @@ class Object(models.Model):
|
|||
Checks to see whether a user has the specified permission or is a super
|
||||
user.
|
||||
|
||||
perm: (string) A string representing the desired permission.
|
||||
perm: (string) A string representing the desired permission. This
|
||||
is on the form app.perm , e.g. 'objects.see_dbref' as
|
||||
defined in the settings file.
|
||||
"""
|
||||
if not self.is_player():
|
||||
return False
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue