Cleaning imports
This commit is contained in:
+1
-16
@@ -1,31 +1,16 @@
|
|||||||
"""File containing Members application views."""
|
"""File containing Members application views."""
|
||||||
|
|
||||||
from django.shortcuts import render
|
|
||||||
from django.contrib.auth.decorators import permission_required
|
|
||||||
from django.views.decorators.http import require_http_methods
|
|
||||||
from django.views.decorators.csrf import ensure_csrf_cookie
|
|
||||||
from django.http import HttpResponse, HttpResponseRedirect
|
|
||||||
from django.core.mail import send_mail
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.utils.translation import ugettext as _
|
from django.utils.translation import ugettext as _
|
||||||
from django.forms.models import model_to_dict
|
|
||||||
|
|
||||||
# Email validation
|
# Email validation
|
||||||
from django.db.models.signals import post_save
|
from django.db.models.signals import post_save
|
||||||
from django.dispatch import receiver
|
from django.dispatch import receiver
|
||||||
from django.utils.http import urlsafe_base64_encode
|
|
||||||
from django.utils.encoding import force_bytes
|
|
||||||
|
|
||||||
import json
|
|
||||||
import requests
|
|
||||||
import logging
|
import logging
|
||||||
import html
|
|
||||||
import csv
|
|
||||||
import pickle
|
|
||||||
from smtplib import SMTPAuthenticationError
|
from smtplib import SMTPAuthenticationError
|
||||||
|
|
||||||
from members.models import Member, Request, Payment
|
from members.models import Member, Request
|
||||||
from members.forms import MemberForm, PaymentForm, ApplicationForm, CSVValidationError
|
|
||||||
from members.views.utils import send_mail_wrapper
|
from members.views.utils import send_mail_wrapper
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from webapp.models import Official, Role, Committee, Occupation
|
from webapp.models import Official, Role, Committee, Occupation
|
||||||
from webapp.models import Feed, Tag, BaseFeed, Event, Signup, SignupForm, TemplateQuestion
|
from webapp.models import Feed, Tag, Event, Signup, SignupForm, TemplateQuestion
|
||||||
from modeltranslation.admin import TranslationAdmin
|
from modeltranslation.admin import TranslationAdmin
|
||||||
from django.contrib.auth.models import Permission
|
from django.contrib.auth.models import Permission
|
||||||
# this is needed so that the models get registered for translation
|
# this is needed so that the models get registered for translation
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
"""File containing webapp forms."""
|
|
||||||
|
|
||||||
from django import forms
|
|
||||||
from django.utils.translation import ugettext_lazy as _
|
|
||||||
from django.core.exceptions import ValidationError
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
import django_tables2 as tables
|
|
||||||
from django.db.models import Count, Q
|
|
||||||
from django.utils.translation import ugettext as _
|
|
||||||
+7
-11
@@ -1,24 +1,20 @@
|
|||||||
"""Webapp views."""
|
"""Webapp views."""
|
||||||
|
|
||||||
import jwt
|
from jwt import decode
|
||||||
import json
|
from jwt.exceptions import InvalidSignatureError
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from dealer.git import git
|
from dealer.git import git
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.contrib.auth import authenticate
|
from django.http import HttpResponse, JsonResponse
|
||||||
from django.http import HttpResponseBadRequest, HttpResponse, JsonResponse
|
from django.shortcuts import render
|
||||||
from django.shortcuts import redirect, render
|
|
||||||
from django.views.decorators.http import require_http_methods
|
from django.views.decorators.http import require_http_methods
|
||||||
from django_filters import rest_framework as filters
|
from django_filters import rest_framework as filters
|
||||||
from django.core.exceptions import ObjectDoesNotExist
|
from django.core.exceptions import ObjectDoesNotExist
|
||||||
from rest_framework import permissions, routers, viewsets
|
from rest_framework import permissions, routers, viewsets
|
||||||
from rest_framework.filters import OrderingFilter, SearchFilter
|
from rest_framework.filters import OrderingFilter, SearchFilter
|
||||||
from rest_framework.permissions import IsAuthenticatedOrReadOnly
|
from rest_framework.permissions import IsAuthenticatedOrReadOnly
|
||||||
from rest_framework.response import Response
|
|
||||||
from rest_framework.reverse import reverse
|
|
||||||
from jsonschema import validate
|
from jsonschema import validate
|
||||||
from jsonschema.exceptions import ValidationError
|
from jsonschema.exceptions import ValidationError
|
||||||
import logging
|
|
||||||
|
|
||||||
from webapp.models import Event, SignupForm, Signup, TemplateQuestion, Feed, Committee, Occupation, Tag
|
from webapp.models import Event, SignupForm, Signup, TemplateQuestion, Feed, Committee, Occupation, Tag
|
||||||
from webapp.serializers import (EventSerializer, SignupFormSerializer, SignupSerializer,
|
from webapp.serializers import (EventSerializer, SignupFormSerializer, SignupSerializer,
|
||||||
@@ -82,8 +78,8 @@ class SignupViewSet(viewsets.ModelViewSet):
|
|||||||
# search_fields = '__all__'
|
# search_fields = '__all__'
|
||||||
|
|
||||||
def create(self, request, *args, **kwargs):
|
def create(self, request, *args, **kwargs):
|
||||||
try:
|
|
||||||
id = request.data["signupForm_id"]
|
id = request.data["signupForm_id"]
|
||||||
|
try:
|
||||||
answer = request.data["answer"]
|
answer = request.data["answer"]
|
||||||
form = SignupForm.objects.get(id=id)
|
form = SignupForm.objects.get(id=id)
|
||||||
if (form.visible):
|
if (form.visible):
|
||||||
@@ -184,8 +180,8 @@ def nginx_jwt_resp(request, *args, **kwargs):
|
|||||||
if not cookie:
|
if not cookie:
|
||||||
return HttpResponse("", status=401)
|
return HttpResponse("", status=401)
|
||||||
try:
|
try:
|
||||||
token = jwt.decode(cookie, settings.SECRET_KEY)
|
token = decode(cookie, settings.SECRET_KEY)
|
||||||
except jwt.exceptions.InvalidSignatureError:
|
except InvalidSignatureError:
|
||||||
return HttpResponse("", status=403)
|
return HttpResponse("", status=403)
|
||||||
user = 'admin' if token.get('username', '') == 'admin' else 'moderator'
|
user = 'admin' if token.get('username', '') == 'admin' else 'moderator'
|
||||||
resp = HttpResponse("", status=200)
|
resp = HttpResponse("", status=200)
|
||||||
|
|||||||
Reference in New Issue
Block a user