Beispiel #1
0
 def get_object(self):
     # If preview code is given check if code is valid and extend queryset to all Hearings Published and Unpublished
     preview_code = self.request.query_params.get("preview")
     lookup_url_kwarg = self.lookup_url_kwarg or self.lookup_field
     if preview_code and lookup_url_kwarg in self.kwargs:
         # A preview code is provided and there is a object lookup
         if preview_code == get_hmac_b64_encoded(self.kwargs[lookup_url_kwarg]):
             # preview code match object
             queryset = Hearing.objects.with_unpublished()
             filter_kwargs = {self.lookup_field: self.kwargs[lookup_url_kwarg]}
             obj = get_object_or_404(queryset, **filter_kwargs)
             # May raise a permission denied
             self.check_object_permissions(self.request, obj)
             return obj
     return super().get_object()
Beispiel #2
0
 def get_object(self):
     # If preview code is given check if code is valid and extend queryset to all Hearings Published and Unpublished
     preview_code = self.request.query_params.get("preview")
     lookup_url_kwarg = self.lookup_url_kwarg or self.lookup_field
     if preview_code and lookup_url_kwarg in self.kwargs:
         # A preview code is provided and there is a object lookup
         if preview_code == get_hmac_b64_encoded(self.kwargs[lookup_url_kwarg]):
             # preview code match object
             queryset = Hearing.objects.with_unpublished()
             filter_kwargs = {self.lookup_field: self.kwargs[lookup_url_kwarg]}
             obj = get_object_or_404(queryset, **filter_kwargs)
             # May raise a permission denied
             self.check_object_permissions(self.request, obj)
             return obj
     return super().get_object()
Beispiel #3
0
 def preview_code(self):
     if not self.pk:
         return None
     return get_hmac_b64_encoded(self.pk)
Beispiel #4
0
 def preview_code(self):
     if not self.pk:
         return None
     return get_hmac_b64_encoded(self.pk)