Beginnings of our permissions system.
This commit is contained in:
parent
0e1e2ed1b0
commit
6f52e75725
7 changed files with 41 additions and 13 deletions
0
evennia/trunk/apps/genperms/__init__.py
Normal file
0
evennia/trunk/apps/genperms/__init__.py
Normal file
24
evennia/trunk/apps/genperms/models.py
Normal file
24
evennia/trunk/apps/genperms/models.py
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
from django.db import models
|
||||
|
||||
class GenericPerm(models.Model):
|
||||
"""
|
||||
This is merely a container class for some generic permissions that don't
|
||||
fit under a particular module.
|
||||
"""
|
||||
class Meta:
|
||||
permissions = (
|
||||
("announce", "May use @wall to make announcements"),
|
||||
("boot", "May use @boot to kick players"),
|
||||
("builder", "May build"),
|
||||
("chown_all", "Can @chown anything to anyone."),
|
||||
("control_all", "May control everything"),
|
||||
("examine_all", "Can examine any object"),
|
||||
("extended_who", "May see extended WHO list"),
|
||||
("free_money", "Has infinite money"),
|
||||
("long_fingers", "May get/look/examine etc. from a distance"),
|
||||
("steal", "May give negative money"),
|
||||
("set_hide", "May set themself invisible"),
|
||||
("shutdown", "May @shutdown the site"),
|
||||
("tel_anywhere", "May @teleport anywhere"),
|
||||
("tel_anyone", "May @teleport anything"),
|
||||
)
|
||||
1
evennia/trunk/apps/genperms/views.py
Normal file
1
evennia/trunk/apps/genperms/views.py
Normal file
|
|
@ -0,0 +1 @@
|
|||
# Create your views here.
|
||||
|
|
@ -1,7 +1,6 @@
|
|||
from django.db import models
|
||||
import ansi
|
||||
|
||||
# Create your models here.
|
||||
class HelpEntry(models.Model):
|
||||
"""
|
||||
A generic help entry.
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ class Attribute(models.Model):
|
|||
object = models.ForeignKey("Object")
|
||||
|
||||
def __str__(self):
|
||||
return "%s(%d)" % (self.name, self.id,)
|
||||
return "%s(%s)" % (self.name, self.id)
|
||||
|
||||
class Admin:
|
||||
list_display = ('object', 'name', 'value',)
|
||||
|
|
@ -62,15 +62,13 @@ class Object(models.Model):
|
|||
return "%s" % (self.get_name(),)
|
||||
|
||||
class Meta:
|
||||
permissions = (
|
||||
("can_examine", "Can examine objects"),
|
||||
)
|
||||
ordering = ['-date_created', 'id']
|
||||
|
||||
class Admin:
|
||||
list_display = ('id', 'name', 'type', 'date_created')
|
||||
list_filter = ('type',)
|
||||
search_fields = ['name']
|
||||
save_on_top = True
|
||||
|
||||
"""
|
||||
BEGIN COMMON METHODS
|
||||
|
|
@ -195,18 +193,21 @@ class Object(models.Model):
|
|||
Returns an object's name.
|
||||
"""
|
||||
if fullname:
|
||||
return "%s(#%d%s)" % (ansi.parse_ansi(self.name, strip_ansi=True),self.id, self.flag_string())
|
||||
return "%s(#%s%s)" % (ansi.parse_ansi(self.name, strip_ansi=True),self.id, self.flag_string())
|
||||
else:
|
||||
return "%s(#%d%s)" % (ansi.parse_ansi(self.name.split(';')[0], strip_ansi=True),self.id, self.flag_string())
|
||||
return "%s(#%s%s)" % (ansi.parse_ansi(self.name.split(';')[0], strip_ansi=True), self.id, self.flag_string())
|
||||
|
||||
def get_ansiname(self, fullname=False):
|
||||
"""
|
||||
Returns an object's ANSI'd name.
|
||||
"""
|
||||
if fullname:
|
||||
return "%s(#%d%s)" % (ansi.parse_ansi(self.ansi_name), self.id, self.flag_string())
|
||||
if self.ansi_name:
|
||||
if fullname:
|
||||
return "%s(#%s%s)" % (ansi.parse_ansi(self.ansi_name), self.id, self.flag_string())
|
||||
else:
|
||||
return "%s(#%s%s)" % (ansi.parse_ansi(self.ansi_name.split(';')[0]), self.id, self.flag_string())
|
||||
else:
|
||||
return "%s(#%d%s)" % (ansi.parse_ansi(self.ansi_name.split(';')[0]), self.id, self.flag_string())
|
||||
return self.get_name()
|
||||
|
||||
def set_description(self, new_desc):
|
||||
"""
|
||||
|
|
@ -492,6 +493,7 @@ class Object(models.Model):
|
|||
Moves the object to a new location.
|
||||
|
||||
target: (Object) Reference to the object to move to.
|
||||
quiet: (bool) If true, don't emit left/arrived messages.
|
||||
"""
|
||||
if not quiet:
|
||||
self.get_location().emit_to_contents("%s has left." % (self.get_ansiname(),), exclude=self)
|
||||
|
|
@ -592,9 +594,10 @@ class Object(models.Model):
|
|||
Returns the flag string for an object. This abbreviates all of the flags
|
||||
set on the object into a list of single-character flag characters.
|
||||
"""
|
||||
# TODO: Once we add a flag system, add the other flag types here.
|
||||
type_string = global_defines.OBJECT_TYPES[self.type][1][0]
|
||||
return type_string
|
||||
# We have to cast this because the admin interface is really picky
|
||||
# about tuple index types. Bleh.
|
||||
otype = int(self.type)
|
||||
return global_defines.OBJECT_TYPES[otype][1][0]
|
||||
|
||||
import functions_db
|
||||
import session_mgr
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -77,4 +77,5 @@ INSTALLED_APPS = (
|
|||
'apps.config',
|
||||
'apps.objects',
|
||||
'apps.helpsys',
|
||||
'apps.genperms',
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue