Begin implementing content permissions
This commit is contained in:
parent
424f81bc2e
commit
3d8519154b
|
@ -102,3 +102,17 @@ class ContentBlock(models.Model):
|
|||
self.image3 = None
|
||||
|
||||
super().save(*args, **kwargs)
|
||||
|
||||
|
||||
class Role(models.Model):
|
||||
name = models.CharField(max_length=255, unique=True)
|
||||
description = models.CharField(max_length=1024, null=True, blank=True)
|
||||
permission = models.CharField(max_length=255)
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
|
||||
class ContentPermission(models.Model):
|
||||
inherit = models.ForeignKey("self", null=True, blank=True, on_delete=models.PROTECT)
|
||||
roles = models.ManyToManyField(Role, blank=True)
|
||||
|
|
|
@ -21,19 +21,17 @@ def dedup_list(data, check_keys):
|
|||
return out
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# from random import randint
|
||||
# from timeit import timeit
|
||||
# entries = 10000
|
||||
# a = [
|
||||
# {'ts': "sss", 'msg': randint(1, 2), str(randint(1, 2)): randint(1, 2)} for x in range(entries)
|
||||
# {'ts': "sss", 'msg': randint(1, 2), str(randint(1, 2)): \
|
||||
# randint(1, 2)} for x in range(entries)
|
||||
# ]
|
||||
# kk = ["msg", "nick"]
|
||||
# call = lambda: dedup_list(a, kk)
|
||||
# #print(timeit(call, number=10))
|
||||
# print(dedup_list(a, kk))
|
||||
|
||||
# # sh-5.1$ python helpers.py
|
||||
# # 1.0805372429895215
|
||||
# # sh-5.1$ python helpers.py
|
||||
# # 1.0805372429895215
|
||||
|
|
Loading…
Reference in New Issue