forked from 0x2620/pandora
anon does not have a profile
This commit is contained in:
parent
6a6ba425bb
commit
e2a6c8a663
1 changed files with 7 additions and 2 deletions
|
@ -128,7 +128,8 @@ class Item(models.Model):
|
||||||
|
|
||||||
#while metadata is updated, files are set to rendered=False
|
#while metadata is updated, files are set to rendered=False
|
||||||
rendered = models.BooleanField(default=False, db_index=True)
|
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)
|
itemId = models.CharField(max_length=128, unique=True, blank=True)
|
||||||
oxdbId = models.CharField(max_length=42, unique=True, blank=True, null=True)
|
oxdbId = models.CharField(max_length=42, unique=True, blank=True, null=True)
|
||||||
|
@ -162,7 +163,11 @@ class Item(models.Model):
|
||||||
return default
|
return default
|
||||||
|
|
||||||
def access(self, user):
|
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:
|
if self.level < allowed_level:
|
||||||
return True
|
return True
|
||||||
elif user.is_authenticated() and \
|
elif user.is_authenticated() and \
|
||||||
|
|
Loading…
Reference in a new issue