From 1cad0d472bce3e42b07c21a1bfc10cda921d3f9d Mon Sep 17 00:00:00 2001 From: gfawcett Date: Mon, 27 Dec 2010 21:58:04 +0000 Subject: [PATCH] configurable default site access level. git-svn-id: svn://svn.open-ils.org/ILS-Contrib/servres/trunk@1119 6d9bc8c9-1ec2-4278-b937-99fde70a366f --- conifer/local_settings.py.example | 8 ++++++++ conifer/syrup/models.py | 17 +++++++++++------ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/conifer/local_settings.py.example b/conifer/local_settings.py.example index 290dec5..ba85208 100644 --- a/conifer/local_settings.py.example +++ b/conifer/local_settings.py.example @@ -55,6 +55,14 @@ Z3950_CONFIG = ('zed.concat.ca', 210, 'OWA') #OWA,OSUL,CONIFER # of Z39.50. #---------------------------------------------------------------------- +# SITE_DEFAULT_ACCESS_LEVEL: by default, all new sites are +# world-readable. Possible default values are ANON (world readable), +# LOGIN (any logged in user), MEMBR (only explicit members of the +# site), and CLOSE (only instructors/owners of the site). + +# SITE_DEFAULT_ACCESS_LEVEL = 'MEMBR' + +#---------------------------------------------------------------------- # INTEGRATION_MODULE: name of a module to import after the database # models have been initialized. This can be used for defining 'hook' # functions, and other late initializations. diff --git a/conifer/syrup/models.py b/conifer/syrup/models.py index ace11bc..42970ba 100644 --- a/conifer/syrup/models.py +++ b/conifer/syrup/models.py @@ -200,13 +200,18 @@ class Site(BaseModel): owner = m.ForeignKey(User) service_desk = m.ForeignKey(ServiceDesk) + ACCESS_CHOICES = [ + ('ANON', _('World-accessible')), + ('LOGIN', _('Accessible to all logged-in users')), + ('MEMBR', _('Accessible to course-site members')), + ('CLOSE', _('Accessible only to course-site owners'))] + + ACCESS_DEFAULT = getattr(settings, 'SITE_DEFAULT_ACCESS_LEVEL', 'ANON') + assert ACCESS_DEFAULT in [x[0] for x in ACCESS_CHOICES] + access = m.CharField(max_length=5, - default='ANON', - choices = [ - ('ANON', _('World-accessible')), - ('LOGIN', _('Accessible to all logged-in users')), - ('MEMBR', _('Accessible to course-site members')), - ('CLOSE', _('Accessible only to course-site owners'))]) + default=ACCESS_DEFAULT, + choices=ACCESS_CHOICES) @property def term(self): -- 2.11.0