-
-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into bug/299-anonymous-invoice
- Loading branch information
Showing
54 changed files
with
2,103 additions
and
219 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,38 @@ | ||
repos: | ||
- repo: https://github.com/psf/black | ||
- repo: https://github.com/psf/black | ||
rev: 24.3.0 | ||
entry: black --check --diff | ||
hooks: | ||
- id: black | ||
- repo: local | ||
hooks: | ||
- id: pre-commit-django-migrations | ||
name: Check django migrations | ||
entry: python manage.py makemigrations --dry-run --check --no-input | ||
language: system | ||
types: [python] | ||
pass_filenames: false | ||
- repo: local | ||
hooks: | ||
- id: pre-commit-djlint | ||
name: Djlint (html files) | ||
entry: djlint . --check --profile=django | ||
language: system | ||
types: [python] | ||
pass_filenames: false | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
- id: black | ||
- repo: local | ||
hooks: | ||
- id: pre-commit-django-migrations | ||
name: Check django migrations | ||
entry: python manage.py makemigrations --dry-run --check --no-input | ||
language: system | ||
types: [ python ] | ||
pass_filenames: false | ||
- repo: local | ||
hooks: | ||
- id: pre-commit-djlint | ||
name: Djlint (html files) | ||
entry: djlint . --profile django --check | ||
language: system | ||
types: [ python ] | ||
pass_filenames: false | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.5.0 | ||
hooks: | ||
- id: trailing-whitespace | ||
- id: end-of-file-fixer | ||
- id: check-yaml | ||
- id: debug-statements | ||
- id: name-tests-test | ||
- repo: https://github.com/asottile/setup-cfg-fmt | ||
- id: trailing-whitespace | ||
- id: end-of-file-fixer | ||
- id: debug-statements | ||
- id: name-tests-test | ||
- repo: https://github.com/asottile/setup-cfg-fmt | ||
rev: v2.5.0 | ||
hooks: | ||
- id: setup-cfg-fmt | ||
- repo: https://github.com/asottile/reorder-python-imports | ||
rev: v3.12.0 | ||
hooks: | ||
- id: reorder-python-imports | ||
exclude: ^(pre_commit/resources/|testing/resources/python3_hooks_repo/) | ||
args: [--py39-plus, --add-import, 'from __future__ import annotations'] | ||
- repo: https://github.com/asottile/pyupgrade | ||
- id: setup-cfg-fmt | ||
- repo: https://github.com/asottile/pyupgrade | ||
rev: v3.15.2 | ||
hooks: | ||
- id: pyupgrade | ||
args: [--py39-plus] | ||
- id: pyupgrade | ||
args: [ --py39-plus ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from django.contrib import messages | ||
from django.core.paginator import Paginator | ||
from django.db.models import Q | ||
from django.http import HttpRequest, HttpResponse | ||
from django.shortcuts import render, redirect | ||
from django_ratelimit.core import is_ratelimited | ||
from django_ratelimit.decorators import ratelimit | ||
|
||
from backend.models import EmailSendStatus | ||
|
||
|
||
def fetch_all_emails(request: HttpRequest): | ||
if is_ratelimited(request, group="fetch_all_emails", key="user", rate="2/4s", increment=True) or is_ratelimited( | ||
request, | ||
group="fetch_all_emails", | ||
key="user", | ||
rate="5/10s", | ||
increment=True or is_ratelimited(request, group="fetch_all_emails", key="user", rate="20/2m", increment=True), | ||
): | ||
return HttpResponse(status=429) | ||
context = {} | ||
if not request.htmx: | ||
return redirect("quotas") | ||
|
||
search_text = request.GET.get("search") | ||
page_num = request.GET.get("page") | ||
|
||
if request.user.logged_in_as_team: | ||
results = EmailSendStatus.objects.filter(organization=request.user.logged_in_as_team) | ||
else: | ||
results = EmailSendStatus.objects.filter(user=request.user) | ||
|
||
if search_text: | ||
results = results.filter(Q(recipient__icontains=search_text)) | ||
|
||
results = results.order_by("-id") | ||
|
||
paginator = Paginator(results, 8) | ||
results = paginator.get_page(page_num) | ||
|
||
context.update({"emails": results}) | ||
return render(request, "pages/emails/_fetch_body.html", context) |
Oops, something went wrong.