- 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:
Griatch 2009-10-03 14:40:34 +00:00
parent 77f2186d9a
commit 7f7306a6e4
23 changed files with 341 additions and 214 deletions

View file

@ -7,6 +7,7 @@ import sys
from datetime import datetime
from twisted.conch.telnet import StatefulTelnetProtocol
from django.contrib.auth.models import User
from django.contrib.auth.models import Group
from django.conf import settings
from util import functions_general
from src.objects.models import Object
@ -202,15 +203,27 @@ class SessionProtocol(StatefulTelnetProtocol):
Adds the player to the default channels.
"""
# Add the default channels.
for chan in CommChannel.objects.filter(is_joined_by_default=True):
#logger.log_infomsg("ADDING BY DEFAULT %s" % chan)
chan_alias = chan.get_default_chan_alias()
membership = CommChannelMembership(channel=chan,
listener=self.get_pobject(),
user_alias=chan_alias)
membership.save()
for chan in CommChannel.objects.filter(is_joined_by_default=True):
chan_alias = chan.get_default_chan_alias()
comsys.plr_add_channel(self.get_pobject(), chan_alias, chan)
comsys.plr_set_channel_listening(self, chan_alias, True)
def add_default_group(self):
default_group = settings.PERM_DEFAULT_PLAYER_GROUP.strip()
if not default_group:
logger.log_infomsg("settings.DEFAULT_PLAYER_GROUP is not set. Using no group.")
return
try:
group = Group.objects.get(name=default_group)
except Group.DoesNotExist:
logger.log_errmsg("settings.DEFAULT_PLAYER_GROUP = %s is not a valid group. Using no group." % default_group)
return
pobj = self.get_pobject()
user = User.objects.get(username=pobj.get_name(show_dbref=False,no_ansi=True))
user.groups.add(group)
logger.log_infomsg("Added new player to default permission group '%s'." % default_group)
user.save(); pobj.save()
def __str__(self):
"""
String representation of the user session class. We use