diff --git a/input/models.py b/input/models.py index 88327f3..5e273fb 100644 --- a/input/models.py +++ b/input/models.py @@ -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 diff --git a/input/views.py b/input/views.py index afa9b8c..7a34e0c 100644 --- a/input/views.py +++ b/input/views.py @@ -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!')