From 2a9de52cf19fc35acec88fe7138aad2960a3619f Mon Sep 17 00:00:00 2001 From: Zamil Majdy <z.majdy1996@gmail.com> Date: Fri, 2 Jun 2017 09:13:36 +0700 Subject: [PATCH] Make all images responsive with respect to div --- assets/css/custom.css | 5 +++++ assets/js/ProfilePage.jsx | 2 +- assets/js/VacancyPage.jsx | 2 +- core/views/accounts.py | 33 ++++++++++++++++----------------- kape/settings.py | 2 +- kape/urls.py | 4 ++-- 6 files changed, 26 insertions(+), 22 deletions(-) diff --git a/assets/css/custom.css b/assets/css/custom.css index bdf4b33b..9b7cf50a 100755 --- a/assets/css/custom.css +++ b/assets/css/custom.css @@ -2,6 +2,11 @@ text-align: center; } +img { + max-width: 100%; + height: auto; +} + * { box-sizing: border-box; -webkit-box-sizing: border-box; diff --git a/assets/js/ProfilePage.jsx b/assets/js/ProfilePage.jsx index fe5bdc62..dee202a4 100644 --- a/assets/js/ProfilePage.jsx +++ b/assets/js/ProfilePage.jsx @@ -91,7 +91,7 @@ export default class ProfilePage extends React.Component { } }); this.setState({ loading: true }); - Server.submit(`/profiles/students/${this.state.id}/`, submitForm, 'PATCH').then(() => { + Server.submit(`/students/${this.state.id}/profile/`, submitForm, 'PATCH').then(() => { this.setState({ loading: false }); this.modalAlert.open('Profil berhasil diperbaharui', 'Silakan periksa kembali profil anda', this.getProfile); }, error => error.then((r) => { diff --git a/assets/js/VacancyPage.jsx b/assets/js/VacancyPage.jsx index dc86b9ac..28e3f52c 100644 --- a/assets/js/VacancyPage.jsx +++ b/assets/js/VacancyPage.jsx @@ -39,7 +39,7 @@ export default class VacancyPage extends React.Component { if (this.props.user.role === 'student') { return ( <Tabs selected={0}> - <Pane label="Semua Lowongan" > + <Pane label="Lowongan" > <Pagination key={1} url="/vacancies/" diff --git a/core/views/accounts.py b/core/views/accounts.py index a441fc79..39bad87b 100644 --- a/core/views/accounts.py +++ b/core/views/accounts.py @@ -2,7 +2,7 @@ import requests from django.contrib.auth import authenticate, login from django.contrib.auth.models import User from rest_framework import viewsets, status -from rest_framework.decorators import list_route +from rest_framework.decorators import list_route, detail_route from rest_framework.parsers import FormParser,MultiPartParser from rest_framework.permissions import AllowAny from rest_framework.permissions import IsAdminUser, IsAuthenticated @@ -51,6 +51,21 @@ class StudentViewSet(viewsets.ModelViewSet): return [IsAuthenticated(), IsAdminOrSupervisorOrCompanyOrSelf()] return super(StudentViewSet, self).get_permissions() + @detail_route(methods=['patch'], permission_classes=[IsAdminOrStudent], + serializer_class=StudentUpdateSerializer, parser_classes=(MultiPartParser, FormParser,)) + def profile(self, request, pk=None): + """ + Update student {student_id}'s profile information + --- + """ + user = self.get_object() + serializer = self.serializer_class(user, data=request.data, partial=True) + if serializer.is_valid(): + serializer.save() + return Response(serializer.data, status=status.HTTP_202_ACCEPTED) + else: + return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) + class CompanyViewSet(viewsets.ModelViewSet): queryset = Company.objects.all() @@ -211,19 +226,3 @@ class CompanyRegisterViewSet(viewsets.GenericViewSet): return Response(serializer.data, status=status.HTTP_201_CREATED) else: return Response({'error': 'Company with email '+data['email']+' already exist'}, status=status.HTTP_409_CONFLICT) - - -class StudentProfileViewSet(viewsets.GenericViewSet): - queryset = Student.objects.all() - permission_classes = [IsAdminOrStudent] - serializer_class = StudentUpdateSerializer - parser_classes = (MultiPartParser, FormParser,) - - def partial_update(self, request, pk=None): - user = self.get_object() - serializer = self.serializer_class(user, data=request.data, partial=True) - if serializer.is_valid(): - serializer.save() - return Response(serializer.data, status=status.HTTP_202_ACCEPTED) - else: - return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) diff --git a/kape/settings.py b/kape/settings.py index 0967295d..56d0ddcb 100755 --- a/kape/settings.py +++ b/kape/settings.py @@ -18,7 +18,7 @@ WEBPACK_LOADER = { SECRET_KEY = 'gz!k*@!n8h$yny1)zp!e5#w8!s4%*wqnur5$qnr@$*xx_o+aij' # SECURITY WARNING: don't run with debug turned on in production! -DEBUG = True +DEBUG = (len(sys.argv) > 1 and sys.argv[1] == 'runserver') ALLOWED_HOSTS = [u'bot.recruit.id',u'kape.recruit.id',u'104.236.76.161',u'localhost',u'127.0.0.1'] diff --git a/kape/urls.py b/kape/urls.py index 0a398fec..0222b662 100755 --- a/kape/urls.py +++ b/kape/urls.py @@ -23,7 +23,7 @@ from rest_framework_swagger.views import get_swagger_view from core import apps from core.views.accounts import StudentViewSet, CompanyViewSet, SupervisorViewSet, UserViewSet, LoginViewSet, \ - CompanyRegisterViewSet, StudentProfileViewSet + CompanyRegisterViewSet from core.views.vacancies import VacancyViewSet, BookmarkedVacancyByStudentViewSet, ApplicationViewSet, \ CompanyApplicationViewSet, CompanyVacanciesViewSet, CompanyApplicationStatusViewSet, \ SupervisorStudentApplicationViewSet @@ -37,9 +37,9 @@ router.register(r'supervisors', SupervisorViewSet) router.register(r'login', LoginViewSet) router.register(r'register', CompanyRegisterViewSet) router.register(r'vacancies', VacancyViewSet) -router.register(r'profiles/students', StudentProfileViewSet) router.register(r'applications', CompanyApplicationStatusViewSet) router.register(r'student-applications', SupervisorStudentApplicationViewSet) +# router.register(r'students/(?P<student_id>\d+)/profile', StudentProfileViewSet) router.register(r'students/(?P<student_id>\d+)/bookmarked-vacancies', BookmarkedVacancyByStudentViewSet, base_name='bookmarked-vacancy-list') router.register(r'students/(?P<student_id>\d+)/applied-vacancies', ApplicationViewSet, -- GitLab