Moved permissions into a the tag system as a separate handler. Permissions still don't work quite right yet.

This commit is contained in:
Griatch 2013-08-24 23:57:44 +02:00
parent 2acff2d1ab
commit 06e858b3f6
21 changed files with 1003 additions and 389 deletions

View file

@ -508,10 +508,10 @@ class CmdPerm(MuxCommand):
return
string = "Permissions on {w%s{n: " % obj.key
if not obj.permissions:
if not obj.permissions.all():
string += "<None>"
else:
string += ", ".join(obj.permissions)
string += ", ".join(obj.permissions.all())
if hasattr(obj, 'player') and hasattr(obj.player, 'is_superuser') and obj.player.is_superuser:
string += "\n(... but this object is currently controlled by a SUPERUSER! "
string += "All access checks are passed automatically.)"
@ -528,20 +528,12 @@ class CmdPerm(MuxCommand):
tstring = ""
if 'del' in switches:
# delete the given permission(s) from object.
for perm in self.rhslist:
try:
index = obj.permissions.index(perm)
except ValueError:
cstring += "\nPermission '%s' was not defined on %s." % (perm, obj.name)
continue
permissions = obj.permissions
del permissions[index]
obj.permissions = permissions
cstring += "\nPermission '%s' was removed from %s." % (perm, obj.name)
tstring += "\n%s revokes the permission '%s' from you." % (caller.name, perm)
obj.permission.remove(self.rhslist)
cstring += "\nPermission(s) %s removed from %s (if they existed)." % (", ".join(self.rhslist), obj.name)
tstring += "\n%s revokes the permission(s) %s from you." % (caller.name, ", ".join(self.rhslist))
else:
# add a new permission
permissions = obj.permissions
permissions = obj.permissions.all()
for perm in self.rhslist:
@ -554,8 +546,7 @@ class CmdPerm(MuxCommand):
if perm in permissions:
cstring += "\nPermission '%s' is already defined on %s." % (rhs, obj.name)
else:
permissions.append(perm)
obj.permissions = permissions
obj.permissions.add(perm)
cstring += "\nPermission '%s' given to %s." % (rhs, obj.name)
tstring += "\n%s gives you the permission '%s'." % (caller.name, rhs)
caller.msg(cstring.strip())

View file

@ -1576,7 +1576,7 @@ class CmdExamine(ObjManipCommand):
string += "\n{wsession(s){n: %s" % (", ".join(str(sess.sessid) for sess in obj.sessions))
if hasattr(obj, "has_player") and obj.has_player:
string += "\n{wPlayer{n: {c%s{n" % obj.player.name
perms = obj.player.permissions
perms = obj.player.permissions.all()
if obj.player.is_superuser:
perms = ["<Superuser>"]
elif not perms:
@ -1591,7 +1591,7 @@ class CmdExamine(ObjManipCommand):
string += "\n{wDestination{n: %s" % obj.destination
if obj.destination:
string += " (#%s)" % obj.destination.id
perms = obj.permissions
perms = obj.permissions.all()
if perms:
perms_string = (", ".join(perms))
else:

View file

@ -433,8 +433,8 @@ class CmdAccess(MuxCommand):
cperms = "<Superuser>"
pperms = "<Superuser>"
else:
cperms = ", ".join(caller.permissions)
pperms = ", ".join(caller.player.permissions)
cperms = ", ".join(caller.permissions.all())
pperms = ", ".join(caller.player.permissions.all())
string += "\n{wYour access{n:"
string += "\nCharacter {c%s{n: %s" % (caller.key, cperms)

View file

@ -110,12 +110,12 @@ class CmdOOCLook(MuxPlayerCommand):
sess = player.get_session(csessid)
sid = sess in sessions and sessions.index(sess) + 1
if sess and sid:
string += "\n - {G%s{n [%s] (played by you in session %i)" % (char.key, ", ".join(char.permissions), sid)
string += "\n - {G%s{n [%s] (played by you in session %i)" % (char.key, ", ".join(char.permissions.all()), sid)
else:
string += "\n - {R%s{n [%s] (played by someone else)" % (char.key, ", ".join(char.permissions))
string += "\n - {R%s{n [%s] (played by someone else)" % (char.key, ", ".join(char.permissions.all()))
else:
# character is "free to puppet"
string += "\n - %s [%s]" % (char.key, ", ".join(char.permissions))
string += "\n - %s [%s]" % (char.key, ", ".join(char.permissions.all()))
string = ("-" * 68) + "\n" + string + "\n" + ("-" * 68)
self.msg(string)
@ -620,7 +620,7 @@ class CmdQuell(MuxPlayerCommand):
def func(self):
"Perform the command"
player = self.caller
permstr = player.is_superuser and " (superuser)" or " (%s)" % (", ".join(player.permissions))
permstr = player.is_superuser and " (superuser)" or " (%s)" % (", ".join(player.permissions.all()))
if self.cmdstring == '@unquell':
if not player.get_attribute('_quell'):
self.msg("Already using normal Player permissions%s." % permstr)

View file

@ -59,7 +59,7 @@ class CommandTest(TestCase):
self.player = create.create_player("TestPlayer%i" % self.CID, "test@test.com", "testpassword", typeclass=TestPlayerClass)
self.player2 = create.create_player("TestPlayer%ib" % self.CID, "test@test.com", "testpassword", typeclass=TestPlayerClass)
self.player.permissions = "Immortals"
self.player.permissions.add("Immortals")
self.char1.player = self.player
self.char1.sessid = 1