Example #1
0
def staff_pick_stamps(request, page):
    page = int(page)
    page_size = 20

    b36_ids = knobs.REMIX_IMAGES_STAFF_PICKS[page*page_size:(page+1)*page_size]

    ids = [util.base36decode(b36_id) for b36_id in b36_ids]

    details = CachedCall.queryset_details(Comment.objects.in_bulk_list(ids))

    return {'comments': details}
Example #2
0
def staff_pick_stamps(request, page):
    page = int(page)
    page_size = 20

    b36_ids = knobs.REMIX_IMAGES_STAFF_PICKS[page * page_size:(page + 1) *
                                             page_size]

    ids = [util.base36decode(b36_id) for b36_id in b36_ids]

    details = CachedCall.queryset_details(Comment.objects.in_bulk_list(ids))

    return {'comments': details}
Example #3
0
    def process_request(self, request):
        share_b36 = request.GET.get('s')
        if not share_b36:
            return
            
        try:
            share_id = base36decode(share_b36)
        except Base36DecodeException:
            return

        stu = ShareTrackingUrl.objects.get_or_none(id=share_id)
        if not stu:
            return
            
        stu.record_view(request)
Example #4
0
def reverse_invite_id(invite_id):
    """
    `invite_id` is the slug portion of an invite URL.

    Returns a pair of `(user, url,)`
    """
    keys = invite_id.split(DELIMITER)
    keys = [util.base36decode(e) for e in keys]

    user_id = keys.pop(0)
    user = get_object_or_404(User, pk=user_id)

    try:
        comment_id = keys.pop(0)
        comment = get_object_or_404(canvas.models.Comment, pk=comment_id)
        url = comment.get_absolute_url()
    except IndexError:
        url = '/'

    return (user, url,)
Example #5
0
def reverse_invite_id(invite_id):
    """
    `invite_id` is the slug portion of an invite URL.

    Returns a pair of `(user, url,)`
    """
    keys = invite_id.split(DELIMITER)
    keys = [util.base36decode(e) for e in keys]

    user_id = keys.pop(0)
    user = get_object_or_404(User, pk=user_id)

    try:
        comment_id = keys.pop(0)
        comment = get_object_or_404(canvas.models.Comment, pk=comment_id)
        url = comment.get_absolute_url()
    except IndexError:
        url = '/'

    return (
        user,
        url,
    )
 def test_decode_negative_number_raises_Base36DecodeException(self):
     with self.assertRaises(util.Base36DecodeException):
         util.base36decode('-1j')
 def test_decode_invalid_characters_raises_Base36DecodeException(self):
     with self.assertRaises(util.Base36DecodeException):
         util.base36decode('1!')
 def test_decode_bad_check_digit_raises_Base36DecodeException(self):
     with self.assertRaises(util.Base36DecodeException):
         util.base36decode('1x') # 1j is correct
 def test_decode_happy_paths(self):
     for happy_int, happy_b36 in self.happy_paths:
         self.assertEqual(util.base36decode(happy_b36), happy_int)
Example #10
0
def long_id(short_id):
    return util.base36decode(short_id)
Example #11
0
 def test_decode_negative_number_raises_Base36DecodeException(self):
     with self.assertRaises(util.Base36DecodeException):
         util.base36decode('-1j')
Example #12
0
 def test_decode_invalid_characters_raises_Base36DecodeException(self):
     with self.assertRaises(util.Base36DecodeException):
         util.base36decode('1!')
Example #13
0
 def test_decode_bad_check_digit_raises_Base36DecodeException(self):
     with self.assertRaises(util.Base36DecodeException):
         util.base36decode('1x')  # 1j is correct
Example #14
0
 def test_decode_happy_paths(self):
     for happy_int, happy_b36 in self.happy_paths:
         self.assertEqual(util.base36decode(happy_b36), happy_int)
Example #15
0
def long_id(short_id):
    return util.base36decode(short_id)