Skip to content

Commit

Permalink
Make lint
Browse files Browse the repository at this point in the history
  • Loading branch information
marcmatias committed Sep 10, 2020
1 parent 801c969 commit 1f0437c
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 10 deletions.
16 changes: 13 additions & 3 deletions brasilio/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,10 @@
"rest_framework.throttling.AnonRateThrottle",
"rest_framework.throttling.UserRateThrottle",
],
"DEFAULT_THROTTLE_RATES": {"anon": THROTTLING_RATE, "user": THROTTLING_RATE,},
"DEFAULT_THROTTLE_RATES": {
"anon": THROTTLING_RATE,
"user": THROTTLING_RATE,
},
}
)

Expand Down Expand Up @@ -234,7 +237,12 @@ def get_neo4j_config_dict(neo4j_uri):
}

# django-rq config
RQ_QUEUES = {"default": {"URL": REDIS_URL, "DEFAULT_TIMEOUT": 500,}}
RQ_QUEUES = {
"default": {
"URL": REDIS_URL,
"DEFAULT_TIMEOUT": 500,
}
}
RQ = {
"DEFAULT_RESULT_TTL": 60 * 60 * 24, # 24-hours
}
Expand All @@ -259,7 +267,9 @@ def get_neo4j_config_dict(neo4j_uri):
# Sentry config
SENTRY_DSN = env("SENTRY_DSN")
sentry_sdk.init(
SENTRY_DSN, integrations=[DjangoIntegration(), RqIntegration()], send_default_pii=True,
SENTRY_DSN,
integrations=[DjangoIntegration(), RqIntegration()],
send_default_pii=True,
)


Expand Down
3 changes: 2 additions & 1 deletion core/templatetags/endswith.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

register = template.Library()


@register.filter(name="endswith")
@stringfilter
def endswith(value, suffix):
return value.endswith(suffix)
return value.endswith(suffix)
4 changes: 3 additions & 1 deletion core/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,12 @@ def get_apoiase_donors(campain_id):
finished = len(new) < limit
return donors


@cached(cache=TTLCache(maxsize=100, ttl=24 * 3600))
def get_cached_apoiase_donors():
return get_apoiase_donors(settings.APOIASE_PROJECT_ID)


def ratelimit_key(group, request):
ip = request.META.get("HTTP_CF_CONNECTING_IP", "").strip()
if not ip:
Expand All @@ -175,4 +177,4 @@ def ratelimit_key(group, request):

agent = request.META.get("HTTP_USER_AGENT", "")
key = f"{ip}:{agent}"
return key
return key
17 changes: 12 additions & 5 deletions core/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from core.forms import ContactForm, DatasetSearchForm
from core.models import Dataset, Table
from core.templatetags.utils import obfuscate
from core.util import cached_http_get_json, get_apoiase_donors, get_cached_apoiase_donors
from core.util import cached_http_get_json, get_cached_apoiase_donors


class Echo:
Expand Down Expand Up @@ -103,7 +103,12 @@ def dataset_detail(request, slug, tablename=""):

if not tablename:
tablename = dataset.get_default_table().name
return redirect(reverse("core:dataset-table-detail", kwargs={"slug": slug, "tablename": tablename},))
return redirect(
reverse(
"core:dataset-table-detail",
kwargs={"slug": slug, "tablename": tablename},
)
)

try:
allow_hidden = request.user.is_superuser
Expand Down Expand Up @@ -154,7 +159,8 @@ def dataset_detail(request, slug, tablename=""):
writer = csv.writer(pseudo_buffer, dialect=csv.excel)
csv_rows = queryset_to_csv(all_data, fields)
response = StreamingHttpResponse(
(writer.writerow(row) for row in csv_rows), content_type="text/csv;charset=UTF-8",
(writer.writerow(row) for row in csv_rows),
content_type="text/csv;charset=UTF-8",
)
response["Content-Disposition"] = 'attachment; filename="{}"'.format(filename)
response.encoding = "UTF-8"
Expand Down Expand Up @@ -200,8 +206,9 @@ def contributors(request):
data = cached_http_get_json(url, 5)
return render(request, "contributors.html", {"contributors": data})


def donors(request):
page = request.GET.get('page', 1)
page = request.GET.get("page", 1)
paginator = Paginator(get_cached_apoiase_donors(), 25)
data = paginator.page(page)
return render(request, "donors.html", {"donors": data})
return render(request, "donors.html", {"donors": data})

0 comments on commit 1f0437c

Please sign in to comment.