made a @classmethod out of set_granted

This commit is contained in:
Benni Bärmann 2020-10-20 12:00:59 +02:00
parent a31d4edc44
commit 0c20053f45
2 changed files with 7 additions and 7 deletions

View File

@ -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

View File

@ -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!')