<s> """<STR_LIT>""" <EOL> from django . conf import settings <EOL> from django . http import Http404 <EOL> from django . shortcuts import get_object_or_404 <EOL> from django . utils . functional import cached_property <EOL> from django . views . generic import DetailView <EOL> from redis import StrictRedis <EOL> from . models import Delivery , WebhookTarget <EOL> from . senders . redislog import make_key <EOL> redis = StrictRedis ( <EOL> host = getattr ( settings , "<STR_LIT>" , '<STR_LIT:localhost>' ) , <EOL> port = getattr ( settings , "<STR_LIT>" , <NUM_LIT> ) , <EOL> db = getattr ( settings , "<STR_LIT>" , <NUM_LIT:0> ) ) <EOL> class WebhookTargetDetailView ( DetailView ) : <EOL> max_deliveries_listed = <NUM_LIT:20> <EOL> @ property <EOL> def webhoot_target ( self ) : <EOL> return self . object <EOL> @ cached_property <EOL> def object ( self ) : <EOL> return self . get_object ( ) <EOL> def get_object ( self ) : <EOL> if '<STR_LIT>' in self . kwargs : <EOL> return get_object_or_404 ( <EOL> WebhookTarget , <EOL> pk = self . kwargs [ '<STR_LIT>' ] <EOL> ) <EOL> if '<STR_LIT>' in self . kwargs : <EOL> return get_object_or_404 ( <EOL> WebhookTarget , <EOL> pk = self . kwargs [ '<STR_LIT>' ] <EOL> ) <EOL> raise Http404 <EOL> @ cached_property <EOL> def deliveries ( self ) : <EOL> return Delivery . objects . filter ( <EOL> webhoot_target = self . webhook_target <EOL> ) [ : self . max_deliveries_listed ] <EOL> class ProtectedWebhookTargetDetailView ( WebhookTargetDetailView ) : <EOL> def get_object ( self ) : <EOL> if '<STR_LIT>' in self . kwargs : <EOL> return get_object_or_404 ( <EOL> WebhookTarget , <EOL> pk = self . kwargs [ '<STR_LIT>' ] , <EOL> owner = self . request . user <EOL> ) <EOL> if '<STR_LIT>' in self . kwargs : <EOL> return get_object_or_404 ( <EOL> WebhookTarget , <EOL> pk = self . kwargs [ '<STR_LIT>' ] , <EOL> owner = self . request . user <EOL> ) <EOL> raise Http404 <EOL> class WebhookTargetRedisDetailView ( WebhookTargetDetailView ) : <EOL> @ cached_property <EOL> def deliveries ( self ) : <EOL> """<STR_LIT>""" <EOL> key = make_key ( <EOL> event = self . object . event , <EOL> owner_name = self . object . owner . username , <EOL> identifier = self . object . identifier <EOL> ) <EOL> return redis . lrange ( key , <NUM_LIT:0> , <NUM_LIT:20> ) <EOL> class ProtectedWebhookTargetRedisDetailView ( WebhookTargetRedisDetailView ) : <EOL> def get_object ( self ) : <EOL> if '<STR_LIT>' in self . kwargs : <EOL> return get_object_or_404 ( <EOL> WebhookTarget , <EOL> pk = self . kwargs [ '<STR_LIT>' ] , <EOL> owner = self . request . user <EOL> ) <EOL> if '<STR_LIT>' in self . kwargs : <EOL> return get_object_or_404 ( <EOL> WebhookTarget , <EOL> pk = self . kwargs [ '<STR_LIT>' ] , <EOL> owner = self . request . user <EOL> ) <EOL> raise Http404 </s>
