diff --git a/locustfile.py b/locustfile.py index cd1bbdea..3f3ab55c 100644 --- a/locustfile.py +++ b/locustfile.py @@ -1,17 +1,22 @@ from locust import HttpLocust, Set, between + def index(load): load.client.get("/") + def load_gifs(load): load.client.get("/collection/") + def exhibit(load): load.client.get("/longavida/") + class UserBehavior(Set): - s = {exhibit:1} + s = {exhibit: 1} + class WebsiteUser(HttpLocust): _set = UserBehavior - wait_time = between(3,5) \ No newline at end of file + wait_time = between(3, 5) diff --git a/src/blog/admin.py b/src/blog/admin.py index cb2d3a08..32c0d726 100644 --- a/src/blog/admin.py +++ b/src/blog/admin.py @@ -1,6 +1,7 @@ -from blog.models import Category, Clipping, Post, PostImage from django.contrib import admin +from blog.models import Category, Clipping, Post, PostImage + admin.site.register(Category) admin.site.register(PostImage) admin.site.register(Clipping) diff --git a/src/blog/models.py b/src/blog/models.py index 20e7d4d9..a7cc490b 100644 --- a/src/blog/models.py +++ b/src/blog/models.py @@ -1,5 +1,6 @@ from django.core.files.storage import default_storage from django.db import models + from users.models import Profile IMAGE_BASE_PATH = "post_images/" diff --git a/src/blog/urls.py b/src/blog/urls.py index 124606f4..f2720390 100644 --- a/src/blog/urls.py +++ b/src/blog/urls.py @@ -1,8 +1,9 @@ # blog/urls.py -from blog import views from django.urls import path +from blog import views + urlpatterns = [ path("", views.blog_index, name="blog_index"), path("post//", views.blog_detail, name="blog_detail"), diff --git a/src/blog/views.py b/src/blog/views.py index a5ef25f4..88b3492d 100644 --- a/src/blog/views.py +++ b/src/blog/views.py @@ -1,6 +1,7 @@ -from blog.models import Category, Clipping, Post, PostStatus from django.shortcuts import render +from blog.models import Category, Clipping, Post, PostStatus + PREVIEW_SIZE = 300 PAGE_SIZE = 4 diff --git a/src/config/settings.py b/src/config/settings.py index 6c2ab9d5..2112a64e 100644 --- a/src/config/settings.py +++ b/src/config/settings.py @@ -245,5 +245,12 @@ def debug(request): SMTP_PASSWORD = env("SMTP_PASSWORD", default="password") SMTP_SENDER_MAIL = env("SMTP_SENDER_MAIL", default="jandig@memelab.com.br") +# Recaptcha +RECAPTCHA_ENABLED = env("RECAPTCHA_ENABLED", default=False) +RECAPTCHA_SITE_KEY = env("RECAPTCHA_SITE_KEY", default="") +RECAPTCHA_SECRET_KEY = env("RECAPTCHA_SECRET_KEY", default="") +RECAPTCHA_PROJECT_ID = env("RECAPTCHA_PROJECT_ID", default="") +RECAPTCHA_GCLOUD_API_KEY = env("RECAPTCHA_GCLOUD_API_KEY", default="") + if len(sys.argv) > 1 and sys.argv[1] == "test": logging.disable(logging.CRITICAL) diff --git a/src/core/admin.py b/src/core/admin.py index e5af7e08..2211979b 100644 --- a/src/core/admin.py +++ b/src/core/admin.py @@ -1,6 +1,7 @@ -from core.models import Artwork, Exhibit, Marker, Object from django.contrib import admin +from core.models import Artwork, Exhibit, Marker, Object + admin.site.register(Exhibit) admin.site.register(Object) admin.site.register(Marker) diff --git a/src/core/models.py b/src/core/models.py index 4197da51..e600e0e4 100644 --- a/src/core/models.py +++ b/src/core/models.py @@ -1,13 +1,14 @@ import logging import re -from config.storage_backends import PublicMediaStorage from django.core.files.base import ContentFile from django.db import models from django.db.models.signals import post_delete from django.dispatch import receiver from PIL import Image from pymarker.core import generate_marker_from_image, generate_patt_from_image + +from config.storage_backends import PublicMediaStorage from users.models import Profile log = logging.getLogger() diff --git a/src/core/serializers/artworks.py b/src/core/serializers/artworks.py index 30e3627d..04751a7d 100644 --- a/src/core/serializers/artworks.py +++ b/src/core/serializers/artworks.py @@ -1,6 +1,7 @@ -from core.models import Artwork from rest_framework.serializers import ModelSerializer +from core.models import Artwork + class ArtworkSerializer(ModelSerializer): class Meta: diff --git a/src/core/serializers/exhibits.py b/src/core/serializers/exhibits.py index 5981d01c..502e7272 100644 --- a/src/core/serializers/exhibits.py +++ b/src/core/serializers/exhibits.py @@ -1,6 +1,7 @@ -from core.models import Exhibit from rest_framework.serializers import ModelSerializer +from core.models import Exhibit + class ExhibitSerializer(ModelSerializer): class Meta: diff --git a/src/core/serializers/markers.py b/src/core/serializers/markers.py index 7dd53f8a..9b0ac3ae 100644 --- a/src/core/serializers/markers.py +++ b/src/core/serializers/markers.py @@ -1,6 +1,7 @@ -from core.models import Marker from rest_framework.serializers import ModelSerializer +from core.models import Marker + class MarkerSerializer(ModelSerializer): class Meta: diff --git a/src/core/serializers/objects.py b/src/core/serializers/objects.py index 0c789f25..38f7edd4 100644 --- a/src/core/serializers/objects.py +++ b/src/core/serializers/objects.py @@ -1,6 +1,7 @@ -from core.models import Object from rest_framework.serializers import ModelSerializer +from core.models import Object + class ObjectSerializer(ModelSerializer): class Meta: diff --git a/src/core/tests/test_artworks_api.py b/src/core/tests/test_artworks_api.py index 80e42996..1ff680b7 100644 --- a/src/core/tests/test_artworks_api.py +++ b/src/core/tests/test_artworks_api.py @@ -1,9 +1,10 @@ """Test using the artwork API for Jandig Artwork""" -from core.models import Artwork, Marker, Object from django.conf import settings from django.core.files.uploadedfile import SimpleUploadedFile from django.test import TestCase + +from core.models import Artwork, Marker, Object from users.models import User fake_file = SimpleUploadedFile("fake_file.png", b"these are the file contents!") diff --git a/src/core/tests/test_exhibits_api.py b/src/core/tests/test_exhibits_api.py index 7f0f9114..9bb07aec 100644 --- a/src/core/tests/test_exhibits_api.py +++ b/src/core/tests/test_exhibits_api.py @@ -1,9 +1,10 @@ """Test using the exhibit API for Jandig Exhibit""" -from core.models import Artwork, Exhibit, Marker, Object from django.conf import settings from django.core.files.uploadedfile import SimpleUploadedFile from django.test import TestCase + +from core.models import Artwork, Exhibit, Marker, Object from users.models import User fake_file = SimpleUploadedFile("fake_file.png", b"these are the file contents!") diff --git a/src/core/tests/test_markers_api.py b/src/core/tests/test_markers_api.py index 648d6dbd..79a0138c 100644 --- a/src/core/tests/test_markers_api.py +++ b/src/core/tests/test_markers_api.py @@ -1,10 +1,11 @@ """Test using the marker API for Jandig Markers""" -from core.models import Marker -from core.serializers.markers import MarkerSerializer from django.conf import settings from django.core.files.uploadedfile import SimpleUploadedFile from django.test import TestCase + +from core.models import Marker +from core.serializers.markers import MarkerSerializer from users.models import User fake_file = SimpleUploadedFile("fake_file.png", b"these are the file contents!") diff --git a/src/core/tests/test_objects_api.py b/src/core/tests/test_objects_api.py index 2a5aef3c..ae2f2d21 100644 --- a/src/core/tests/test_objects_api.py +++ b/src/core/tests/test_objects_api.py @@ -1,10 +1,11 @@ """Test using the object API for Jandig Objects""" -from core.models import Object -from core.serializers.objects import ObjectSerializer from django.conf import settings from django.core.files.uploadedfile import SimpleUploadedFile from django.test import TestCase + +from core.models import Object +from core.serializers.objects import ObjectSerializer from users.models import User fake_file = SimpleUploadedFile("fake_file.png", b"these are the file contents!") diff --git a/src/core/urls.py b/src/core/urls.py index ec5d16de..72f94734 100644 --- a/src/core/urls.py +++ b/src/core/urls.py @@ -1,3 +1,7 @@ +from django.conf import settings +from django.urls import include, path +from rest_framework_nested.routers import DefaultRouter + from core.views.artworks import ArtworkViewset from core.views.exhibits import ExhibitViewset from core.views.markers import MarkerViewset @@ -22,9 +26,6 @@ service_worker, upload_image, ) -from django.conf import settings -from django.urls import include, path -from rest_framework_nested.routers import DefaultRouter api_router = DefaultRouter() api_router.register("markers", MarkerViewset, basename="marker") diff --git a/src/core/views/artworks.py b/src/core/views/artworks.py index 2927f460..eaaea233 100644 --- a/src/core/views/artworks.py +++ b/src/core/views/artworks.py @@ -1,8 +1,9 @@ -from core.models import Artwork -from core.serializers.artworks import ArtworkSerializer from rest_framework.mixins import ListModelMixin, RetrieveModelMixin from rest_framework.viewsets import GenericViewSet +from core.models import Artwork +from core.serializers.artworks import ArtworkSerializer + class ArtworkViewset(ListModelMixin, RetrieveModelMixin, GenericViewSet): serializer_class = ArtworkSerializer diff --git a/src/core/views/exhibits.py b/src/core/views/exhibits.py index e65479d9..e3a2fe46 100644 --- a/src/core/views/exhibits.py +++ b/src/core/views/exhibits.py @@ -1,8 +1,9 @@ -from core.models import Exhibit -from core.serializers.exhibits import ExhibitSerializer from rest_framework.mixins import ListModelMixin, RetrieveModelMixin from rest_framework.viewsets import GenericViewSet +from core.models import Exhibit +from core.serializers.exhibits import ExhibitSerializer + class ExhibitViewset(ListModelMixin, RetrieveModelMixin, GenericViewSet): serializer_class = ExhibitSerializer diff --git a/src/core/views/markers.py b/src/core/views/markers.py index 95192e64..bd185f5a 100644 --- a/src/core/views/markers.py +++ b/src/core/views/markers.py @@ -1,8 +1,9 @@ -from core.models import Marker -from core.serializers.markers import MarkerSerializer from rest_framework.mixins import ListModelMixin, RetrieveModelMixin from rest_framework.viewsets import GenericViewSet +from core.models import Marker +from core.serializers.markers import MarkerSerializer + class MarkerViewset(ListModelMixin, RetrieveModelMixin, GenericViewSet): serializer_class = MarkerSerializer diff --git a/src/core/views/objects.py b/src/core/views/objects.py index 3e29e5be..e7a01f61 100644 --- a/src/core/views/objects.py +++ b/src/core/views/objects.py @@ -1,8 +1,9 @@ -from core.models import Object -from core.serializers.objects import ObjectSerializer from rest_framework.mixins import ListModelMixin, RetrieveModelMixin from rest_framework.viewsets import GenericViewSet +from core.models import Object +from core.serializers.objects import ObjectSerializer + class ObjectViewset(ListModelMixin, RetrieveModelMixin, GenericViewSet): serializer_class = ObjectSerializer diff --git a/src/core/views/views.py b/src/core/views/views.py index 8bc19e1f..5a8a745c 100644 --- a/src/core/views/views.py +++ b/src/core/views/views.py @@ -1,6 +1,3 @@ -from core.forms import ExhibitForm, UploadFileForm -from core.helpers import handle_upload_image -from core.models import Artwork, Exhibit, Marker, Object from django.core.paginator import Paginator from django.http import HttpResponseRedirect from django.shortcuts import get_object_or_404, redirect, render @@ -8,6 +5,10 @@ from django.views.decorators.cache import cache_page from django.views.decorators.http import require_http_methods +from core.forms import ExhibitForm, UploadFileForm +from core.helpers import handle_upload_image +from core.models import Artwork, Exhibit, Marker, Object + @cache_page(60 * 60) @require_http_methods(["GET"]) diff --git a/src/users/admin.py b/src/users/admin.py index ed3b70ac..42e47160 100644 --- a/src/users/admin.py +++ b/src/users/admin.py @@ -8,6 +8,7 @@ from django.http import HttpRequest from django.urls import reverse from django.utils.html import format_html + from users.models import Profile admin.site.unregister(User) diff --git a/src/users/factory.py b/src/users/factory.py index 382c92ab..fc89688a 100644 --- a/src/users/factory.py +++ b/src/users/factory.py @@ -1,7 +1,8 @@ -from core.models import Object from django.contrib.auth.models import User from factory.django import DjangoModelFactory +from core.models import Object + class UserFactory(DjangoModelFactory): username = "Testador" diff --git a/src/users/forms.py b/src/users/forms.py index 6a8cb328..1be84fae 100644 --- a/src/users/forms.py +++ b/src/users/forms.py @@ -2,7 +2,6 @@ import re from io import BytesIO -from core.models import Marker, Object from django import forms from django.contrib.auth import authenticate, get_user_model from django.contrib.auth.forms import AuthenticationForm @@ -14,6 +13,8 @@ from PIL import Image from pymarker.core import generate_marker_from_image, generate_patt_from_image +from core.models import Marker, Object + from .choices import COUNTRY_CHOICES log = logging.getLogger("ej") diff --git a/src/users/tests/test_users.py b/src/users/tests/test_users.py index 41acf9bc..a080fea6 100644 --- a/src/users/tests/test_users.py +++ b/src/users/tests/test_users.py @@ -1,6 +1,7 @@ from unittest import mock from django.test import RequestFactory, TestCase + from users.factory import UserFactory from users.services.email_service import EmailService from users.services.encrypt_service import EncryptService diff --git a/tasks.py b/tasks.py index 589bb5c6..0d82b838 100644 --- a/tasks.py +++ b/tasks.py @@ -1,7 +1,8 @@ -from invoke import task import os import sys +from invoke import task + python = sys.executable directory = os.path.dirname(__file__) sys.path.append("jandig")