made a @classmethod out of set_granted
This commit is contained in:
parent
a31d4edc44
commit
0c20053f45
|
@ -7,6 +7,12 @@ class Volunteer(models.Model):
|
|||
username = models.CharField(max_length=200, null=True)
|
||||
granted = models.BooleanField(null=True)
|
||||
|
||||
@classmethod
|
||||
def set_granted(cl, key, b):
|
||||
obj = cl.objects.get(pk=key)
|
||||
obj.granted = b
|
||||
obj.save()
|
||||
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
||||
|
|
|
@ -13,15 +13,9 @@ from .models import Project, TYPE_CHOICES, Library
|
|||
from .settings import URLPREFIX, IF_EMAIL
|
||||
|
||||
|
||||
def set_granted_in_lib(key,b):
|
||||
lib = Library.objects.get(pk=key)
|
||||
lib.granted = b
|
||||
lib.save()
|
||||
|
||||
|
||||
def authorize(request, choice, pk):
|
||||
if choice in ('BIB', 'ELIT', 'SOFT'):
|
||||
set_granted_in_lib(pk,True)
|
||||
Library.set_granted(pk,True)
|
||||
return HttpResponse(f"AUTHORIZED! choice: {choice}, pk: {pk}")
|
||||
else:
|
||||
return HttpResponse('ERROR! UNKNWON CHOICE TYPE!')
|
||||
|
|
Loading…
Reference in New Issue