-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
user type and id stored in localstorage
- Loading branch information
mattfreire
committed
Dec 11, 2018
1 parent
272f61a
commit 174ae28
Showing
11 changed files
with
107 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import React from "react"; | ||
import { connect } from "react-redux"; | ||
|
||
class Profile extends React.PureComponent { | ||
render() { | ||
return <div>Hi {this.props.username}</div>; | ||
} | ||
} | ||
|
||
const mapStateToProps = state => { | ||
return { | ||
token: state.auth.token, | ||
username: state.auth.username | ||
}; | ||
}; | ||
|
||
const mapDispatchToProps = dispatch => { | ||
return { | ||
// | ||
}; | ||
}; | ||
|
||
export default connect(mapStateToProps)(Profile); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,31 @@ | ||
from django.contrib import admin | ||
from django.contrib.auth.admin import UserAdmin as BaseUserAdmin | ||
from django.contrib.auth.models import Group | ||
|
||
from .models import User | ||
|
||
admin.site.register(User) | ||
|
||
class UserAdmin(BaseUserAdmin): | ||
add_fieldsets = ( | ||
(None, { | ||
'fields': ('email', 'username', 'is_student', 'is_teacher', 'password1', 'password2') | ||
}), | ||
('Permissions', { | ||
'fields': ('is_superuser', 'is_staff') | ||
}) | ||
) | ||
fieldsets = ( | ||
(None, { | ||
'fields': ('email', 'username', 'is_student', 'is_teacher', 'password') | ||
}), | ||
('Permissions', { | ||
'fields': ('is_superuser', 'is_staff') | ||
}) | ||
) | ||
list_display = ['email', 'username', 'is_student', 'is_teacher'] | ||
search_fields = ('email', 'username') | ||
ordering = ('email',) | ||
|
||
|
||
admin.site.register(User, UserAdmin) | ||
admin.site.unregister(Group) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from rest_framework.routers import DefaultRouter | ||
from .views import UserViewSet | ||
|
||
router = DefaultRouter() | ||
router.register(r'', UserViewSet, base_name='users') | ||
urlpatterns = router.urls |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,10 @@ | ||
from rest_framework import viewsets | ||
from django.shortcuts import render | ||
|
||
# Create your views here. | ||
from .models import User | ||
from .serializers import UserSerializer | ||
|
||
|
||
class UserViewSet(viewsets.ModelViewSet): | ||
serializer_class = UserSerializer | ||
queryset = User.objects.all() |