From b109fd11339a6b547c757797a3f3dc763294b13e Mon Sep 17 00:00:00 2001 From: ajatprabha Date: Sun, 14 Oct 2018 20:32:12 +0530 Subject: [PATCH] update MentorList.vue --- src/account/api/views.py | 20 ++---- ui/src/components/GAvatar.vue | 4 +- ui/src/components/MentorDetails.vue | 51 -------------- ui/src/components/MentorList.vue | 102 ++++++++++++++++++++++++++++ ui/src/router/index.js | 4 +- 5 files changed, 112 insertions(+), 69 deletions(-) delete mode 100644 ui/src/components/MentorDetails.vue create mode 100644 ui/src/components/MentorList.vue diff --git a/src/account/api/views.py b/src/account/api/views.py index df4e4b6..2f4bdcc 100644 --- a/src/account/api/views.py +++ b/src/account/api/views.py @@ -27,12 +27,6 @@ def get_object(self): return get_object_or_404(MentorProfile, user=self.request.user) if self.action == 'current' else super().get_object() - @action(methods=['get'], detail=False) - 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() @@ -40,14 +34,12 @@ 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] + self.permission_classes = [AllowAny] if self.action == 'all' else self.permission_classes + return super().get_permissions() + + @action(methods=['get'], detail=False) + def current(self, request, *args, **kwargs): + return self.retrieve(request, args, kwargs) @action(methods=['get'], detail=False) def all(self, request, *args, **kwargs): diff --git a/ui/src/components/GAvatar.vue b/ui/src/components/GAvatar.vue index e30f0da..56074cd 100644 --- a/ui/src/components/GAvatar.vue +++ b/ui/src/components/GAvatar.vue @@ -8,13 +8,13 @@ export default { name: 'GAvatar', - props: ['email'], + props: ['email', 'size'], data: () => ({link: avatarPlaceholder}), methods: { setLink () { if (this.email) { axios.get(`https://picasaweb.google.com/data/entry/api/user/${this.email}?alt=json`).then(response => { - this.link = response.data.entry.gphoto$thumbnail.$t + this.link = response.data.entry.gphoto$thumbnail.$t + (this.size ? `?sz=${this.size}` : '') }) } } diff --git a/ui/src/components/MentorDetails.vue b/ui/src/components/MentorDetails.vue deleted file mode 100644 index bfcc6b8..0000000 --- a/ui/src/components/MentorDetails.vue +++ /dev/null @@ -1,51 +0,0 @@ - - - diff --git a/ui/src/components/MentorList.vue b/ui/src/components/MentorList.vue new file mode 100644 index 0000000..9dda897 --- /dev/null +++ b/ui/src/components/MentorList.vue @@ -0,0 +1,102 @@ + + + + + diff --git a/ui/src/router/index.js b/ui/src/router/index.js index 8165953..ed7582a 100644 --- a/ui/src/router/index.js +++ b/ui/src/router/index.js @@ -8,7 +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' +import MentorList from '../components/MentorList' Vue.use(Router) @@ -20,7 +20,7 @@ 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: '/mentors', name: 'MentorList', component: MentorList}, {path: '/dashboard', name: 'Dashboard', component: Dashboard, meta: {requiresAuth: true}}, {path: '/not-found', component: NotFound}, {path: '*', redirect: '/not-found'}