fnp
/
cas.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
6e3dcb6
)
Auto-generate keys for services.
author
Radek Czajka
<rczajka@rczajka.pl>
Sat, 30 Mar 2019 22:33:45 +0000
(23:33 +0100)
committer
Radek Czajka
<rczajka@rczajka.pl>
Sat, 30 Mar 2019 22:35:42 +0000
(23:35 +0100)
src/services/models.py
patch
|
blob
|
history
diff --git
a/src/services/models.py
b/src/services/models.py
index
593eff2
..
c7a5d97
100644
(file)
--- a/
src/services/models.py
+++ b/
src/services/models.py
@@
-1,3
+1,4
@@
+import secrets
from django.conf import settings
from django.contrib.auth.models import User
from django.db import models
from django.conf import settings
from django.contrib.auth.models import User
from django.db import models
@@
-20,6
+21,11
@@
class Service(models.Model):
def __str__(self):
return self.name
def __str__(self):
return self.name
+ def save(self, *args, **kwargs):
+ if not self.key:
+ self.key = secrets.token_urlsafe()
+ return super().save(*args, **kwargs)
+
def all_users(self):
return User.objects.filter(
models.Q(service=self) |
def all_users(self):
return User.objects.filter(
models.Q(service=self) |