1
0
mirror of https://github.com/aquatix/digimarks.git synced 2025-12-06 22:05:09 +01:00

Moved key generation to User object itself; initialise its tags cache

This commit is contained in:
2016-07-23 15:10:58 +02:00
parent 9aef5162b4
commit ad4d839a1a

View File

@@ -46,10 +46,6 @@ except AttributeError:
all_tags = {}
def getkey():
return os.urandom(24).encode('hex')
def clean_tags(tags_list):
tags_res = [x.strip() for x in tags_list]
tags_res = list(unique_everseen(tags_res))
@@ -65,6 +61,11 @@ class User(db.Model):
key = CharField()
created_date = DateTimeField(default=datetime.datetime.now)
def generate_key(self):
""" Generate userkey """
self.key = os.urandom(24).encode('hex')
return self.key
class Bookmark(db.Model):
""" Bookmark instance, connected to User """
@@ -334,9 +335,10 @@ def adduser(systemkey):
""" Add user endpoint, convenience """
if systemkey == settings.SYSTEMKEY:
newuser = User()
newuser.key = getkey()
newuser.generate_key()
newuser.username = 'Nomen Nescio'
newuser.save()
all_tags[newuser.key] = []
return redirect('/' + newuser.key, code=302)
else:
abort(404)