Commit 31a39be9 authored by ibuler's avatar ibuler

Resolve conflicts

parents 2022ca8e 011c1255
...@@ -15,3 +15,4 @@ migrations/ ...@@ -15,3 +15,4 @@ migrations/
db.sqlite3 db.sqlite3
config.py config.py
*/migrations/* */migrations/*
*.log
...@@ -53,6 +53,7 @@ INSTALLED_APPS = [ ...@@ -53,6 +53,7 @@ INSTALLED_APPS = [
'audits.apps.AuditsConfig', 'audits.apps.AuditsConfig',
'common.apps.CommonConfig', 'common.apps.CommonConfig',
'rest_framework', 'rest_framework',
'rest_framework.authtoken',
'bootstrapform', 'bootstrapform',
# 'django.contrib.admin', # 'django.contrib.admin',
'django.contrib.auth', 'django.contrib.auth',
...@@ -247,6 +248,7 @@ REST_FRAMEWORK = { ...@@ -247,6 +248,7 @@ REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': ( 'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework.authentication.BasicAuthentication', 'rest_framework.authentication.BasicAuthentication',
'rest_framework.authentication.SessionAuthentication', 'rest_framework.authentication.SessionAuthentication',
'rest_framework.authentication.TokenAuthentication',
), ),
} }
# This setting is required to override the Django's main loop, when running in # This setting is required to override the Django's main loop, when running in
......
...@@ -7,7 +7,7 @@ from rest_framework import generics, mixins, status, permissions ...@@ -7,7 +7,7 @@ from rest_framework import generics, mixins, status, permissions
from rest_framework.views import APIView from rest_framework.views import APIView
from rest_framework.response import Response from rest_framework.response import Response
from .serializers import UserSerializer, UserGroupSerializer from .serializers import UserSerializer, UserGroupSerializer, UserActiveSerializer
from .models import User, UserGroup from .models import User, UserGroup
...@@ -18,20 +18,11 @@ class UserListAddApi(generics.ListCreateAPIView): ...@@ -18,20 +18,11 @@ class UserListAddApi(generics.ListCreateAPIView):
queryset = User.objects.all() queryset = User.objects.all()
serializer_class = UserSerializer serializer_class = UserSerializer
# permission_classes = (
# permissions.DenyAll,
# )
class UserDetailDeleteUpdateApi(generics.RetrieveUpdateDestroyAPIView): class UserDetailDeleteUpdateApi(generics.RetrieveUpdateDestroyAPIView):
queryset = User.objects.all() queryset = User.objects.all()
serializer_class = UserSerializer serializer_class = UserSerializer
def put(self, request, *args, **kwargs):
for k, v in request.META.items():
logger.debug("%s --> %s" % (k, v))
return super(UserDetailDeleteUpdateApi, self).put(request, *args, **kwargs)
def delete(self, request, *args, **kwargs): def delete(self, request, *args, **kwargs):
print(self.request.data) print(self.request.data)
return super(UserDetailDeleteUpdateApi, self).delete(request, *args, **kwargs) return super(UserDetailDeleteUpdateApi, self).delete(request, *args, **kwargs)
...@@ -42,6 +33,16 @@ class UserDetailDeleteUpdateApi(generics.RetrieveUpdateDestroyAPIView): ...@@ -42,6 +33,16 @@ class UserDetailDeleteUpdateApi(generics.RetrieveUpdateDestroyAPIView):
# return super(UserDetailDeleteUpdateApi, self).get(request, *args, **kwargs) # return super(UserDetailDeleteUpdateApi, self).get(request, *args, **kwargs)
class UserActiveApi(generics.RetrieveUpdateDestroyAPIView):
queryset = User.objects.all()
serializer_class = UserActiveSerializer
# def put(self, request, *args, **kwargs):
# for k, v in request.META.items():
# logger.debug("%s --> %s" % (k, v))
# return super(UserActiveApi, self).put(request, *args, **kwargs)
class UserGroupListAddApi(generics.ListCreateAPIView): class UserGroupListAddApi(generics.ListCreateAPIView):
queryset = UserGroup.objects.all() queryset = UserGroup.objects.all()
serializer_class = UserGroupSerializer serializer_class = UserGroupSerializer
......
...@@ -17,6 +17,12 @@ class UserSerializer(serializers.ModelSerializer): ...@@ -17,6 +17,12 @@ class UserSerializer(serializers.ModelSerializer):
] ]
class UserActiveSerializer(serializers.ModelSerializer):
class Meta:
model = User
fields = ['is_active']
class UserGroupSerializer(serializers.ModelSerializer): class UserGroupSerializer(serializers.ModelSerializer):
users = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='users:user-detail-api') users = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='users:user-detail-api')
......
...@@ -231,12 +231,9 @@ ...@@ -231,12 +231,9 @@
var status = $(obj).prop('checked'); var status = $(obj).prop('checked');
$.ajax({ $.ajax({
url: "{% url 'users:user-detail-api' pk=user.id %}", url: "{% url 'users:user-active-api' pk=user.id %}",
{# url: "{% url 'users:login' %}",#}
type: "PUT", type: "PUT",
data: { data: {
'username': "{{ user.username }}",
'email': "{{ user.email }}",
'is_active': status 'is_active': status
}, },
success: function (data, status) { success: function (data, status) {
......
...@@ -22,8 +22,9 @@ urlpatterns = [ ...@@ -22,8 +22,9 @@ urlpatterns = [
urlpatterns += [ urlpatterns += [
url(r'^v1/users/$', api.UserListAddApi.as_view(), name='user-list-api'), url(r'^v1/users$', api.UserListAddApi.as_view(), name='user-list-api'),
url(r'^v1/users/(?P<pk>[0-9]+)/$', api.UserDetailDeleteUpdateApi.as_view(), name='user-detail-api'), url(r'^v1/users/(?P<pk>[0-9]+)$', api.UserDetailDeleteUpdateApi.as_view(), name='user-detail-api'),
url(r'^v1/usergroups/$', api.UserGroupListAddApi.as_view(), name='usergroup-list-api'), url(r'^v1/users/(?P<pk>[0-9]+)/active$', api.UserActiveApi.as_view(), name='user-active-api'),
url(r'^v1/usergroups/(?P<pk>[0-9]+)/$', api.UserGroupDetailDeleteUpdateApi.as_view(), name='usergroup-detail-api'), url(r'^v1/usergroups$', api.UserGroupListAddApi.as_view(), name='usergroup-list-api'),
url(r'^v1/usergroups/(?P<pk>[0-9]+)$', api.UserGroupDetailDeleteUpdateApi.as_view(), name='usergroup-detail-api'),
] ]
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment