Commit 101f3bf2aaeb25083ac9c9dab127859e9d41bc8e
1 parent
b0f214b3
Exists in
master
and in
3 other branches
fixed api which was broken when we removed core app from project, serializers fo…
…r log and users are now working
Showing
13 changed files
with
70 additions
and
3 deletions
Show diff stats
amadeus/settings.py
@@ -75,6 +75,7 @@ INSTALLED_APPS = [ | @@ -75,6 +75,7 @@ INSTALLED_APPS = [ | ||
75 | 'mailsender', | 75 | 'mailsender', |
76 | 'security', | 76 | 'security', |
77 | 'themes', | 77 | 'themes', |
78 | + 'api', | ||
78 | 79 | ||
79 | ] | 80 | ] |
80 | 81 | ||
@@ -289,6 +290,21 @@ S3DIRECT_DESTINATIONS = { | @@ -289,6 +290,21 @@ S3DIRECT_DESTINATIONS = { | ||
289 | 290 | ||
290 | } | 291 | } |
291 | 292 | ||
293 | +#API CONFIG STARTS | ||
294 | +#TELL the rest framework to use a different backend | ||
295 | +REST_FRAMEWORK = { | ||
296 | + 'DEFAULT_AUTHENTICATION_CLASSES':( | ||
297 | + 'oauth2_provider.ext.rest_framework.OAuth2Authentication',), | ||
298 | + 'DEFAULT_PERMISSION_CLASSES':( | ||
299 | + 'rest_framework.permissions.IsAuthenticated',), | ||
300 | + 'PAGE_SIZE': 10, #pagination purposes | ||
301 | +} | ||
302 | + | ||
303 | +OAUTH2_PROVIDER = { | ||
304 | + 'SCOPES':{'read':'Read scope', 'write': 'Write scope'} | ||
305 | +} | ||
306 | +#API CONFIG ENDS | ||
307 | + | ||
292 | # FILE UPLOAD | 308 | # FILE UPLOAD |
293 | MAX_UPLOAD_SIZE = 10485760 | 309 | MAX_UPLOAD_SIZE = 10485760 |
294 | 310 |
amadeus/urls.py
@@ -25,6 +25,7 @@ urlpatterns = [ | @@ -25,6 +25,7 @@ urlpatterns = [ | ||
25 | url(r'^users/', include('users.urls', namespace = 'users')), | 25 | url(r'^users/', include('users.urls', namespace = 'users')), |
26 | url(r'^admin/', admin.site.urls), | 26 | url(r'^admin/', admin.site.urls), |
27 | url(r'^$', index, name = 'home'), | 27 | url(r'^$', index, name = 'home'), |
28 | + url(r'api/', include('api.urls', namespace = 'api')), | ||
28 | url(r'^categories/', include('categories.urls', namespace = 'categories')), | 29 | url(r'^categories/', include('categories.urls', namespace = 'categories')), |
29 | url(r'^subjects/', include('subjects.urls', namespace = 'subjects')), | 30 | url(r'^subjects/', include('subjects.urls', namespace = 'subjects')), |
30 | url(r'^groups/', include('students_group.urls', namespace = 'groups')), | 31 | url(r'^groups/', include('students_group.urls', namespace = 'groups')), |
@@ -0,0 +1,17 @@ | @@ -0,0 +1,17 @@ | ||
1 | +from django.conf.urls import url, include | ||
2 | + | ||
3 | +# ========== API IMPORTS ============= # | ||
4 | + | ||
5 | +from rest_framework import routers | ||
6 | + | ||
7 | +from users.views import UserViewSet | ||
8 | +from log.views import LogViewSet | ||
9 | + | ||
10 | +router = routers.DefaultRouter() | ||
11 | +router.register(r'logs', LogViewSet) | ||
12 | +router.register(r'usersapi', UserViewSet) | ||
13 | + | ||
14 | +urlpatterns = [ | ||
15 | + #API REST | ||
16 | + url(r'^', include(router.urls)), | ||
17 | +] | ||
0 | \ No newline at end of file | 18 | \ No newline at end of file |
log/views.py
1 | from django.shortcuts import render | 1 | from django.shortcuts import render |
2 | - | 2 | +#API IMPORTS |
3 | +from rest_framework import viewsets | ||
4 | +from .serializers import LogSerializer | ||
5 | +from rest_framework.permissions import IsAuthenticated, IsAuthenticatedOrReadOnly | ||
6 | +from .models import Log | ||
3 | # Create your views here. | 7 | # Create your views here. |
8 | + | ||
9 | +#REST API VIEWS | ||
10 | +class LogViewSet(viewsets.ModelViewSet): | ||
11 | + permission_classes = [IsAuthenticated] | ||
12 | + queryset = Log.objects.all() | ||
13 | + serializer_class = LogSerializer | ||
4 | \ No newline at end of file | 14 | \ No newline at end of file |
users/serializers.py
@@ -4,6 +4,5 @@ from .models import User | @@ -4,6 +4,5 @@ from .models import User | ||
4 | class UserSerializer(serializers.ModelSerializer): | 4 | class UserSerializer(serializers.ModelSerializer): |
5 | class Meta: | 5 | class Meta: |
6 | model = User | 6 | model = User |
7 | - fields = ('username','email','name','city','state','gender','image','birth_date','phone', | ||
8 | - 'cpf','type_profile','titration','year_titration','institution','curriculum','date_created', | 7 | + fields = ('username','email','image','last_update','date_created','last_name','social_name', |
9 | 'is_staff','is_active') | 8 | 'is_staff','is_active') |