Skip to content

Commit

Permalink
Merge branch 'develop' into 'master'
Browse files Browse the repository at this point in the history
  • Loading branch information
ajatprabha committed Oct 14, 2018
2 parents f1b51e3 + d71aa27 commit 00c1401
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 4 deletions.
10 changes: 10 additions & 0 deletions src/account/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,13 @@ class MentorProfileSerializer(serializers.ModelSerializer):
class Meta:
model = MentorProfile
fields = '__all__'


class MentorsListSerializer(serializers.ModelSerializer):
first_name = serializers.CharField(source='user.first_name')
last_name = serializers.CharField(source='user.last_name')
email = serializers.EmailField(source='user.email')

class Meta:
model = MentorProfile
fields = ('first_name', 'last_name', 'email', 'phone', 'about_me')
27 changes: 25 additions & 2 deletions src/account/api/views.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from rest_framework.viewsets import GenericViewSet
from rest_framework import mixins
from rest_framework.permissions import AllowAny
from rest_framework.permissions import AllowAny, IsAuthenticated
from rest_framework.decorators import action
from account.api.serializers import StudentProfileSerializer, MentorProfileSerializer, UserSerializer
from account.api.serializers import StudentProfileSerializer, MentorProfileSerializer
from account.api.serializers import UserSerializer, MentorsListSerializer
from account.models import StudentProfile, MentorProfile
from django.contrib.auth.models import User
from django.shortcuts import get_object_or_404
Expand Down Expand Up @@ -30,6 +31,28 @@ def get_object(self):
def current(self, request, *args, **kwargs):
return self.retrieve(request, args, kwargs)

# For listing all mentors that are verified

def get_queryset(self, queryset=None):
return self.queryset.filter(is_approved=True) if self.action == 'all' else super().get_queryset()

def get_serializer_class(self):
return MentorsListSerializer if self.action == 'all' else self.serializer_class

def get_permissions(self):
"""
Instantiates and returns the list of permissions that this view requires.
"""
if self.action == 'all':
permission_classes = [AllowAny]
else:
permission_classes = [IsAuthenticated]
return [permission() for permission in permission_classes]

@action(methods=['get'], detail=False)
def all(self, request, *args, **kwargs):
return self.list(request, args, kwargs)


class UserViewSet(mixins.UpdateModelMixin, mixins.RetrieveModelMixin, GenericViewSet):
serializer_class = UserSerializer
Expand Down
51 changes: 51 additions & 0 deletions ui/src/components/MentorDetails.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<template>
<div>
<v-layout justify-center><h1>Mentors</h1></v-layout>
<v-layout justify-center row wrap>
<v-flex xs12 md6 sm6 v-for="(mentor,i) in mentorList" :key="i" pt-2 pl-4 pr-4>
<v-card flat>
<v-layout justify-start row wrap>
<v-flex xs12 class="headline"><v-layout justify-center>{{ mentor.first_name }} {{ mentor.last_name }}</v-layout></v-flex>
</v-layout>
<v-layout justify-start row wrap>
<v-flex xs2 sm2 md2 pl-2><v-icon>fa-envelope</v-icon></v-flex><v-flex xs10 sm10 md10>
{{ mentor.email }}</v-flex>
</v-layout>
<v-layout justify-start row wrap>
<v-flex xs2 sm2 md2 pl-2><v-icon>fa-phone</v-icon></v-flex><v-flex xs10 sm10 md10 class="sub-heading">{{ mentor.phone }}</v-flex>
</v-layout>
<v-layout justify-start row wrap>
<v-flex xs2 sm2 md2 pl-2><v-icon medium>fa-info-circle</v-icon></v-flex><v-flex xs10 sm10 md10 class="sub-heading">{{ mentor.about_me }}</v-flex>
</v-layout>
</v-card>
</v-flex>
</v-layout>
</div>
</template>

<script>
export default {
name: 'MentorDetails',
data () {
return {
mentorList: [{
first_name: '',
last_name: '',
email: '',
phone: '',
about_me: ''
}]
}
},
methods: {
fetchMentorList () {
this.$httpClient.get('/api/account/mentor-profile/all/').then(response => {
this.mentorList = response.data
})
}
},
mounted () {
this.fetchMentorList()
}
}
</script>
6 changes: 4 additions & 2 deletions ui/src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import HowItWorks from '../components/HowItWorks'
import NotFound from '../components/NotFound'
import Help from '../components/Help'
import Dashboard from '../components/Dashboard'
import MentorDetails from '../components/MentorDetails'

Vue.use(Router)

Expand All @@ -19,9 +20,10 @@ const router = new Router({
{path: '/projects', name: 'Projects', component: ProjectsList},
{path: '/how-it-works', name: 'HowItWorks', component: HowItWorks},
{path: '/help', name: 'Help', component: Help},
{path: '/mentors', name: 'MentorDetails', component: MentorDetails},
{path: '/dashboard', name: 'Dashboard', component: Dashboard, meta: {requiresAuth: true}},
{ path: '/not-found', component: NotFound },
{ path: '*', redirect: '/not-found' }
{path: '/not-found', component: NotFound},
{path: '*', redirect: '/not-found'}
]
})

Expand Down
1 change: 1 addition & 0 deletions ui/src/store/modules/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const state = {
items: [
{icon: 'fa-home', text: 'Home', path: '/'},
{icon: 'fa-calendar', text: 'How It Works', path: '/how-it-works'},
{icon: 'supervisor_account', text: 'Mentors', path: '/mentors'},
{icon: 'fa-code', text: 'Projects', path: '/projects'},
{icon: 'fa-tachometer', text: 'Dashboard', path: '/dashboard', requiresAuth: true},
{icon: 'help', text: 'Help', path: '/help'}
Expand Down

0 comments on commit 00c1401

Please sign in to comment.