From e2a6c8a663732d33502ca84b485c4ea8c8d79ae2 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Fri, 16 Sep 2011 13:17:49 -0400 Subject: [PATCH] anon does not have a profile --- pandora/item/models.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pandora/item/models.py b/pandora/item/models.py index 361f0452..468d5f37 100644 --- a/pandora/item/models.py +++ b/pandora/item/models.py @@ -128,7 +128,8 @@ class Item(models.Model): #while metadata is updated, files are set to rendered=False rendered = models.BooleanField(default=False, db_index=True) - level = models.IntegerField(default=False, db_index=True) + #should be set based on user + level = models.IntegerField(default=4, db_index=True) itemId = models.CharField(max_length=128, unique=True, blank=True) oxdbId = models.CharField(max_length=42, unique=True, blank=True, null=True) @@ -162,7 +163,11 @@ class Item(models.Model): return default def access(self, user): - allowed_level = settings.CONFIG['capabilities']['canSeeItem'][user.get_profile().get_level()] + if user.is_anonymous(): + level = 'guest' + else: + level = user.get_profile().get_level() + allowed_level = settings.CONFIG['capabilities']['canSeeItem'][level] if self.level < allowed_level: return True elif user.is_authenticated() and \