Browse Source

made a @classmethod out of set_granted

master
Benni Baermann 4 years ago
parent
commit
0c20053f45
2 changed files with 7 additions and 7 deletions
  1. +6
    -0
      input/models.py
  2. +1
    -7
      input/views.py

+ 6
- 0
input/models.py View File

@ -7,6 +7,12 @@ class Volunteer(models.Model):
username = models.CharField(max_length=200, null=True) username = models.CharField(max_length=200, null=True)
granted = models.BooleanField(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: class Meta:
abstract = True abstract = True

+ 1
- 7
input/views.py View File

@ -13,15 +13,9 @@ from .models import Project, TYPE_CHOICES, Library
from .settings import URLPREFIX, IF_EMAIL 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): def authorize(request, choice, pk):
if choice in ('BIB', 'ELIT', 'SOFT'): 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}") return HttpResponse(f"AUTHORIZED! choice: {choice}, pk: {pk}")
else: else:
return HttpResponse('ERROR! UNKNWON CHOICE TYPE!') return HttpResponse('ERROR! UNKNWON CHOICE TYPE!')

Loading…
Cancel
Save