Beispiel #1
0
def forward(request, token):

    # get the forwarding Forward
    sl = ShortLink.find(token=token)

    if sl.disabled:
        raise Http404

    # Click :)
    click_link(token, request.META)

    if not re.search("^https?://.+", sl.url):
        forward_url = "http://{0}".format(sl.url)
    else:
        forward_url = sl.url

    # Add the points to the user
    user_link = UserLink.objects.get(token=token)
    # If returns something then level upload then notification
    new_level = utils.incr_points(user_link.user, settings.POINTS_PER_CLICK)
    if new_level:
        # Send notifications
        notif = LevelNotification(level=new_level,
                                  user_id=user_link.user.id)
        #notif.send_push()  # Push realtime notification
        notif.save()  # save the notification for the dashboard

    return redirect(forward_url)
Beispiel #2
0
    def test_basic_increment_with_level(self):
        incr_points = 5000
        user = User.objects.get(id=1)

        self.assertEqual(0, user.profile.points)
        self.assertEqual(0, user.profile.level.level_number)

        level = utils.incr_points(user, incr_points)
        self.assertEqual(incr_points, user.profile.points)
        self.assertEqual(5, user.profile.level.level_number)
        self.assertEqual(5, level.level_number)