Index: ow/tests/models/test_root.py
===================================================================
--- ow/tests/models/test_root.py	(revision 68d00f524e30821aa6f27e5b322ccec0563817ac)
+++ ow/tests/models/test_root.py	(revision 24596dace05234b9fd49655a4798965c6bfed02c)
@@ -112,4 +112,22 @@
             user = root.get_user_by_email(Mock())
 
+    def test_get_user_by_nickname(self, root, john):
+        # set a nickname for john
+        john.nickname = 'JohnDoe'
+        root.reindex(john)
+        user = root.get_user_by_nickname('JohnDoe')
+        assert user == john
+        user = root.get_user_by_nickname('NonExistant')
+        assert user is None
+        # passing in None
+        user = root.get_user_by_nickname(None)
+        assert user is None
+        # passing in something that is not None or a string will break
+        # the query code
+        with pytest.raises(TypeError):
+            user = root.get_user_by_nickname(False)
+        with pytest.raises(TypeError):
+            user = root.get_user_by_nickname(Mock())
+
     def test_users(self, root, john):
         assert root.users == [john]
Index: ow/tests/models/test_user.py
===================================================================
--- ow/tests/models/test_user.py	(revision 68d00f524e30821aa6f27e5b322ccec0563817ac)
+++ ow/tests/models/test_user.py	(revision 24596dace05234b9fd49655a4798965c6bfed02c)
@@ -348,2 +348,206 @@
             'time': timedelta(0)
         }
+
+    def test_yearly_stats(self, root):
+        expected_no_stats_per_month = {
+            'workouts': 0,
+            'time': timedelta(0),
+            'distance': Decimal(0),
+            'elevation': Decimal(0),
+            'sports': {}
+        }
+
+        yearly_stats = root['john'].yearly_stats
+        for month, stats in yearly_stats.items():
+            assert stats == expected_no_stats_per_month
+
+        # add a cycling workout
+        start_date = datetime.now(timezone.utc)
+        workout = Workout(
+            start=start_date,
+            duration=timedelta(minutes=(60*4)),
+            uphill=1200,
+            distance=115,
+            sport='cycling')
+        root['john'].add_workout(workout)
+
+        yearly_stats = root['john'].yearly_stats
+        for month, stats in yearly_stats.items():
+            if month == (start_date.year, start_date.month):
+                assert stats == {
+                    'workouts': 1,
+                    'time': timedelta(minutes=(60*4)),
+                    'distance': Decimal(115),
+                    'elevation': Decimal(1200),
+                    'sports': {
+                        'cycling': {'distance': Decimal(115),
+                                    'elevation': Decimal(1200),
+                                    'time': timedelta(minutes=(60*4)),
+                                    'workouts': 1}
+                    }
+                }
+            else:
+                assert stats == expected_no_stats_per_month
+
+        # add a second cycling workout
+        workout = Workout(
+            start=start_date,
+            duration=timedelta(minutes=(30)),
+            uphill=500,
+            distance=20,
+            sport='cycling')
+        root['john'].add_workout(workout)
+
+        yearly_stats = root['john'].yearly_stats
+        for month, stats in yearly_stats.items():
+            if month == (start_date.year, start_date.month):
+                assert stats == {
+                    'workouts': 2,
+                    'time': timedelta(minutes=((60*4)+30)),
+                    'distance': Decimal(115+20),
+                    'elevation': Decimal(1200+500),
+                    'sports': {
+                        'cycling': {'distance': Decimal(115+20),
+                                    'elevation': Decimal(1200+500),
+                                    'time': timedelta(minutes=((60*4)+30)),
+                                    'workouts': 2}
+                    }
+                }
+            else:
+                assert stats == expected_no_stats_per_month
+
+        # add a running workout
+        workout = Workout(
+            start=start_date,
+            duration=timedelta(minutes=(60)),
+            uphill=200,
+            distance=5,
+            sport='running')
+        root['john'].add_workout(workout)
+
+        yearly_stats = root['john'].yearly_stats
+        for month, stats in yearly_stats.items():
+            if month == (start_date.year, start_date.month):
+                assert stats == {
+                    'workouts': 3,
+                    'time': timedelta(minutes=((60*4)+30+60)),
+                    'distance': Decimal(115+20+5),
+                    'elevation': Decimal(1200+500+200),
+                    'sports': {
+                        'cycling': {'distance': Decimal(115+20),
+                                    'elevation': Decimal(1200+500),
+                                    'time': timedelta(minutes=((60*4)+30)),
+                                    'workouts': 2},
+                        'running': {'distance': Decimal(5),
+                                    'elevation': Decimal(200),
+                                    'time': timedelta(minutes=(60)),
+                                    'workouts': 1}
+                    }
+                }
+            else:
+                assert stats == expected_no_stats_per_month
+
+    def test_weekly_year_stats(self, root):
+        expected_no_stats_per_week = {
+            'workouts': 0,
+            'time': timedelta(0),
+            'distance': Decimal(0),
+            'elevation': Decimal(0),
+            'sports': {}
+        }
+
+        weekly_year_stats = root['john'].weekly_year_stats
+        for week, stats in weekly_year_stats.items():
+            assert stats == expected_no_stats_per_week
+
+        # add a cycling workout
+        start_date = datetime.now(timezone.utc)
+        workout = Workout(
+            start=start_date,
+            duration=timedelta(minutes=(60*4)),
+            uphill=1200,
+            distance=115,
+            sport='cycling')
+        root['john'].add_workout(workout)
+
+        weekly_year_stats = root['john'].weekly_year_stats
+        workout_week = (start_date.year, start_date.month,
+                        start_date.isocalendar()[1])
+        for week, stats in weekly_year_stats.items():
+            if week[:3] == workout_week:
+                assert stats == {
+                    'workouts': 1,
+                    'time': timedelta(minutes=(60*4)),
+                    'distance': Decimal(115),
+                    'elevation': Decimal(1200),
+                    'sports': {
+                        'cycling': {'distance': Decimal(115),
+                                    'elevation': Decimal(1200),
+                                    'time': timedelta(minutes=(60*4)),
+                                    'workouts': 1}
+                    }
+                }
+            else:
+                assert stats == expected_no_stats_per_week
+
+        # add a second cycling workout
+        workout = Workout(
+            start=start_date,
+            duration=timedelta(minutes=(30)),
+            uphill=500,
+            distance=20,
+            sport='cycling')
+        root['john'].add_workout(workout)
+
+        weekly_year_stats = root['john'].weekly_year_stats
+        workout_week = (start_date.year, start_date.month,
+                        start_date.isocalendar()[1])
+        for week, stats in weekly_year_stats.items():
+            if week[:3] == workout_week:
+                assert stats == {
+                    'workouts': 2,
+                    'time': timedelta(minutes=((60*4)+30)),
+                    'distance': Decimal(115+20),
+                    'elevation': Decimal(1200+500),
+                    'sports': {
+                        'cycling': {'distance': Decimal(115+20),
+                                    'elevation': Decimal(1200+500),
+                                    'time': timedelta(minutes=((60*4)+30)),
+                                    'workouts': 2}
+                    }
+                }
+            else:
+                assert stats == expected_no_stats_per_week
+
+        # add a running workout
+        workout = Workout(
+            start=start_date,
+            duration=timedelta(minutes=(60)),
+            uphill=200,
+            distance=5,
+            sport='running')
+        root['john'].add_workout(workout)
+
+        weekly_year_stats = root['john'].weekly_year_stats
+        workout_week = (start_date.year, start_date.month,
+                        start_date.isocalendar()[1])
+        for week, stats in weekly_year_stats.items():
+            if week[:3] == workout_week:
+                assert stats == {
+                    'workouts': 3,
+                    'time': timedelta(minutes=((60*4)+30+60)),
+                    'distance': Decimal(115+20+5),
+                    'elevation': Decimal(1200+500+200),
+                    'sports': {
+                        'cycling': {'distance': Decimal(115+20),
+                                    'elevation': Decimal(1200+500),
+                                    'time': timedelta(minutes=((60*4)+30)),
+                                    'workouts': 2},
+                        'running': {'distance': Decimal(5),
+                                    'elevation': Decimal(200),
+                                    'time': timedelta(minutes=(60)),
+                                    'workouts': 1}
+                    }
+                }
+            else:
+                assert stats == expected_no_stats_per_week
Index: ow/tests/views/test_user.py
===================================================================
--- ow/tests/views/test_user.py	(revision 68d00f524e30821aa6f27e5b322ccec0563817ac)
+++ ow/tests/views/test_user.py	(revision 24596dace05234b9fd49655a4798965c6bfed02c)
@@ -13,5 +13,5 @@
 
 from pyramid.testing import DummyRequest
-from pyramid.httpexceptions import HTTPFound
+from pyramid.httpexceptions import HTTPFound, HTTPNotFound
 from pyramid.response import Response
 
@@ -475,4 +475,22 @@
         }
 
+    def test_profile_with_nickname(self, dummy_request, john):
+        """
+        Loading the profile page using the user nickname
+        """
+        request = dummy_request
+        john.nickname = 'JohnDoe'
+        request.root.reindex(john)
+        # first load using the uuid
+        response_uuid = user_views.profile(john, request)
+        # now, do it with the nickname
+        request.subpath = ['JohnDoe']
+        response_nickname = user_views.profile(request.root, request)
+        assert response_uuid == response_nickname
+        # try an unknown nickname, HTTPNotFound is returned
+        request.subpath = ['Invalid']
+        response_nickname = user_views.profile(request.root, request)
+        assert isinstance(response_nickname, HTTPNotFound)
+
     def test_login_get(self, dummy_request):
         """
@@ -675,4 +693,13 @@
         returned_image = Image.open(BytesIO(response.body))
         assert original_image.size == returned_image.size
+
+    def test_profile_picture_none(self, dummy_request, john):
+        """
+        GET request for an user without a profile picture
+        """
+        request = dummy_request
+        user = john
+        response = user_views.profile_picture(user, request)
+        assert isinstance(response, HTTPNotFound)
 
     def test_edit_profile_get(self, dummy_request, john):
@@ -1002,2 +1029,125 @@
                 day['time'] == '00'
                 day['workouts'] == 0
+
+    def test_last_months_stats(self, dummy_request, john):
+        request = dummy_request
+        user = john
+        response = user_views.last_months_stats(user, request)
+        assert isinstance(response, Response)
+        assert response.content_type == 'application/json'
+        # the body is a valid json-encoded stream
+        obj = json.loads(response.body)
+        assert len(obj) == 13
+        for month in obj:
+            assert len(month.keys()) == 7
+            assert 'id' in month.keys()
+            assert 'name' in month.keys()
+            assert month['distance'] == 0
+            assert month['elevation'] == 0
+            assert month['time'] == '00'
+            assert month['workouts'] == 0
+            assert str(user.uid) in month['url']
+            assert 'profile' in month['url']
+            assert 'year' in month['url']
+            assert 'month' in month['url']
+
+        # try now with a workout
+        workout_start = datetime.now(timezone.utc)
+        workout_start_id = (
+            str(workout_start.year) + '-' + str(workout_start.month).zfill(2))
+        workout = Workout(
+            sport='cycling',
+            start=workout_start,
+            duration=timedelta(minutes=60),
+            distance=30,
+            uphill=540
+        )
+        user.add_workout(workout)
+        response = user_views.last_months_stats(user, request)
+        assert isinstance(response, Response)
+        assert response.content_type == 'application/json'
+        # the body is a valid json-encoded stream
+        obj = json.loads(response.body)
+        assert len(obj) == 13
+        for month in obj:
+            assert len(month.keys()) == 7
+            assert 'id' in month.keys()
+            assert 'name' in month.keys()
+            assert str(user.uid) in month['url']
+            assert 'profile' in month['url']
+            assert 'year' in month['url']
+            assert 'month' in month['url']
+            if month['id'] == workout_start_id:
+                assert month['distance'] == 30
+                assert month['elevation'] == 540
+                assert month['time'] == '01'
+                assert month['workouts'] == 1
+            else:
+                assert month['distance'] == 0
+                assert month['elevation'] == 0
+                assert month['time'] == '00'
+                assert month['workouts'] == 0
+
+    def test_last_weeks_stats(self, dummy_request, john):
+        request = dummy_request
+        user = john
+        response = user_views.last_weeks_stats(user, request)
+        assert isinstance(response, Response)
+        assert response.content_type == 'application/json'
+        # the body is a valid json-encoded stream
+        obj = json.loads(response.body)
+        assert len(obj) == 68
+        for week in obj:
+            assert len(week.keys()) == 8
+            assert 'id' in week.keys()
+            assert 'name' in week.keys()
+            assert 'week' in week.keys()
+            assert week['distance'] == 0
+            assert week['elevation'] == 0
+            assert week['time'] == '00'
+            assert week['workouts'] == 0
+            assert str(user.uid) in week['url']
+            assert 'profile' in week['url']
+            assert 'year' in week['url']
+            assert 'month' in week['url']
+            assert 'week' in week['url']
+
+        # try now with a workout
+        workout_start = datetime.now(timezone.utc)
+        workout_start_id = str(workout_start.year)
+        workout_start_id += '-' + str(workout_start.month).zfill(2)
+        workout_start_id += '-' + str(workout_start.isocalendar()[1])
+        workout = Workout(
+            sport='cycling',
+            start=workout_start,
+            duration=timedelta(minutes=60),
+            distance=30,
+            uphill=540
+        )
+        user.add_workout(workout)
+        response = user_views.last_weeks_stats(user, request)
+        assert isinstance(response, Response)
+        assert response.content_type == 'application/json'
+        # the body is a valid json-encoded stream
+        obj = json.loads(response.body)
+        assert len(obj) == 68
+        for week in obj:
+            assert len(week.keys()) == 8
+            assert 'id' in week.keys()
+            assert 'name' in week.keys()
+            assert 'week' in week.keys()
+            assert str(user.uid) in week['url']
+            assert 'profile' in week['url']
+            assert 'year' in week['url']
+            assert 'month' in week['url']
+            assert 'week' in week['url']
+            if week['id'] == workout_start_id:
+                assert week['distance'] == 30
+                assert week['elevation'] == 540
+                assert week['time'] == '01'
+                assert week['workouts'] == 1
+            else:
+                assert week['distance'] == 0
+                assert week['elevation'] == 0
+                assert week['time'] == '00'
+                assert week['workouts'] == 0
Index: ow/utilities.py
===================================================================
--- ow/utilities.py	(revision 68d00f524e30821aa6f27e5b322ccec0563817ac)
+++ ow/utilities.py	(revision 24596dace05234b9fd49655a4798965c6bfed02c)
@@ -279,5 +279,4 @@
         if day.day in week:
             return weeks.index(week)
-    return None
 
 
Index: ow/views/user.py
===================================================================
--- ow/views/user.py	(revision 68d00f524e30821aa6f27e5b322ccec0563817ac)
+++ ow/views/user.py	(revision 24596dace05234b9fd49655a4798965c6bfed02c)
@@ -302,5 +302,5 @@
     user_gender = _('Unknown')
     for g in get_gender_names():
-        if g[0] == context.gender:
+        if g[0] == user.gender:
             user_gender = localizer.translate(g[1])
 
