|
|
@ -37,9 +37,9 @@ class ShortLink(RandomSlugPKMixin, models.Model): |
|
|
|
return f"{self.domain.fqdn}/{self.location}" |
|
|
|
return f"{self.domain.fqdn}/{self.location}" |
|
|
|
|
|
|
|
|
|
|
|
@classmethod |
|
|
|
@classmethod |
|
|
|
def get_from_request(cls, req): |
|
|
|
def get_from_request(cls, req, loc): |
|
|
|
d = Domain.get_from_request(req) |
|
|
|
d = Domain.get_from_request(req) |
|
|
|
return cls.objects.filter(domain=d).get(location=req.path[1:]) |
|
|
|
return cls.objects.filter(domain=d).get(location=loc) |
|
|
|
|
|
|
|
|
|
|
|
@classmethod |
|
|
|
@classmethod |
|
|
|
def hit(cls, req, loc): |
|
|
|
def hit(cls, req, loc): |
|
|
@ -50,7 +50,7 @@ class ShortLink(RandomSlugPKMixin, models.Model): |
|
|
|
|
|
|
|
|
|
|
|
@classmethod |
|
|
|
@classmethod |
|
|
|
def miss(cls, req, loc): |
|
|
|
def miss(cls, req, loc): |
|
|
|
lnk = cls.get_from_request(req) |
|
|
|
lnk = cls.get_from_request(req, loc) |
|
|
|
cls.cache[req.get_host()][loc] = lnk.to |
|
|
|
cls.cache[req.get_host()][loc] = lnk.to |
|
|
|
return lnk.to |
|
|
|
return lnk.to |
|
|
|
|
|
|
|
|
|
|
|