Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REVIEW] 449 - Fix Linter Warning #547

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
extensions = [
]

# Add any paths that contain templates here, relative to this directory.
Expand Down Expand Up @@ -74,5 +74,6 @@
},
}


def setup(app):
app.add_css_file('reset.css')
app.add_css_file('reset.css')
18 changes: 15 additions & 3 deletions etc/scripts/compilemessages.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,17 @@ def main():
locales = set(all_locales)

for basedir in basedirs:
dirs = [os.path.join(basedir, locale, 'LC_MESSAGES') for locale in locales]
dirs = [
os.path
.join(basedir, locale, 'LC_MESSAGES') for locale in locales
]
locations = []
for ldir in dirs:
for dirpath, dirnames, filenames in os.walk(ldir):
locations.extend((dirpath, f) for f in filenames if f.endswith('.po'))
locations.extend(
(dirpath, f) for f in filenames
if f.endswith('.po')
)
compile_messages(locations)


Expand Down Expand Up @@ -65,7 +71,13 @@ def popen_wrapper(args, os_err_exc_type=RuntimeError):
Friendly wrapper around Popen.
Return stdout output, stderr output, and OS status code.
"""
with Popen(args, shell=False, stdout=PIPE, stderr=PIPE, close_fds=True) as p:
with Popen(
args,
shell=False,
stdout=PIPE,
stderr=PIPE,
close_fds=True
) as p:
output, errors = p.communicate()
return output, errors, p.returncode
raise os_err_exc_type('Error executing')
Expand Down
9 changes: 7 additions & 2 deletions locustfile.py
Original file line number Diff line number Diff line change
@@ -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)
wait_time = between(3, 5)
19 changes: 15 additions & 4 deletions src/config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,14 @@
DJANGO_ADMIN_URL = env("DJANGO_ADMIN_URL", default="admin/")
SENTRY_ENVIRONMENT = env("SENTRY_ENVIRONMENT", default="")


def traces_sampler(sampling_context):
url = sampling_context["wsgi_environ"]["PATH_INFO"]
is_health_check = url == f"/{HEALTH_CHECK_URL}"
is_django_admin = re.search(f"^/{DJANGO_ADMIN_URL.strip('/')}/*", url) is not None
is_django_admin = re.search(
f"^/{DJANGO_ADMIN_URL.strip('/')}/*",
url
) is not None
if is_health_check or is_django_admin:
return 0
return SENTRY_TRACES_SAMPLE_RATE
Expand Down Expand Up @@ -105,12 +109,13 @@ def debug(request):
ROOT_URLCONF = "config.urls"

PAGE_SIZE = 20
LIMITOFFSET_PAGINATION = "rest_framework.pagination.LimitOffsetPagination"

REST_FRAMEWORK = {
"DEFAULT_RENDERER_CLASSES": [
"rest_framework.renderers.JSONRenderer",
],
"DEFAULT_PAGINATION_CLASS": "rest_framework.pagination.LimitOffsetPagination",
"DEFAULT_PAGINATION_CLASS": LIMITOFFSET_PAGINATION,
"PAGE_SIZE": PAGE_SIZE,
}

Expand Down Expand Up @@ -217,7 +222,10 @@ def debug(request):
AWS_MEDIA_LOCATION = os.getenv("AWS_MEDIA_LOCATION", "media")
USE_MINIO = os.getenv("USE_MINIO", "false").lower() in ("true", "True", "1")
if USE_MINIO:
AWS_S3_ENDPOINT_URL = os.getenv("MINIO_S3_ENDPOINT_URL", "http://storage:9000")
AWS_S3_ENDPOINT_URL = os.getenv(
"MINIO_S3_ENDPOINT_URL",
"http://storage:9000"
)
AWS_S3_CUSTOM_DOMAIN = f"localhost:9000/{AWS_STORAGE_BUCKET_NAME}"
AWS_S3_USE_SSL = False
AWS_S3_SECURE_URLS = False
Expand Down Expand Up @@ -246,7 +254,10 @@ def debug(request):
PRIVATE_FILE_STORAGE = "config.storage_backends.PrivateMediaStorage"

AWS_PRIVATE_MEDIA_DIFFERENT_BUCKET_LOCATION = "media/private"
AWS_PRIVATE_STORAGE_BUCKET_NAME = os.getenv("AWS_PRIVATE_STORAGE_BUCKET_NAME", "")
AWS_PRIVATE_STORAGE_BUCKET_NAME = os.getenv(
"AWS_PRIVATE_STORAGE_BUCKET_NAME",
""
)
PRIVATE_FILE_DIFFERENT_BUCKET_STORAGE = "config.storage_backends.PrivateMediaStorage"

# LOGIN / LOGOUT
Expand Down
8 changes: 7 additions & 1 deletion src/config/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@
path("", include("core.urls")),
path("", include("core.routes")),
path("users/", include("users.urls")),
re_path("^docs/(?P<path>.*)$", serve, {"document_root": settings.DOCS_ROOT}),
re_path(
"^docs/(?P<path>.*)$",
serve,
{
"document_root": settings.DOCS_ROOT
}
),
]

urlpatterns += [
Expand Down
7 changes: 6 additions & 1 deletion src/config/wait_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,12 @@ def start_postgres():

def can_connect(dbname, user, password, host):
try:
psycopg2.connect(dbname=dbname, user=user, password=password, host=host)
psycopg2.connect(
dbname=dbname,
user=user,
password=password,
host=host
)
except psycopg2.OperationalError:
return False
return True
4 changes: 3 additions & 1 deletion src/core/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ class UploadFileForm(forms.Form):


class ExhibitForm(forms.Form):
exhibit = forms.ModelChoiceField(queryset=Exhibit.objects.all().order_by("name"))
exhibit = forms.ModelChoiceField(
queryset=Exhibit.objects.all().order_by("name")
)
65 changes: 53 additions & 12 deletions src/core/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,64 @@ class Migration(migrations.Migration):
migrations.CreateModel(
name='Artwork2',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=50, unique=True)),
('patt', models.CharField(default='hiro', max_length=50)),
('gif', models.CharField(default='peixe', max_length=50)),
('scale', models.CharField(default='1 1', max_length=50)),
('position', models.CharField(default='0 0 0', max_length=50)),
('rotation', models.CharField(default='270 0 0', max_length=50)),
('id', models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name='ID'
)),
('name', models.CharField(
max_length=50,
unique=True
)),
('patt', models.CharField(
default='hiro',
max_length=50
)),
('gif', models.CharField(
default='peixe',
max_length=50
)),
('scale', models.CharField(
default='1 1',
max_length=50
)),
('position', models.CharField(
default='0 0 0',
max_length=50
)),
('rotation', models.CharField(
default='270 0 0',
max_length=50
)),
],
),
migrations.CreateModel(
name='Exhibit',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=50, unique=True)),
('slug', models.CharField(max_length=50, unique=True)),
('artworks', models.ManyToManyField(related_name='exhibits', to='users.Artwork')),
('owner', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='exhibits', to='users.Profile')),
('id', models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name='ID'
)),
('name', models.CharField(
max_length=50,
unique=True
)),
('slug', models.CharField(
max_length=50,
unique=True
)),
('artworks', models.ManyToManyField(
related_name='exhibits',
to='users.Artwork'
)),
('owner', models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name='exhibits',
to='users.Profile'
)),
],
),
]
6 changes: 5 additions & 1 deletion src/core/migrations/0003_auto_20200213_1934.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name='exhibit',
name='owner',
field=models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, related_name='exhibits', to='users.Profile'),
field=models.ForeignKey(
on_delete=django.db.models.deletion.DO_NOTHING,
related_name='exhibits',
to='users.Profile'
),
),
]
81 changes: 66 additions & 15 deletions src/core/migrations/0005_fake_create_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,17 @@ class Migration(migrations.Migration):
migrations.CreateModel(
name='Artwork',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('id', models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name='ID'
)),
('title', models.CharField(max_length=50)),
('description', models.TextField(blank=True, max_length=500)),
('description', models.TextField(
blank=True,
max_length=500
)),
('created_at', models.DateTimeField(auto_now=True)),
],
options={
Expand All @@ -29,15 +37,35 @@ class Migration(migrations.Migration):
migrations.CreateModel(
name='Object',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('id', models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name='ID'
)),
('source', models.FileField(upload_to='objects/')),
('uploaded_at', models.DateTimeField(auto_now=True)),
('author', models.CharField(max_length=60)),
('title', models.CharField(default='', max_length=60)),
('scale', models.CharField(default='1 1', max_length=50)),
('position', models.CharField(default='0 0 0', max_length=50)),
('rotation', models.CharField(default='270 0 0', max_length=50)),
('owner', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to='users.Profile')),
('title', models.CharField(
default='',
max_length=60
)),
('scale', models.CharField(
default='1 1',
max_length=50
)),
('position', models.CharField(
default='0 0 0',
max_length=50
)),
('rotation', models.CharField(
default='270 0 0',
max_length=50
)),
('owner', models.ForeignKey(
on_delete=django.db.models.deletion.DO_NOTHING,
to='users.Profile'
)),
],
options={
'db_table': 'users_object',
Expand All @@ -46,13 +74,24 @@ class Migration(migrations.Migration):
migrations.CreateModel(
name='Marker',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('id', models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name='ID'
)),
('source', models.ImageField(upload_to='markers/')),
('uploaded_at', models.DateTimeField(auto_now=True)),
('author', models.CharField(max_length=60)),
('title', models.CharField(default='', max_length=60)),
('title', models.CharField(
default='',
max_length=60
)),
('patt', models.FileField(upload_to='patts/')),
('owner', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to='users.Profile')),
('owner', models.ForeignKey(
on_delete=django.db.models.deletion.DO_NOTHING,
to='users.Profile'
)),
],
options={
'db_table': 'users_marker',
Expand All @@ -61,22 +100,34 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name='exhibit',
name='artworks',
field=models.ManyToManyField(related_name='exhibits', to='core.Artwork'),
field=models.ManyToManyField(
related_name='exhibits',
to='core.Artwork'
),
),
migrations.AddField(
model_name='artwork',
name='augmented',
field=models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to='core.Object'),
field=models.ForeignKey(
on_delete=django.db.models.deletion.DO_NOTHING,
to='core.Object'
),
),
migrations.AddField(
model_name='artwork',
name='author',
field=models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to='users.Profile'),
field=models.ForeignKey(
on_delete=django.db.models.deletion.DO_NOTHING,
to='users.Profile'
),
),
migrations.AddField(
model_name='artwork',
name='marker',
field=models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to='core.Marker'),
field=models.ForeignKey(
on_delete=django.db.models.deletion.DO_NOTHING,
to='core.Marker'
),
),
],
database_operations=[]
Expand Down
Loading