Skip to content

Commit

Permalink
Merge pull request #115 from nb9960/master
Browse files Browse the repository at this point in the history
fixes install dependencies workflow and lint errors
  • Loading branch information
Vikhyath08 authored Jan 14, 2022
2 parents d0026e5 + 0c00a58 commit b55c01b
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 26 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: '3.8'
- uses: dschep/install-pipenv-action@v1
- name: Install dependencies
run: pipenv install
python-version: 3.8
- name: Install dependencies with pipenv
run: |
pip install pipenv
pipenv install
- name: Run lint checks
run: pipenv run pylint --load-plugins pylint_django team workshops workshop authentication config noticeboard academics
1 change: 1 addition & 0 deletions academics/models.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# pylint: disable=too-few-public-methods
from django.db import models

# Create your models here.
Expand Down
3 changes: 1 addition & 2 deletions academics/serializers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# pylint: disable=too-few-public-methods
from rest_framework import serializers
from rest_framework.exceptions import NotFound
from drf_yasg2.utils import swagger_serializer_method
from .models import AcademicSchedule, ProfsAndHODs, StudyMaterials


Expand Down
2 changes: 0 additions & 2 deletions academics/tests.py
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
from django.test import TestCase

# Create your tests here.
14 changes: 6 additions & 8 deletions academics/views.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
from rest_framework import generics, permissions, status
from rest_framework.response import Response
# pylint: disable=no-member
from rest_framework import generics
from django.shortcuts import get_object_or_404
from authentication.models import UserProfile
from .models import AcademicSchedule, StudyMaterials, ProfsAndHODs
from .serializers import (AcademicScheduleSerializer,
ProfsAndHODsSerializer, StudyMaterialsSerializer)
from authentication.models import UserProfile
from rest_framework.permissions import IsAuthenticated, IsAdminUser


class AcademicScheduleView(generics.RetrieveAPIView):
"""
Expand All @@ -31,7 +27,8 @@ def get_object(self):
class StudyMaterialsView(generics.RetrieveAPIView):
'''
Accepts a parameter dept and returns a url of the study materials for the given department.
'dept' is the acronym of the department same as in the email id and contains lower case letters only.
'dept' is the acronym of the department same as in the email id and contains lower case
letters only.
'''

queryset = StudyMaterials.objects.all()
Expand All @@ -43,7 +40,8 @@ class StudyMaterialsView(generics.RetrieveAPIView):
class ProfsAndHODsView(generics.RetrieveAPIView):
'''
Accepts a parameter dept and returns a url of the professors of the given department.
'dept' is the acronym of the department same as in the email id and contains lower case letters only.
'dept' is the acronym of the department same as in the email id and contains lower
case letters only.
'''

queryset = ProfsAndHODs.objects.all()
Expand Down
6 changes: 3 additions & 3 deletions authentication/serializers.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# pylint: disable=too-few-public-methods
import logging
from django.core.validators import RegexValidator
# pylint: disable=imported-auth-user
from django.contrib.auth.models import User
from django.contrib.auth import get_user_model
from rest_framework import serializers
from drf_yasg2.utils import swagger_serializer_method
from workshop.serializers import ClubSerializer, EntitySerializer
Expand Down Expand Up @@ -49,7 +49,7 @@ def validate(self, attrs):
raise serializers.ValidationError(
"Please login using @itbhu.ac.in student email id only")
name = jwt['name']
user = User()
user = get_user_model()
user.username = jwt['uid']
user.email = email
user.save()
Expand Down
5 changes: 4 additions & 1 deletion noticeboard/serializers.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# pylint: disable=too-few-public-methods
# from datetime import date
from rest_framework import serializers
from authentication.models import UserProfile
Expand All @@ -12,6 +13,7 @@ class NoticeDetailSerializer(serializers.ModelSerializer):
has_voted = serializers.SerializerMethodField()

def get_has_voted(self, obj):
"""Check if already voted"""
# pylint: disable=no-member
user = UserProfile.objects.get(user=self.context['request'].user)
# if user in obj.voters.all():
Expand All @@ -22,7 +24,8 @@ def get_has_voted(self, obj):
class Meta:
model = NoticeBoard
read_only_fields = ("id", "upvotes", "downvotes")
fields = ("id", "title", "description", "date", "upvotes", "downvotes","importance", "has_voted")
fields = ("id", "title", "description", "date", "upvotes", "downvotes",
"importance", "has_voted")


class NoticeCreateSerializer(serializers.ModelSerializer):
Expand Down
2 changes: 0 additions & 2 deletions noticeboard/tests.py
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
from django.test import TestCase

# Create your tests here.
8 changes: 4 additions & 4 deletions noticeboard/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class NoticeUpvoteView(generics.GenericAPIView):
serializer_class = NoticeDetailSerializer

def get(self, request, pk):
"""Check if already voted or not"""
notice = self.queryset.get(id=pk)
user = UserProfile.objects.get(user=request.user)
if notice is not None:
Expand All @@ -62,8 +63,7 @@ def get(self, request, pk):
return Response(
{"Message": "Upvoted successfully"}, status=status.HTTP_200_OK
)
else:
return Response(
return Response(
{"Error": "Notice not found"}, status=status.HTTP_204_NO_CONTENT
)

Expand All @@ -78,6 +78,7 @@ class NoticeDownvoteView(generics.GenericAPIView):
serializer_class = NoticeDetailSerializer

def get(self, request, pk):
"""Check if already voted or not"""
notice = self.queryset.get(id=pk)
user = UserProfile.objects.get(user=request.user)
if notice is not None:
Expand All @@ -91,7 +92,6 @@ def get(self, request, pk):
return Response(
{"Message": "Downvoted successfully"}, status=status.HTTP_200_OK
)
else:
return Response(
return Response(
{"Error": "Notice not found"}, status=status.HTTP_204_NO_CONTENT
)

0 comments on commit b55c01b

Please sign in to comment.