Ejemplo n.º 1
0
    def test_multiple_features_on_single_user_returns_only_closest_feature(
            self):
        subject = 's1'
        faces = self.faces[subject]
        user = User.objects.create(username=subject)
        user.save()

        for face in faces:
            with open(face, 'rb') as data:
                request = self.factory.post(
                    '/api/v1/users/%d' % user.id, {'faces': data},
                    format='multipart',
                    HTTP_AUTHORIZATION='Token {}'.format(self.token))
                view = UserViewSet.as_view({'post': 'enroll'})
                response = view(request, pk=user.id)
                self.assertEqual(response.status_code, 200)

            with open(face, 'rb') as data:
                request = self.factory.post(
                    '/api/v1/users', {'faces': data},
                    format='multipart',
                    HTTP_AUTHORIZATION='Token {}'.format(self.token))
                view = UserViewSet.as_view({'post': 'recognize'})
                response = view(request)
                self.assertEqual(response.status_code, 200)
                self.assertEqual(len(response.data), 1)
Ejemplo n.º 2
0
 def test_unauthenticated_get_user_should_fail(self):
     request = self.factory.get('/api/v1/users',
                                HTTP_AUTHORIZATION='Token {}'.format(
                                    self.bad_token))
     view = UserViewSet.as_view({'get': 'list'})
     response = view(request)
     self.assertEqual(response.status_code, 401)
Ejemplo n.º 3
0
 def test_user_exists(self):
     request = self.factory.get('/api/v1/users/1',
                                HTTP_AUTHORIZATION='Token {}'.format(
                                    self.token))
     view = UserViewSet.as_view({'get': 'retrieve'})
     response = view(request, pk=1)
     self.assertEqual(response.data['username'], 'Markku')
Ejemplo n.º 4
0
    def test_delete_user_unauthorized(self):
        username = '******'
        # Let's make sure the user exist on the database first
        self.assertTrue(User.objects.filter(username=username).exists())

        # Delete the user as a user manager
        user_id = User.objects.get(username=username).id
        factory = APIRequestFactory()
        view = UserViewSet.as_view(actions={'delete': 'destroy'})
        request = factory.delete(reverse('user-detail', kwargs={'pk':
                                                                user_id}))

        # Test the request with the usermanager
        force_authenticate(request, user=self.get_usermanager())
        response = view(request, pk=user_id)

        # Make sure the user is still in the database
        self.assertTrue(User.objects.filter(username=username).exists())
        # Forbidden should be returned
        self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)

        # Test the request with the regular user
        force_authenticate(request, user=self.get_regularuser())
        response = view(request, pk=user_id)

        # Make sure the user is still in the database
        self.assertTrue(User.objects.filter(username=username).exists())
        # Not found, these users have no access to this API
        self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)
Ejemplo n.º 5
0
 def test_create_new_user(self):
     """
     Try cretaing a new user, then try loggin in as them
     """
     sample.sample_data_one_user()
     school_id = School.objects.get().id
     view = UserViewSet.as_view(actions={'post': 'create'})
     email = '*****@*****.**'
     password = '******'
     # form data to submit
     data = {
         'email': email,
         'password': password,
         'school': school_id,
         'first_name': 'first',
         'last_name': 'last',
         'color_pref': 'green'
     }
     request = self.factory.post('/user/', data)
     response = view(request)
     self.assertEqual(response.status_code, 201,
                      "Did not get a 201 HTTP response.")
     # make sure user can login
     out = self.authenticate(email, password)
     self.assertTrue('token' in out.keys())
Ejemplo n.º 6
0
 def test_change_password(self):
     """
     try to change the password for a user
     """
     email = '*****@*****.**'
     old_pass = '******'
     new_pass = '******'
     # sample data
     sample.sample_data_one_user()
     # check the original login
     out = self.authenticate(email, old_pass)
     self.assertTrue('token' in out)
     # change the password
     view = UserViewSet.as_view(actions={'put': 'change_password'})
     data = {
         'email': email,
         'old_password': old_pass,
         'new_password': new_pass
     }
     request = self.factory.put('/user/change_password/', data)
     response = view(request)
     # Check the response
     self.assertEqual(response.status_code, 201,
                      "Did not get a 201 HTTP response.")
     response.render()
     out = self.authenticate(email, new_pass)
     # check authenticated
     self.assertTrue('token' in out)
Ejemplo n.º 7
0
 def test_unauthenticated_recognize_user_should_fail(self):
     with open(self.faces['s1'][0], 'rb') as data:
         request = self.factory.post('/api/v1/users', {'faces': data},
                                     format='multipart',
                                     HTTP_AUTHORIZATION='Token {}'.format(
                                         self.bad_token))
         view = UserViewSet.as_view({'post': 'recognize'})
         response = view(request, pk=1)
         self.assertEqual(response.status_code, 401)
Ejemplo n.º 8
0
 def test_current(self):
     """Test the current API endpoint."""
     url = reverse('users-current')
     factory = APIRequestFactory()
     request = factory.get(url, content_type='application/json')
     force_authenticate(request, user=self.user)
     user_current = UserViewSet.as_view({'get': 'current'})
     response = user_current(request)
     self.assertEqual(response.status_code, status.HTTP_200_OK)
Ejemplo n.º 9
0
 def test_put_last_and_first_name(self):
     request = self.factory.put('/api/v1/users/1', {
         'first_name': 'Markku',
         'last_name': 'Virtanen'
     },
                                format='multipart',
                                HTTP_AUTHORIZATION='Token {}'.format(
                                    self.token))
     view = UserViewSet.as_view({'put': 'partial_update'})
     response = view(request, pk=1)
     self.assertEqual(response.status_code, 200)
     self.assertEqual(User.objects.get(pk=1).first_name, 'Markku')
     self.assertEqual(User.objects.get(pk=1).last_name, 'Virtanen')
Ejemplo n.º 10
0
 def test_encode_token_empty(self):
     """
     encode then decode an empty token
     """
     view = UserViewSet.as_view(actions={'post': 'encode_token'})
     to_encode = {}
     request = self.factory.post('/user/encode_token/', to_encode)
     response = view(request)
     self.assertEqual(response.status_code, 200,
                      "Did not get a 200 HTTP response.")
     response.render()
     data = json.loads(response.content.decode('utf-8'))
     # make sure token is in response, then decode
     self.assertTrue('token' in data)
     view = UserViewSet.as_view(actions={'post': 'decode_token'})
     request = self.factory.post('/user/decode_token/', data)
     response = view(request)
     # Check the response
     self.assertEqual(response.status_code, 200,
                      "Did not get a 200 HTTP response.")
     response.render()
     data = json.loads(response.content.decode('utf-8'))
     self.assertEqual(data, to_encode)
Ejemplo n.º 11
0
 def test_decode_token_bad(self):
     """
     try to token an invalid token, check that response is error
     """
     view = UserViewSet.as_view(actions={'post': 'decode_token'})
     data = {'token': 'bad_token_data'}
     request = self.factory.post('/user/decode_token/', data)
     response = view(request)
     self.assertEqual(response.status_code, 200,
                      "Did not get a 200 HTTP response.")
     response.render()
     data = json.loads(response.content.decode('utf-8'))
     # should get error
     self.assertTrue('error_msg' in data)
Ejemplo n.º 12
0
 def try_ac(self, user, ac):
     """
     Helper function to try having user use ac as an access code
     :param user: logged in user
     :param ac: access code they try
     :return: response of post
     """
     data = {'access_code': ac}
     view = UserViewSet.as_view(actions={'post': 'join_course'})
     request = self.factory.post('/course/' + str(user.id) + '/join_course/', data)
     response = view(request, pk=user.id)
     self.assertEqual(response.status_code, 200, "Did not get a 200 HTTP response.")
     # Check the response
     response.render()
     return json.loads(response.content.decode('utf-8'))
Ejemplo n.º 13
0
 def test_get_assignments_due_week_none(self):
     """
     Create sample data with a user with no assignments due in a week
     """
     sample.sample_data_few()
     me = User.objects.get(email="*****@*****.**")
     view = UserViewSet.as_view(actions={'get': 'assignments_due_week'})
     request = self.factory.get('/user/' + str(me.id) + '/assignments_due_week/')
     response = view(request, pk=me.id)
     self.assertEqual(response.status_code, 200, "Did not get a 200 HTTP response.")
     response.render()
     satisfying_assignments = json.loads(response.content.decode('utf-8'))
     # No assignments should be returned
     self.assertEqual(len(satisfying_assignments), 0, "Should not have received an assignment back for u3 "
                                                      "(they are only an instructor).")
Ejemplo n.º 14
0
 def setUp(self):
     self.factory = APIRequestFactory()
     self.faker = Faker()
     self.user = User.objects.create_user(email=self.faker.email(),
                                          username=self.faker.name(),
                                          password=self.faker.password(),
                                          is_staff=True)
     self.factory = APIRequestFactory()
     self.view = UserViewSet.as_view({
         'get': 'list',
         'post': 'create',
         'patch': 'partial_update',
         'delete': 'destroy'
     })
     self.uri = '/users/'
Ejemplo n.º 15
0
 def test_encode_token(self):
     """
     encode then decode an arbitrary token
     """
     # encode some sample data
     view = UserViewSet.as_view(actions={'post': 'encode_token'})
     to_encode = {'test_data': 'test_value'}
     request = self.factory.post('/user/encode_token/', to_encode)
     response = view(request)
     self.assertEqual(response.status_code, 200,
                      "Did not get a 200 HTTP response.")
     response.render()
     data = json.loads(response.content.decode('utf-8'))
     # make sure token is in response, then decode
     self.assertTrue('token' in data)
     view = UserViewSet.as_view(actions={'post': 'decode_token'})
     request = self.factory.post('/user/decode_token/', data)
     response = view(request)
     self.assertEqual(response.status_code, 200,
                      "Did not get a 200 HTTP response.")
     response.render()
     data = json.loads(response.content.decode('utf-8'))
     # data should be equal
     self.assertEqual(data, to_encode)
Ejemplo n.º 16
0
    def test_create_user(self):
        factory = APIRequestFactory()
        view = UserViewSet.as_view(actions={'post': 'create'})
        request = factory.post(reverse('user-list'),
                               data={
                                   'username': '******',
                                   'password': '******',
                                   'email': '*****@*****.**',
                                   'first_name': 'user',
                                   'last_name': 'last'
                               },
                               format='json')

        response = view(request)

        self.assertEqual(response.status_code, status.HTTP_201_CREATED)
Ejemplo n.º 17
0
 def test_authenticate_decode(self):
     """
     authenticate a user, then try to decode the token response
     """
     sample.sample_data_one_user()
     out = self.authenticate('*****@*****.**', 'hello!')
     self.assertTrue('token' in out)
     view = UserViewSet.as_view(actions={'post': 'decode_token'})
     request = self.factory.post('/user/decode_token/', out)
     response = view(request)
     self.assertEqual(response.status_code, 200,
                      "Did not get a 200 HTTP response.")
     response.render()
     data = json.loads(response.content.decode('utf-8'))
     # should not get error
     self.assertTrue('error_msg' not in data)
Ejemplo n.º 18
0
 def test_get_assignments_due_week(self):
     """
     Create sample data with a few assignments, with hw1 due in a day. Check that it is the only assignment
     due in a week
     """
     sample.sample_data_one_course()
     me = User.objects.get(email="*****@*****.**")
     view = UserViewSet.as_view(actions={'get': 'assignments_due_week'})
     request = self.factory.get('/user/' + str(me.id) + '/assignments_due_week/')
     response = view(request, pk=me.id)
     self.assertEqual(response.status_code, 200, "Did not get a 200 HTTP response.")
     response.render()
     satisfying_assignments = json.loads(response.content.decode('utf-8'))
     # check 1 assignment is returned, and it's hw1.
     self.assertEqual(len(satisfying_assignments), 1, "Did not receive exactly one assignment back.")
     self.assertEqual(satisfying_assignments[0]['name'], "hw1", "Incorrect assignment returned.")
Ejemplo n.º 19
0
 def authenticate(self, email, password):
     """
     Helper function to login a user
     :param email: email of user
     :param password: password of user
     :return: Response of authenticate post
     """
     view = UserViewSet.as_view(actions={'post': 'authenticate'})
     request = self.factory.post('/user/authenticate/', {
         'email': email,
         'password': password
     })
     response = view(request)
     self.assertEqual(response.status_code, 200,
                      "Did not get a 200 HTTP response.")
     response.render()
     return json.loads(response.content.decode('utf-8'))
Ejemplo n.º 20
0
    def test_delete_user(self):
        username = '******'
        # Let's make sure the user exist on the database first
        self.assertTrue(User.objects.filter(username=username).exists())

        # Delete the user as a user manager
        user_id = User.objects.get(username=username).id
        factory = APIRequestFactory()
        view = UserViewSet.as_view(actions={'delete': 'destroy'})
        request = factory.delete(reverse('user-detail', kwargs={'pk':
                                                                user_id}))

        # Test the request with the admin
        force_authenticate(request, user=self.get_usermanager())
        response = view(request, pk=user_id)

        # Confirm the deletion of that user
        self.assertFalse(User.objects.filter(username=username).exists())
        self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)
Ejemplo n.º 21
0
 def test_get_course_instructor(self):
     """
     Check get_course for a user that is an instructor
     """
     sample.sample_data_few()
     user = User.objects.get(email="*****@*****.**")
     view = UserViewSet.as_view(actions={'get': 'get_course'})
     request = self.factory.get('/user/' + str(user.id) + '/get_course/')
     response = view(request, pk=user.id)
     self.assertEqual(response.status_code, 200, "Did not get a 200 HTTP response.")
     response.render()
     courses = json.loads(response.content.decode('utf-8'))
     # shoulld only be an instructor of two courses
     self.assertEqual(len(courses['student']), 0, "User should not be a student.")
     self.assertEqual(len(courses['ta']), 0, "User should not be a ta.")
     self.assertEqual(len(courses['instructor']), 2, "User should be an instructor for 2 courses.")
     self.assertTrue(courses['instructor'][0]['name'] == 'c23' or courses['instructor'][1]['name'] == 'c23',
                     "User u3 not in course c23.")
     self.assertTrue(courses['instructor'][0]['name'] == 'c3' or courses['instructor'][1]['name'] == 'c3',
                     "User u3 not in course c3.")
Ejemplo n.º 22
0
    def test_update_user(self):
        user_id = User.objects.get(username='******').id
        factory = APIRequestFactory()
        view = UserViewSet.as_view(actions={'put': 'update'})
        request = factory.put(reverse('user-detail', kwargs={'pk': user_id}),
                              data={
                                  'username': '******',
                                  'password': '******',
                                  'email': '*****@*****.**',
                                  'first_name': 'user',
                                  'last_name': 'last'
                              })

        # Test the request with the admin
        force_authenticate(request, user=self.get_admin())
        response = view(request, pk=user_id)

        self.assertEqual(
            User.objects.get(id=user_id).email, '*****@*****.**')
        self.assertEqual(response.status_code, status.HTTP_200_OK)
Ejemplo n.º 23
0
 def test_get_course_student_multiple(self):
     """
     Check getting the coruses for a user in multiple courses
     """
     sample.sample_data_few()
     user = User.objects.get(email="*****@*****.**")
     view = UserViewSet.as_view(actions={'get': 'get_course'})
     request = self.factory.get('/user/' + str(user.id) + '/get_course/')
     response = view(request, pk=user.id)
     self.assertEqual(response.status_code, 200, "Did not get a 200 HTTP response.")
     response.render()
     courses = json.loads(response.content.decode('utf-8'))
     # check two courses back, 'c2' and 'c23'
     self.assertEqual(len(courses['student']), 2, "User should be a student in 2 classes.")
     self.assertTrue(courses['student'][0]['name'] == 'c2' or courses['student'][1]['name'] == 'c2',
                     "User u2 not in course c2.")
     self.assertTrue(courses['student'][0]['name'] == 'c23' or courses['student'][1]['name'] == 'c23',
                     "User u2 not in course c23.")
     self.assertEqual(len(courses['ta']), 0, "User should not be a TA.")
     self.assertEqual(len(courses['instructor']), 0, "User should not be an Instructor.")
Ejemplo n.º 24
0
    def test_get_all_users(self):
        factory = APIRequestFactory()
        view = UserViewSet.as_view(actions={'get': 'list'})
        request = factory.get(reverse('user-list'))

        users = User.objects.all()
        serializer = serializers.UserAdminSerializer(users, many=True)

        # Test the request with the admin
        force_authenticate(request, user=self.get_admin())
        response = view(request)

        self.assertEqual(response.data, serializer.data)
        self.assertEqual(response.status_code, status.HTTP_200_OK)

        # Test the request with the user manager
        force_authenticate(request, user=self.get_usermanager())
        response = view(request)

        self.assertEqual(response.data, serializer.data)
        self.assertEqual(response.status_code, status.HTTP_200_OK)
Ejemplo n.º 25
0
 def test_create_new_user_invalid(self):
     """
     Create a new user with a name too long, check that 400 is returned
     """
     sample.sample_data_one_user()
     school_id = School.objects.get().id
     view = UserViewSet.as_view(actions={'post': 'create'})
     email = '*****@*****.**'
     password = '******'
     data = {
         'email': email,
         'password': password,
         'school': school_id,
         'first_name': 'too long' * 100,
         'last_name': 'last',
         'color_pref': 'green'
     }
     request = self.factory.post('/user/', data)
     response = view(request)
     # Check 400 response
     self.assertEqual(response.status_code, 400,
                      "Should get invalid response")
Ejemplo n.º 26
0
from django.conf.urls import url

from api.views import ProviderViewSet, ServiceAreaViewSet, UserViewSet

user_list = UserViewSet.as_view({
    'get': 'list',
    'post': 'create'
})

user_detail = UserViewSet.as_view({
    'get': 'retrieve',
    'put': 'update',
    'patch': 'partial_update',
    'delete': 'destroy'
})

provider_list = ProviderViewSet.as_view({
    'get': 'list',
    'post': 'create'
})

provider_detail = ProviderViewSet.as_view({
    'get': 'retrieve',
    'put': 'update',
    'patch': 'partial_update',
    'delete': 'destroy'
})

service_area_list = ServiceAreaViewSet.as_view({
    'get': 'list',
    'post': 'create'
from api.views import PictureViewSet, UserViewSet, api_root, AlbumViewSet
from rest_framework import renderers

album_list = AlbumViewSet.as_view({'get': 'list', 'post': 'create'})
album_detail = AlbumViewSet.as_view({
    'get': 'retrieve',
    'put': 'update',
    'patch': 'partial_update',
    'delete': 'destroy'
})
photo_list = PictureViewSet.as_view({'get': 'list', 'post': 'create'})
photo_detail = PictureViewSet.as_view({
    'get': 'retrieve',
    'put': 'update',
    'patch': 'partial_update',
    'delete': 'destroy'
})
user_list = UserViewSet.as_view({'get': 'list'})
user_detail = UserViewSet.as_view({'get': 'retrieve'})

urlpatterns = [
    path('', api_root),
    path('albums/', album_list, name='album-list'),
    path('albums/<int:pk>/', album_detail, name='album-detail'),
    path('photos/', photo_list, name='photo-list'),
    path('photos/<int:pk>/', photo_detail, name='photo-detail'),
    path('users/', user_list, name='user-list'),
    path('users/<int:pk>/', user_detail, name='user-detail'),
]

urlpatterns = format_suffix_patterns(urlpatterns)
Ejemplo n.º 28
0
from django.conf.urls import url
from rest_framework.urlpatterns import format_suffix_patterns
from api.views import UserViewSet, api_root
from api.views import JamEventViewSet, VehicleCountEventViewSet
from api.views import AbandomEventViewSet, IllegalParkEventViewSet

user_list = UserViewSet.as_view({
    'get': 'list'
})
user_detail = UserViewSet.as_view({
    'get': 'retrieve'
})

jamevent_list = JamEventViewSet.as_view({
    'get': 'list',
    'post': 'create'
})

jamevent_detail = JamEventViewSet.as_view({
    'get': 'retrieve',
    'put': 'update',
    'patch': 'partial_update',
    'delete': 'destroy'
})

vehiclecountevent_list = VehicleCountEventViewSet.as_view({
    'get': 'list',
    'post': 'create'
})

vehiclecountevent_detail = VehicleCountEventViewSet.as_view({
Ejemplo n.º 29
0
 def test_user_list(self):
     view = UserViewSet.as_view({'get': 'list'})
     request = self.factory.get('/', **self.extra)
     response = view(request)
     data = [{'username': u'bob', 'first_name': u'Bob', 'last_name': u''}]
     self.assertContains(response, json.dumps(data))
Ejemplo n.º 30
0
 def test_user_get(self):
     view = UserViewSet.as_view({'get': 'retrieve'})
     request = self.factory.get('/', **self.extra)
     response = view(request, username='******')
     data = {'username': u'bob', 'first_name': u'Bob', 'last_name': u''}
     self.assertContains(response, json.dumps(data))
Ejemplo n.º 31
0
Archivo: urls.py Proyecto: bart3k1/CMS
from django.conf.urls import url
from django.contrib import admin
from api.views import UsersView, UserView, UserLoginView, GuestViewSet, UserViewSet

urlpatterns = [
    url(r'^users/$', UsersView.as_view(), name='users'),
    url(r'^userOLD/$', UserView.as_view(), name='user'),
    url(r'^login/(?P<pk>\d+)/$', UserLoginView.as_view(), name='login'),
    url(r'^guests/$',
        GuestViewSet.as_view({
            'get': 'list',
            'post': 'create'
        }),
        name='guests'),
    url(r'^user/$',
        UserViewSet.as_view({
            'get': 'list',
            'post': 'create'
        }),
        name='users'),
]
Ejemplo n.º 32
0
from django.conf.urls import url

from api.views import NotificationViewSet, UserViewSet


urlpatterns = [
    # Users
    url(r'^users/$', UserViewSet.as_view({'get': 'list'})),

    # Notifications
    url(r'^notifications/$', NotificationViewSet.as_view({'get': 'list', 'post': 'create'})),
    url(r'^notifications/(?P<pk>[\d]+)/$', NotificationViewSet.as_view({'get': 'retrieve', 'patch': 'partial_update', 'delete': 'destroy'})),
]
Ejemplo n.º 33
0
                       EducationalAPIView, EducationalUpdateAPIView, SkillsUpdateAPIView,
                       LoginView, LogoutView, PasswordResetView, IntrestUpdateAPIView,
                       WorkExperienceAPIView, WorkExperienceUpdateAPIView, IntrestAPIView, PosterAPIView,
                       SkillsAPIView, CertificationAPIView, PublicationAPIView, ArticleAPIView,
                       PatentAPIView, BookAPIView, ConferenceAPIView, AchievementAPIView,
                       ExtraCurricularAPIView, SocialMediaLinksAPIView, CertificationUpdateAPIView,
                       PublicationUpdateAPIView, PatentUpdateAPIView, ArticleUpdateAPIView,
                       BookUpdateAPIView, PosterUpdateAPIView, ConferenceUpdateAPIView, ExtraCurricularUpdateAPIView,
                       AchievemntUpdateAPIView, SocialMediaLinksUpdateAPIView)
from django.conf import settings
from django.conf.urls.static import static


urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^api/accounts/', UserViewSet.as_view(), name='register'),
    url(r'^accounts/login', LoginView.as_view(), name='login'),
    url(r'^accounts/logout', LogoutView.as_view(), name='logout'),
    url(r'^password_reset', PasswordResetView.as_view(), name='password_reset'),
    url(r'^create/$', UserInfoAPIView.as_view(), name='user_info'),
    url(r'^(?P<username>[\w.@+-]+)/create/$', UserUpdateViewSet.as_view(), name='user_info_edit'), #update
    url(r'^education/', EducationalAPIView.as_view(), name='education_info'),
    url(r'^(?P<username>[\w.@+-]+)/education/$', EducationalUpdateAPIView.as_view(), name='education_info_update'),#update
    url(r'^work/$', WorkExperienceAPIView.as_view(), name='work'),
    url(r'^(?P<username>[\w.@+-]+)/work/', WorkExperienceUpdateAPIView.as_view(), name='work_update'),
    url(r'^intrest/', IntrestAPIView.as_view(), name='intrest'),
    url(r'^(?P<username>[\w.@+-]+)/intrest/', IntrestUpdateAPIView.as_view(), name='intrest_update'),
    url(r'^skills/', SkillsAPIView.as_view(), name='skills'),
    url(r'^(?P<username>[\w.@+-]+)/skills/', SkillsUpdateAPIView.as_view(), name='skills_update'),
    url(r'^certification/', CertificationAPIView.as_view(), name='certification'),
    url(r'^(?P<username>[\w.@+-]+)/certification/', CertificationUpdateAPIView.as_view(), name='certification_update'),