From 852b22dd7cd54b0cf8b8f6fec74e37d686c79517 Mon Sep 17 00:00:00 2001 From: AtmegaBuzz Date: Thu, 25 Aug 2022 19:00:19 +0530 Subject: [PATCH 1/2] cleaning, api views and templateviews splitup --- bugheist/urls.py | 7 +- requirements.txt | 117 ++++++++++++++++++++++++++++++++ website/api/views.py | 155 +++++++++++++++++++++++++++++++++++++++++++ website/tests.py | 5 +- website/views.py | 143 +-------------------------------------- 5 files changed, 282 insertions(+), 145 deletions(-) create mode 100644 requirements.txt create mode 100644 website/api/views.py diff --git a/bugheist/urls.py b/bugheist/urls.py index 2de2ae48df..bb25d0e49b 100644 --- a/bugheist/urls.py +++ b/bugheist/urls.py @@ -24,8 +24,6 @@ GloalLeaderboardView, SpecificMonthLeaderboardView, LeaderboardApiViewSet, - LikeIssueApiView, - FlagIssueApiView, IssueView, AllIssuesView, SpecificIssuesView, @@ -51,11 +49,16 @@ GithubLogin, GoogleLogin, GoogleConnect, +) +from website.api.views import ( IssueViewSet, DomainViewSet, UserIssueViewSet, UserProfileViewSet, + LikeIssueApiView, + FlagIssueApiView, ) + from bugheist import settings from rest_framework import permissions, routers from drf_yasg.views import get_schema_view diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000000..82ba7ff854 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,117 @@ +asgiref==3.5.2; python_version >= "3.8" +async-generator==1.10; python_version >= "3.7" and python_version < "4.0" +attrs==22.1.0; python_version >= "3.7" and python_version < "4.0" +beautifulsoup4==4.11.1; python_full_version >= "3.6.0" +boto==2.49.0 +cachetools==5.2.0; python_version >= "3.7" and python_version < "4.0" and (python_version >= "3.7" and python_full_version < "3.0.0" or python_version >= "3.7" and python_full_version >= "3.6.0") +certifi==2022.6.15; python_version >= "3.7" and python_version < "4" and (python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.7") and (python_version >= "3.0" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.0") and (python_version >= "3.7" and python_full_version < "3.0.0" and python_version < "4.0" and (python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.7") and (python_version >= "3.0" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.0") or python_full_version >= "3.6.0" and python_version < "4" and python_version >= "3.7" and (python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.7") and (python_version >= "3.0" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.0")) +cffi==1.15.1 +charset-normalizer==2.1.0; python_version >= "3.7" and python_version < "4" and python_full_version >= "3.6.0" and (python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.7") and (python_version >= "3.0" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.0") +colorama==0.4.5; python_version >= "3.7" and python_full_version < "3.0.0" and platform_system == "Windows" or python_full_version >= "3.5.0" and python_version >= "3.7" and platform_system == "Windows" +colorthief==0.2.1 +coreapi==2.3.3; python_version >= "3.6" +coreschema==0.0.4; python_version >= "3.6" +cryptography==37.0.4; python_version >= "3.6" and (python_version >= "3.7" and python_full_version < "3.0.0" and python_version < "4.0" and (python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.7") and (python_version >= "3.0" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.0") or python_full_version >= "3.6.0" and python_version < "4" and python_version >= "3.7" and (python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.7") and (python_version >= "3.0" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.0")) +defusedxml==0.7.1; python_version >= "3.7" and python_full_version < "3.0.0" or python_version >= "3.7" and python_full_version >= "3.5.0" +diff-match-patch==20200713; python_version >= "3.7" +dj-database-url==1.0.0 +dj-rest-auth==2.2.5; python_version >= "3.5" +django-allauth==0.51.0 +django-annoying==0.10.6 +django-bootstrap-datepicker-plus==4.0.0; python_version >= "3.6" +django-braces==1.15.0 +django-cors-headers==3.13.0; python_version >= "3.7" +django-debug-toolbar==3.5.0; python_version >= "3.7" +django-email-obfuscator==0.1.5 +django-environ==0.9.0; python_version >= "3.4" and python_version < "4" +django-filter==22.1; python_version >= "3.7" +django-gravatar2==1.4.4 +django-humanize==0.1.2 +django-import-export==2.8.0; python_version >= "3.7" +django-mdeditor==0.1.20 +django-model-utils==4.2.0 +django-ranged-response==0.2.0 +django-rest-auth==0.9.5 +django-simple-captcha==0.5.17 +django-star-ratings==0.9.2 +django-storages==1.13.1; python_version >= "3.7" +django-tellme==0.7.3; python_version >= "2.7" +django-timedeltafield==0.7.10 +django-tz-detect==0.4.0 +django==4.1; python_version >= "3.8" +djangorestframework==3.13.1; python_version >= "3.6" +drf-yasg==1.21.3; python_version >= "3.6" +easyprocess==1.1 +et-xmlfile==1.1.0; python_version >= "3.7" +giturlparse.py==0.0.5 +google-api-core==2.8.2; python_version >= "3.7" +google-auth==2.10.0; python_version >= "3.7" and python_full_version < "3.0.0" or python_version >= "3.7" and python_full_version >= "3.6.0" +google-cloud-core==2.3.2; python_version >= "3.7" +google-cloud-storage==2.5.0; python_version >= "3.7" +google-crc32c==1.3.0; python_version >= "3.7" +google-resumable-media==2.3.3; python_version >= "3.7" +googleapis-common-protos==1.56.4; python_version >= "3.7" +gunicorn==20.1.0; python_version >= "3.5" +h11==0.13.0; python_version >= "3.7" and python_version < "4.0" and python_full_version >= "3.7.0" +humanize==4.3.0; python_version >= "3.7" +idna==3.3; python_version >= "3.7" and python_version < "4" and (python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.7") and (python_version >= "3.0" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.0") and (python_version >= "3.7" and python_full_version < "3.0.0" and python_version < "4.0" and (python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.7") and (python_version >= "3.0" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.0") or python_full_version >= "3.6.0" and python_version < "4" and python_version >= "3.7" and (python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.7") and (python_version >= "3.0" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.0")) +inflection==0.5.1; python_version >= "3.6" +itypes==1.2.0; python_version >= "3.6" +jinja2==3.1.2; python_version >= "3.7" +markuppy==1.14; python_version >= "3.7" +markupsafe==2.1.1; python_version >= "3.7" +oauthlib==3.2.0; python_version >= "3.6" +odfpy==1.4.1; python_version >= "3.7" +openpyxl==3.0.10; python_version >= "3.7" +outcome==1.2.0; python_version >= "3.7" and python_version < "4.0" +packaging==21.3; python_version >= "3.7" +parse==1.19.0 +pillow==9.2.0; python_version >= "3.7" +protobuf==3.20.1; python_version >= "3.7" +psycopg2-binary==2.9.3; python_version >= "3.6" +pyasn1-modules==0.2.8; python_version >= "3.7" and python_full_version < "3.0.0" or python_version >= "3.7" and python_full_version >= "3.6.0" +pyasn1==0.4.8; python_version >= "3.7" and python_full_version < "3.0.0" and python_version < "4" and (python_version >= "3.7" and python_full_version < "3.0.0" or python_version >= "3.7" and python_full_version >= "3.6.0") or python_version >= "3.7" and python_full_version >= "3.6.0" and python_version < "4" and (python_version >= "3.7" and python_full_version < "3.0.0" or python_version >= "3.7" and python_full_version >= "3.6.0") +pycparser==2.21; python_version >= "3.7" and python_full_version < "3.0.0" and os_name == "nt" and implementation_name != "pypy" and python_version < "4.0" and (python_version >= "3.7" and python_full_version < "3.0.0" and python_version < "4.0" and (python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.7") and (python_version >= "3.0" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.0") or python_full_version >= "3.6.0" and python_version < "4" and python_version >= "3.7" and (python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.7") and (python_version >= "3.0" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.0")) or os_name == "nt" and implementation_name != "pypy" and python_version >= "3.7" and python_version < "4.0" and (python_version >= "3.7" and python_full_version < "3.0.0" and python_version < "4.0" and (python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.7") and (python_version >= "3.0" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.0") or python_full_version >= "3.6.0" and python_version < "4" and python_version >= "3.7" and (python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.7") and (python_version >= "3.0" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.0")) and python_full_version >= "3.4.0" +pyjwt==2.4.0; python_version >= "3.6" +pylibmc==1.6.2; python_version >= "3.6" +pyopenssl==22.0.0; python_version >= "3.7" and python_full_version < "3.0.0" and python_version < "4.0" and (python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.7") and (python_version >= "3.0" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.0") or python_full_version >= "3.6.0" and python_version < "4" and python_version >= "3.7" and (python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.7") and (python_version >= "3.0" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.0") +pyparsing==3.0.9; python_full_version >= "3.6.8" and python_version >= "3.7" +pysocks==1.7.1; python_version >= "3.7" and python_full_version < "3.0.0" and python_version < "4.0" and (python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.7") and (python_version >= "3.0" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.0") or python_full_version >= "3.6.0" and python_version < "4" and python_version >= "3.7" and (python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.7") and (python_version >= "3.0" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.0") +pytesseract==0.3.9; python_version >= "3.7" +python-dotenv==0.20.0; python_version >= "3.7" +python-openid==2.2.5 +python3-openid==3.2.0 +pytz==2021.3 +pyvirtualdisplay==3.0 +pyyaml==6.0; python_version >= "3.7" +requests-oauthlib==1.3.1; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.4.0") +requests==2.28.1; python_version >= "3.7" and python_version < "4" +rollbar==0.16.3 +rsa==4.9; python_version >= "3.6" and python_version < "4" and (python_version >= "3.7" and python_full_version < "3.0.0" or python_version >= "3.7" and python_full_version >= "3.6.0") +ruamel.yaml.clib==0.2.6; platform_python_implementation == "CPython" and python_version < "3.11" and python_version >= "3.6" +ruamel.yaml==0.17.21; python_version >= "3.6" +selenium==4.4.0; python_version >= "3.7" and python_version < "4.0" +six==1.16.0; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.3.0") +sniffio==1.2.0; python_version >= "3.7" and python_version < "4.0" +sortedcontainers==2.4.0; python_version >= "3.7" and python_version < "4.0" +soupsieve==2.3.2.post1; python_version >= "3.6" and python_full_version >= "3.6.0" +sqlparse==0.4.2; python_version >= "3.8" +stripe==3.5.0; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.4.0") +swapper==1.3.0 +tablib==3.2.1; python_version >= "3.7" +toml==0.10.2; (python_version >= "2.6" and python_full_version < "3.0.0") or (python_full_version >= "3.3.0") +tqdm==4.64.0; python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.7" +trio-websocket==0.9.2; python_version >= "3.7" and python_version < "4.0" +trio==0.21.0; python_version >= "3.7" and python_version < "4.0" +tweepy==4.10.0; python_version >= "3.7" +tzdata==2022.2; sys_platform == "win32" and python_version >= "3.8" +ua-parser==0.10.0 +unidecode==1.3.4; python_version >= "3.5" +uritemplate==4.1.1; python_version >= "3.6" +urllib3==1.26.11; python_version >= "3.7" and python_full_version < "3.0.0" and python_version < "4.0" and (python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.7") and (python_version >= "3.0" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.0") or python_full_version >= "3.6.0" and python_version < "4" and python_version >= "3.7" and (python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.7") and (python_version >= "3.0" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.0") +user-agents==2.2.0 +webdriver-manager==3.8.3; python_version >= "3.7" +whitenoise==6.2.0; python_version >= "3.7" +wsproto==1.1.0; python_version >= "3.7" and python_version < "4.0" and python_full_version >= "3.7.0" +xlrd==2.0.1; python_version >= "3.7" and python_full_version < "3.0.0" or python_version >= "3.7" and python_full_version >= "3.6.0" +xlwt==1.3.0; python_version >= "3.7" diff --git a/website/api/views.py b/website/api/views.py new file mode 100644 index 0000000000..c5c4de8c59 --- /dev/null +++ b/website/api/views.py @@ -0,0 +1,155 @@ +import requests.exceptions + + +from django.core.mail import send_mail +from django.template.loader import render_to_string + +from rest_framework import viewsets, filters +from rest_framework.response import Response +from rest_framework.views import APIView +from rest_framework.authentication import TokenAuthentication +from rest_framework.permissions import IsAuthenticated + +from website.models import ( + Issue, + Domain, +) +from website.serializers import ( + IssueSerializer, + UserProfileSerializer, + DomainSerializer, +) + +from website.models import UserProfile + + +# API's + + +class UserIssueViewSet(viewsets.ModelViewSet): + """ + User Issue Model View Set + """ + + queryset = Issue.objects.all() + serializer_class = IssueSerializer + filter_backends = (filters.SearchFilter,) + search_fields = ("user__username", "user__id") + http_method_names = ["get", "post", "head"] + + +class UserProfileViewSet(viewsets.ModelViewSet): + """ + User Profile View Set + """ + + serializer_class = UserProfileSerializer + queryset = UserProfile.objects.all() + filter_backends = (filters.SearchFilter,) + search_fields = ("id", "user__id", "user__username") + http_method_names = ["get", "post", "head"] + + +class DomainViewSet(viewsets.ModelViewSet): + """ + Domain View Set + """ + + serializer_class = DomainSerializer + queryset = Domain.objects.all() + filter_backends = (filters.SearchFilter,) + search_fields = ("url", "name") + http_method_names = ["get", "post", "head"] + + +class IssueViewSet(viewsets.ModelViewSet): + """ + Issue View Set + """ + + queryset = Issue.objects.all() + serializer_class = IssueSerializer + filter_backends = (filters.SearchFilter,) + search_fields = ("url", "description", "user__id") + http_method_names = ["get", "post", "head"] + + + +class LikeIssueApiView(APIView): + + authentication_classes = [TokenAuthentication] + permission_classes = [IsAuthenticated] + + def get(self,request,id,format=None,*args, **kwargs): + return Response({ + "likes":UserProfile.objects.filter(issue_upvoted__id=id).count(), + }) + + def post(self,request,id,format=None,*args,**kwargs): + + issue = Issue.objects.get(id=id) + userprof = UserProfile.objects.get(user=request.user) + if userprof in UserProfile.objects.filter(issue_upvoted=issue): + userprof.issue_upvoted.remove(issue) + userprof.save() + return Response({"issue":"unliked"}) + else: + userprof.issue_upvoted.add(issue) + userprof.save() + + liked_user = issue.user + liker_user = request.user + issue_pk = issue.pk + msg_plain = render_to_string( + "email/issue_liked.txt", + { + "liker_user": liker_user.username, + "liked_user": liked_user.username, + "issue_pk": issue_pk, + }, + ) + msg_html = render_to_string( + "email/issue_liked.txt", + { + "liker_user": liker_user.username, + "liked_user": liked_user.username, + "issue_pk": issue_pk, + }, + ) + + send_mail( + "Your issue got an upvote!!", + msg_plain, + "Bugheist ", + [liked_user.email], + html_message=msg_html, + ) + + return Response({"issue":"liked"}) + +class FlagIssueApiView(APIView): + ''' + api for Issue like,flag and bookmark + ''' + + authentication_classes = [TokenAuthentication] + permission_classes = [IsAuthenticated] + + def get(self,request,id,format=None,*args, **kwargs): + return Response({ + "flags":UserProfile.objects.filter(issue_flaged__id=id).count(), + }) + + def post(self,request,id,format=None,*args,**kwargs): + + + issue = Issue.objects.get(id=id) + userprof = UserProfile.objects.get(user=request.user) + if userprof in UserProfile.objects.filter(issue_flaged=issue): + userprof.issue_flaged.remove(issue) + userprof.save() + return Response({"issue":"unflagged"}) + else: + userprof.issue_flaged.add(issue) + userprof.save() + return Response({"issue":"flagged"}) \ No newline at end of file diff --git a/website/tests.py b/website/tests.py index edbeb9689f..30728fbffa 100644 --- a/website/tests.py +++ b/website/tests.py @@ -7,9 +7,10 @@ os.environ['DJANGO_LIVE_TEST_SERVER_ADDRESS'] = 'localhost:8082' from django.test.utils import override_settings -from selenium.webdriver.firefox.webdriver import WebDriver +from selenium import webdriver from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC +from webdriver_manager.firefox import GeckoDriverManager from selenium.webdriver.common.by import By class MySeleniumTests(LiveServerTestCase): @@ -18,7 +19,7 @@ class MySeleniumTests(LiveServerTestCase): @classmethod def setUpClass(cls): print (sys.path) - cls.selenium = WebDriver() + cls.selenium = webdriver.Firefox(executable_path=GeckoDriverManager(cache_valid_range=1).install()) super(MySeleniumTests, cls).setUpClass() @classmethod diff --git a/website/views.py b/website/views.py index a3165b759f..ca7620fcb9 100644 --- a/website/views.py +++ b/website/views.py @@ -34,7 +34,7 @@ from django.db.models import Sum, Count, Q from django.db.models.functions import ExtractMonth from django.dispatch import receiver -from django.http import Http404, QueryDict +from django.http import Http404 from django.http import HttpResponse from django.http import HttpResponseRedirect from django.http import JsonResponse @@ -49,14 +49,10 @@ from django.views.decorators.http import require_GET from django.conf import settings -from rest_framework import viewsets, filters from user_agents import parse from rest_framework.authtoken.models import Token from rest_framework.response import Response from rest_framework.views import APIView -from rest_framework.authentication import TokenAuthentication -from rest_framework.permissions import IsAuthenticated -from rest_framework.decorators import action from allauth.socialaccount.providers.facebook.views import FacebookOAuth2Adapter from dj_rest_auth.registration.views import SocialLoginView @@ -88,11 +84,6 @@ import stripe import humanize -from .serializers import ( - IssueSerializer, - UserProfileSerializer, - DomainSerializer, -) def index(request, template="index.html"): @@ -3058,138 +3049,8 @@ def company_hunt_results(request, pk, template="company_hunt_results.html"): return render(request, template, context) -# API's - - -class UserIssueViewSet(viewsets.ModelViewSet): - """ - User Issue Model View Set - """ - - queryset = Issue.objects.all() - serializer_class = IssueSerializer - filter_backends = (filters.SearchFilter,) - search_fields = ("user__username", "user__id") - http_method_names = ["get", "post", "head"] - - -class UserProfileViewSet(viewsets.ModelViewSet): - """ - User Profile View Set - """ - - serializer_class = UserProfileSerializer - queryset = UserProfile.objects.all() - filter_backends = (filters.SearchFilter,) - search_fields = ("id", "user__id", "user__username") - http_method_names = ["get", "post", "head"] - - -class DomainViewSet(viewsets.ModelViewSet): - """ - Domain View Set - """ - - serializer_class = DomainSerializer - queryset = Domain.objects.all() - filter_backends = (filters.SearchFilter,) - search_fields = ("url", "name") - http_method_names = ["get", "post", "head"] - - -class IssueViewSet(viewsets.ModelViewSet): - """ - Issue View Set - """ - - queryset = Issue.objects.all() - serializer_class = IssueSerializer - filter_backends = (filters.SearchFilter,) - search_fields = ("url", "description", "user__id") - http_method_names = ["get", "post", "head"] - - def handler404(request, exception): return render(request, "404.html", {}, status=404) def handler500(request, exception=None): - return render(request, "500.html", {}, status=500) - -class LikeIssueApiView(APIView): - - authentication_classes = [TokenAuthentication] - permission_classes = [IsAuthenticated] - - def get(self,request,id,format=None,*args, **kwargs): - return Response({ - "likes":UserProfile.objects.filter(issue_upvoted__id=id).count(), - }) - - def post(self,request,id,format=None,*args,**kwargs): - - issue = Issue.objects.get(id=id) - userprof = UserProfile.objects.get(user=request.user) - if userprof in UserProfile.objects.filter(issue_upvoted=issue): - userprof.issue_upvoted.remove(issue) - userprof.save() - return Response({"issue":"unliked"}) - else: - userprof.issue_upvoted.add(issue) - userprof.save() - - liked_user = issue.user - liker_user = request.user - issue_pk = issue.pk - msg_plain = render_to_string( - "email/issue_liked.txt", - { - "liker_user": liker_user.username, - "liked_user": liked_user.username, - "issue_pk": issue_pk, - }, - ) - msg_html = render_to_string( - "email/issue_liked.txt", - { - "liker_user": liker_user.username, - "liked_user": liked_user.username, - "issue_pk": issue_pk, - }, - ) - - send_mail( - "Your issue got an upvote!!", - msg_plain, - "Bugheist ", - [liked_user.email], - html_message=msg_html, - ) - - return Response({"issue":"liked"}) - -class FlagIssueApiView(APIView): - ''' - api for Issue like,flag and bookmark - ''' - - authentication_classes = [TokenAuthentication] - permission_classes = [IsAuthenticated] - - def get(self,request,id,format=None,*args, **kwargs): - return Response({ - "flags":UserProfile.objects.filter(issue_flaged__id=id).count(), - }) - - def post(self,request,id,format=None,*args,**kwargs): - - - issue = Issue.objects.get(id=id) - userprof = UserProfile.objects.get(user=request.user) - if userprof in UserProfile.objects.filter(issue_flaged=issue): - userprof.issue_flaged.remove(issue) - userprof.save() - return Response({"issue":"unflagged"}) - else: - userprof.issue_flaged.add(issue) - userprof.save() - return Response({"issue":"flagged"}) + return render(request, "500.html", {}, status=500) \ No newline at end of file From b58b2f08b920c7a571097a191ca7bd7289b69cd9 Mon Sep 17 00:00:00 2001 From: swapnil shinde Date: Thu, 25 Aug 2022 19:07:07 +0530 Subject: [PATCH 2/2] Delete requirements.txt --- requirements.txt | 117 ----------------------------------------------- 1 file changed, 117 deletions(-) delete mode 100644 requirements.txt diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 82ba7ff854..0000000000 --- a/requirements.txt +++ /dev/null @@ -1,117 +0,0 @@ -asgiref==3.5.2; python_version >= "3.8" -async-generator==1.10; python_version >= "3.7" and python_version < "4.0" -attrs==22.1.0; python_version >= "3.7" and python_version < "4.0" -beautifulsoup4==4.11.1; python_full_version >= "3.6.0" -boto==2.49.0 -cachetools==5.2.0; python_version >= "3.7" and python_version < "4.0" and (python_version >= "3.7" and python_full_version < "3.0.0" or python_version >= "3.7" and python_full_version >= "3.6.0") -certifi==2022.6.15; python_version >= "3.7" and python_version < "4" and (python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.7") and (python_version >= "3.0" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.0") and (python_version >= "3.7" and python_full_version < "3.0.0" and python_version < "4.0" and (python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.7") and (python_version >= "3.0" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.0") or python_full_version >= "3.6.0" and python_version < "4" and python_version >= "3.7" and (python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.7") and (python_version >= "3.0" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.0")) -cffi==1.15.1 -charset-normalizer==2.1.0; python_version >= "3.7" and python_version < "4" and python_full_version >= "3.6.0" and (python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.7") and (python_version >= "3.0" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.0") -colorama==0.4.5; python_version >= "3.7" and python_full_version < "3.0.0" and platform_system == "Windows" or python_full_version >= "3.5.0" and python_version >= "3.7" and platform_system == "Windows" -colorthief==0.2.1 -coreapi==2.3.3; python_version >= "3.6" -coreschema==0.0.4; python_version >= "3.6" -cryptography==37.0.4; python_version >= "3.6" and (python_version >= "3.7" and python_full_version < "3.0.0" and python_version < "4.0" and (python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.7") and (python_version >= "3.0" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.0") or python_full_version >= "3.6.0" and python_version < "4" and python_version >= "3.7" and (python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.7") and (python_version >= "3.0" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.0")) -defusedxml==0.7.1; python_version >= "3.7" and python_full_version < "3.0.0" or python_version >= "3.7" and python_full_version >= "3.5.0" -diff-match-patch==20200713; python_version >= "3.7" -dj-database-url==1.0.0 -dj-rest-auth==2.2.5; python_version >= "3.5" -django-allauth==0.51.0 -django-annoying==0.10.6 -django-bootstrap-datepicker-plus==4.0.0; python_version >= "3.6" -django-braces==1.15.0 -django-cors-headers==3.13.0; python_version >= "3.7" -django-debug-toolbar==3.5.0; python_version >= "3.7" -django-email-obfuscator==0.1.5 -django-environ==0.9.0; python_version >= "3.4" and python_version < "4" -django-filter==22.1; python_version >= "3.7" -django-gravatar2==1.4.4 -django-humanize==0.1.2 -django-import-export==2.8.0; python_version >= "3.7" -django-mdeditor==0.1.20 -django-model-utils==4.2.0 -django-ranged-response==0.2.0 -django-rest-auth==0.9.5 -django-simple-captcha==0.5.17 -django-star-ratings==0.9.2 -django-storages==1.13.1; python_version >= "3.7" -django-tellme==0.7.3; python_version >= "2.7" -django-timedeltafield==0.7.10 -django-tz-detect==0.4.0 -django==4.1; python_version >= "3.8" -djangorestframework==3.13.1; python_version >= "3.6" -drf-yasg==1.21.3; python_version >= "3.6" -easyprocess==1.1 -et-xmlfile==1.1.0; python_version >= "3.7" -giturlparse.py==0.0.5 -google-api-core==2.8.2; python_version >= "3.7" -google-auth==2.10.0; python_version >= "3.7" and python_full_version < "3.0.0" or python_version >= "3.7" and python_full_version >= "3.6.0" -google-cloud-core==2.3.2; python_version >= "3.7" -google-cloud-storage==2.5.0; python_version >= "3.7" -google-crc32c==1.3.0; python_version >= "3.7" -google-resumable-media==2.3.3; python_version >= "3.7" -googleapis-common-protos==1.56.4; python_version >= "3.7" -gunicorn==20.1.0; python_version >= "3.5" -h11==0.13.0; python_version >= "3.7" and python_version < "4.0" and python_full_version >= "3.7.0" -humanize==4.3.0; python_version >= "3.7" -idna==3.3; python_version >= "3.7" and python_version < "4" and (python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.7") and (python_version >= "3.0" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.0") and (python_version >= "3.7" and python_full_version < "3.0.0" and python_version < "4.0" and (python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.7") and (python_version >= "3.0" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.0") or python_full_version >= "3.6.0" and python_version < "4" and python_version >= "3.7" and (python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.7") and (python_version >= "3.0" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.0")) -inflection==0.5.1; python_version >= "3.6" -itypes==1.2.0; python_version >= "3.6" -jinja2==3.1.2; python_version >= "3.7" -markuppy==1.14; python_version >= "3.7" -markupsafe==2.1.1; python_version >= "3.7" -oauthlib==3.2.0; python_version >= "3.6" -odfpy==1.4.1; python_version >= "3.7" -openpyxl==3.0.10; python_version >= "3.7" -outcome==1.2.0; python_version >= "3.7" and python_version < "4.0" -packaging==21.3; python_version >= "3.7" -parse==1.19.0 -pillow==9.2.0; python_version >= "3.7" -protobuf==3.20.1; python_version >= "3.7" -psycopg2-binary==2.9.3; python_version >= "3.6" -pyasn1-modules==0.2.8; python_version >= "3.7" and python_full_version < "3.0.0" or python_version >= "3.7" and python_full_version >= "3.6.0" -pyasn1==0.4.8; python_version >= "3.7" and python_full_version < "3.0.0" and python_version < "4" and (python_version >= "3.7" and python_full_version < "3.0.0" or python_version >= "3.7" and python_full_version >= "3.6.0") or python_version >= "3.7" and python_full_version >= "3.6.0" and python_version < "4" and (python_version >= "3.7" and python_full_version < "3.0.0" or python_version >= "3.7" and python_full_version >= "3.6.0") -pycparser==2.21; python_version >= "3.7" and python_full_version < "3.0.0" and os_name == "nt" and implementation_name != "pypy" and python_version < "4.0" and (python_version >= "3.7" and python_full_version < "3.0.0" and python_version < "4.0" and (python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.7") and (python_version >= "3.0" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.0") or python_full_version >= "3.6.0" and python_version < "4" and python_version >= "3.7" and (python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.7") and (python_version >= "3.0" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.0")) or os_name == "nt" and implementation_name != "pypy" and python_version >= "3.7" and python_version < "4.0" and (python_version >= "3.7" and python_full_version < "3.0.0" and python_version < "4.0" and (python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.7") and (python_version >= "3.0" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.0") or python_full_version >= "3.6.0" and python_version < "4" and python_version >= "3.7" and (python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.7") and (python_version >= "3.0" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.0")) and python_full_version >= "3.4.0" -pyjwt==2.4.0; python_version >= "3.6" -pylibmc==1.6.2; python_version >= "3.6" -pyopenssl==22.0.0; python_version >= "3.7" and python_full_version < "3.0.0" and python_version < "4.0" and (python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.7") and (python_version >= "3.0" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.0") or python_full_version >= "3.6.0" and python_version < "4" and python_version >= "3.7" and (python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.7") and (python_version >= "3.0" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.0") -pyparsing==3.0.9; python_full_version >= "3.6.8" and python_version >= "3.7" -pysocks==1.7.1; python_version >= "3.7" and python_full_version < "3.0.0" and python_version < "4.0" and (python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.7") and (python_version >= "3.0" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.0") or python_full_version >= "3.6.0" and python_version < "4" and python_version >= "3.7" and (python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.7") and (python_version >= "3.0" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.0") -pytesseract==0.3.9; python_version >= "3.7" -python-dotenv==0.20.0; python_version >= "3.7" -python-openid==2.2.5 -python3-openid==3.2.0 -pytz==2021.3 -pyvirtualdisplay==3.0 -pyyaml==6.0; python_version >= "3.7" -requests-oauthlib==1.3.1; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.4.0") -requests==2.28.1; python_version >= "3.7" and python_version < "4" -rollbar==0.16.3 -rsa==4.9; python_version >= "3.6" and python_version < "4" and (python_version >= "3.7" and python_full_version < "3.0.0" or python_version >= "3.7" and python_full_version >= "3.6.0") -ruamel.yaml.clib==0.2.6; platform_python_implementation == "CPython" and python_version < "3.11" and python_version >= "3.6" -ruamel.yaml==0.17.21; python_version >= "3.6" -selenium==4.4.0; python_version >= "3.7" and python_version < "4.0" -six==1.16.0; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.3.0") -sniffio==1.2.0; python_version >= "3.7" and python_version < "4.0" -sortedcontainers==2.4.0; python_version >= "3.7" and python_version < "4.0" -soupsieve==2.3.2.post1; python_version >= "3.6" and python_full_version >= "3.6.0" -sqlparse==0.4.2; python_version >= "3.8" -stripe==3.5.0; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.4.0") -swapper==1.3.0 -tablib==3.2.1; python_version >= "3.7" -toml==0.10.2; (python_version >= "2.6" and python_full_version < "3.0.0") or (python_full_version >= "3.3.0") -tqdm==4.64.0; python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.7" -trio-websocket==0.9.2; python_version >= "3.7" and python_version < "4.0" -trio==0.21.0; python_version >= "3.7" and python_version < "4.0" -tweepy==4.10.0; python_version >= "3.7" -tzdata==2022.2; sys_platform == "win32" and python_version >= "3.8" -ua-parser==0.10.0 -unidecode==1.3.4; python_version >= "3.5" -uritemplate==4.1.1; python_version >= "3.6" -urllib3==1.26.11; python_version >= "3.7" and python_full_version < "3.0.0" and python_version < "4.0" and (python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.7") and (python_version >= "3.0" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.0") or python_full_version >= "3.6.0" and python_version < "4" and python_version >= "3.7" and (python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.7") and (python_version >= "3.0" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.0") -user-agents==2.2.0 -webdriver-manager==3.8.3; python_version >= "3.7" -whitenoise==6.2.0; python_version >= "3.7" -wsproto==1.1.0; python_version >= "3.7" and python_version < "4.0" and python_full_version >= "3.7.0" -xlrd==2.0.1; python_version >= "3.7" and python_full_version < "3.0.0" or python_version >= "3.7" and python_full_version >= "3.6.0" -xlwt==1.3.0; python_version >= "3.7"