* fixes bug where permissions would be checked on non-logged in users which caused errors
28 lines
786 B
Python
28 lines
786 B
Python
"""
|
|
Author: Michel Peltriaux
|
|
Created on: 14.12.25
|
|
|
|
"""
|
|
from abc import ABC
|
|
|
|
from django.contrib.auth.mixins import LoginRequiredMixin
|
|
from django.http import HttpRequest, JsonResponse
|
|
from django.utils.decorators import method_decorator
|
|
from django.views import View
|
|
|
|
from konova.decorators import default_group_required
|
|
from konova.utils.generators import IdentifierGenerator
|
|
|
|
|
|
class AbstractIdentifierGeneratorView(LoginRequiredMixin, View, ABC):
|
|
_MODEL = None
|
|
|
|
@method_decorator(default_group_required)
|
|
def get(self, request: HttpRequest, *args, **kwargs):
|
|
generator = IdentifierGenerator(model=self._MODEL)
|
|
identifier = generator.generate_id()
|
|
return JsonResponse(
|
|
data={
|
|
"gen_data": identifier
|
|
}
|
|
) |