Initial commit
This commit is contained in:
commit
d6ff82eab2
14 changed files with 688 additions and 0 deletions
24
sqrl/managers.py
Normal file
24
sqrl/managers.py
Normal file
|
@ -0,0 +1,24 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from django.db import models
|
||||
|
||||
|
||||
class SQRLNutManager(models.Manager):
|
||||
"""
|
||||
Customer :obj:`.models.SQRLNut` model manager.
|
||||
"""
|
||||
|
||||
def replace_or_create(self, session_key, **kwargs):
|
||||
"""
|
||||
This method creates new :obj:`.models.SQRLNut` with given parameters.
|
||||
|
||||
If nut already exists, it removes it before creating new nut.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
session_key : str
|
||||
Key of the session. All nuts with matching session will be removed.
|
||||
**kwargs
|
||||
Kwargs which will be used to create new :obj:`.models.SQRLNut`
|
||||
"""
|
||||
self.get_queryset().filter(session_key=session_key).delete()
|
||||
return self.create(session_key=session_key, **kwargs)
|
Loading…
Add table
Add a link
Reference in a new issue