def get(self, request, identifier): note_id = utils.url_hash_decode(identifier) note = get_object_or_404(Note, pk=note_id) if note.is_private and note.user != request.user: return HttpResponseForbidden() context = dict(note=note) return render(request, 'pastoapp/note_view.html', context)
def test_decode_hash_to_int(self): self.assertEqual(int(utils.url_hash_decode('GeA')), 52615)
def test_decode_hash_to_string(self): self.assertEqual(utils.url_hash_decode('HTh'), '55372')