Builders start seeing dbrefs for the most part.

This commit is contained in:
Greg Taylor 2009-01-15 16:24:52 +00:00
parent 8b89a4db2f
commit 462628ab55
4 changed files with 52 additions and 30 deletions

View file

@ -359,7 +359,7 @@ def cmd_who(command):
if show_session_data: if show_session_data:
retval += '%-31s%9s %4s%-3s#%-6d%5d%3s%-25s\r\n' % \ retval += '%-31s%9s %4s%-3s#%-6d%5d%3s%-25s\r\n' % \
(plr_pobject.get_name(show_dbref=False)[:25], \ (plr_pobject.get_name(show_dbref=True, show_flags=False)[:25], \
# On-time # On-time
functions_general.time_format(delta_conn,0), \ functions_general.time_format(delta_conn,0), \
# Idle time # Idle time

View file

@ -184,9 +184,10 @@ def msg_cwho(session, channel_name):
session: (SessionProtocol) A reference to the player session. session: (SessionProtocol) A reference to the player session.
channel_name: (str) The channel's full name. channel_name: (str) The channel's full name.
""" """
pobject = session.get_pobject()
session.msg("--- Users Listening to %s ---" % (channel_name,)) session.msg("--- Users Listening to %s ---" % (channel_name,))
for plr_sess in get_cwho_list(channel_name): for plr_sess in get_cwho_list(channel_name):
session.msg(plr_sess.get_pobject().get_name(show_dbref=False)) session.msg(plr_sess.get_pobject().get_name(show_dbref=pobject.sees_dbrefs()))
session.msg("--- End Channel Listeners ---") session.msg("--- End Channel Listeners ---")
def get_cwho_list(channel_name, return_muted=False): def get_cwho_list(channel_name, return_muted=False):

View file

@ -183,34 +183,51 @@ class Object(models.Model):
for obj in contents: for obj in contents:
obj.emit_to(message) obj.emit_to(message)
def get_user_account(self):
"""
Returns the player object's account object (User object).
"""
return User.objects.get(id=self.id)
def is_staff(self): def is_staff(self):
""" """
Returns TRUE if the object is a staff player. Returns True if the object is a staff player.
""" """
if not self.is_player(): if not self.is_player():
return False return False
profile = User.objects.filter(id=self.id) try:
profile = self.get_user_account()
if len(profile) == 0: return profile.is_staff
except User.DoesNotExist:
return False return False
else:
return profile[0].is_staff
def is_superuser(self): def is_superuser(self):
""" """
Returns TRUE if the object is a super user player. Returns True if the object is a super user player.
""" """
if not self.is_player(): if not self.is_player():
return False return False
profile = User.objects.filter(id=self.id) try:
profile = self.get_user_account()
if len(profile) == 0: return profile.is_superuser
except User.DoesNotExist:
return False return False
def sees_dbrefs(self):
"""
Returns True if the object sees dbrefs in messages. This is here
instead of session.py due to potential future expansion in the
direction of MUX-style puppets.
"""
looker_user = self.get_user_account()
if looker_user:
# Builders see dbrefs
return looker_user.has_perm('genperms.builder')
else: else:
return profile[0].is_superuser return False
def user_has_perm(self, perm): def user_has_perm(self, perm):
""" """
@ -301,16 +318,9 @@ class Object(models.Model):
pobject = self.get_user_account() pobject = self.get_user_account()
pobject.username = new_name pobject.username = new_name
pobject.save() pobject.save()
def get_user_account(self):
"""
Returns the player object's account object (User object).
"""
if not self.is_player():
return False
return User.objects.get(id=self.id)
def get_name(self, fullname=False, show_dbref=True, no_ansi=False): def get_name(self, fullname=False, show_dbref=True, show_flags=True,
no_ansi=False):
""" """
Returns an object's name. Returns an object's name.
""" """
@ -320,14 +330,22 @@ class Object(models.Model):
name_string = self.name name_string = self.name
if show_dbref: if show_dbref:
dbref_string = "(#%s%s)" % (self.id, self.flag_string()) # Allow hiding of the flags but show the dbref.
if show_flags:
flag_string = self.flag_string()
else:
flag_string = ""
dbref_string = "(#%s%s)" % (self.id, flag_string)
else: else:
dbref_string = "" dbref_string = ""
if fullname: if fullname:
return "%s%s" % (ansi.parse_ansi(name_string, strip_ansi=no_ansi), dbref_string) return "%s%s" % (ansi.parse_ansi(name_string, strip_ansi=no_ansi),
dbref_string)
else: else:
return "%s%s" % (ansi.parse_ansi(name_string.split(';')[0], strip_ansi=no_ansi), dbref_string) return "%s%s" % (ansi.parse_ansi(name_string.split(';')[0],
strip_ansi=no_ansi), dbref_string)
def set_description(self, new_desc): def set_description(self, new_desc):
""" """

View file

@ -38,15 +38,18 @@ class EvenniaBasicObject(object):
""" """
target_obj = self.source_obj target_obj = self.source_obj
pobject = values["pobject"] pobject = values["pobject"]
show_dbrefs = pobject.sees_dbrefs()
description = target_obj.get_description() description = target_obj.get_description()
if description is not None: if description is not None:
retval = "%s\r\n%s" % ( retval = "%s\r\n%s" % (
target_obj.get_name(), target_obj.get_name(show_dbref=show_dbrefs),
target_obj.get_description(), target_obj.get_description(),
) )
else: else:
retval = "%s" % ( retval = "%s" % (
target_obj.get_name(), target_obj.get_name(show_dbref=show_dbrefs),
) )
con_players = [] con_players = []
@ -65,15 +68,15 @@ class EvenniaBasicObject(object):
if not con_players == []: if not con_players == []:
retval += "\n\r%sPlayers:%s" % (ansi.ansi["hilite"], ansi.ansi["normal"],) retval += "\n\r%sPlayers:%s" % (ansi.ansi["hilite"], ansi.ansi["normal"],)
for player in con_players: for player in con_players:
retval +='\n\r%s' %(player.get_name(),) retval +='\n\r%s' %(player.get_name(show_dbref=show_dbrefs),)
if not con_things == []: if not con_things == []:
retval += "\n\r%sContents:%s" % (ansi.ansi["hilite"], ansi.ansi["normal"],) retval += "\n\r%sContents:%s" % (ansi.ansi["hilite"], ansi.ansi["normal"],)
for thing in con_things: for thing in con_things:
retval += '\n\r%s' %(thing.get_name(),) retval += '\n\r%s' %(thing.get_name(show_dbref=show_dbrefs),)
if not con_exits == []: if not con_exits == []:
retval += "\n\r%sExits:%s" % (ansi.ansi["hilite"], ansi.ansi["normal"],) retval += "\n\r%sExits:%s" % (ansi.ansi["hilite"], ansi.ansi["normal"],)
for exit in con_exits: for exit in con_exits:
retval += '\n\r%s' %(exit.get_name(),) retval += '\n\r%s' %(exit.get_name(show_dbref=show_dbrefs),)
return retval return retval