diff --git a/ccvpn/settings.py b/ccvpn/settings.py index 1031e22..e3b3bf0 100644 --- a/ccvpn/settings.py +++ b/ccvpn/settings.py @@ -34,6 +34,7 @@ ALLOWED_HOSTS = [] # Application definition INSTALLED_APPS = ( + 'lvpn_admin', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', diff --git a/ccvpn/urls.py b/ccvpn/urls.py index fb052b7..19ea7bf 100644 --- a/ccvpn/urls.py +++ b/ccvpn/urls.py @@ -9,10 +9,9 @@ from lambdainst import views as account_views from . import views urlpatterns = [ - path('admin/status', account_views.admin_status, name='admin_status'), - path('admin/referrers', account_views.admin_ref, name='admin_ref'), path('admin/', admin.site.urls), path('vpn/', include(django_lcore.urls)), + path('vpnadmin/', include('lvpn_admin.urls')), path('api/locations', account_views.api_locations), path('api/auth', django_lcore.views.api_auth), diff --git a/lambdainst/views.py b/lambdainst/views.py index 9bf0ab1..517b624 100644 --- a/lambdainst/views.py +++ b/lambdainst/views.py @@ -485,73 +485,6 @@ def status(request): return render(request, "lambdainst/status.html", ctx) -@user_passes_test(lambda user: user.is_staff) -def admin_status(request): - graph_name = request.GET.get("graph_name") - graph_period = request.GET.get("period") - if graph_period not in ("y", "m"): - graph_period = "m" - if graph_name: - if graph_name == "users": - content = graphs.users_graph(graph_period) - elif graph_name == "payments_paid": - content = graphs.payments_paid_graph(graph_period) - elif graph_name == "payments_success": - content = graphs.payments_success_graph(graph_period) - else: - return HttpResponseNotFound() - return HttpResponse(content=content, content_type="image/svg+xml") - - payment_status = ((b, b.get_info()) for b in ACTIVE_BACKENDS.values()) - payment_status = ((b, i) for (b, i) in payment_status if i) - - lcore_keys = { - "core_name", - "core_now", - "core_version", - "current_instance", - "key_public", - } - - ctx = { - "api_status": { - k: str(v) for k, v in django_lcore.api.info.items() if k in lcore_keys - }, - "payment_backends": sorted( - ACTIVE_BACKENDS.values(), key=lambda x: x.backend_id - ), - "payment_status": payment_status, - } - ctx.update(site.each_context(request)) - return render(request, "lambdainst/admin_status.html", ctx) - - -@user_passes_test(lambda user: user.is_staff) -def admin_ref(request): - last_week = datetime.now() - timedelta(days=7) - last_month = datetime.now() - timedelta(days=30) - - top_ref = User.objects.annotate(n_ref=Count("referrals")).order_by("-n_ref")[:10] - top_ref_week = ( - User.objects.filter(referrals__user__date_joined__gt=last_week) - .annotate(n_ref=Count("referrals")) - .order_by("-n_ref")[:10] - ) - top_ref_month = ( - User.objects.filter(referrals__user__date_joined__gt=last_month) - .annotate(n_ref=Count("referrals")) - .order_by("-n_ref")[:10] - ) - - ctx = { - "top_ref": top_ref, - "top_ref_week": top_ref_week, - "top_ref_month": top_ref_month, - } - ctx.update(site.each_context(request)) - return render(request, "lambdainst/admin_ref.html", ctx) - - @login_required def wireguard(request): api = django_lcore.api diff --git a/poetry.lock b/poetry.lock index c31004d..33972d0 100644 --- a/poetry.lock +++ b/poetry.lock @@ -326,22 +326,26 @@ six = "*" [[package]] name = "django-lcore" -version = "1.7.1" +version = "1.8.1" description = "" category = "main" optional = false -python-versions = "*" +python-versions = ">3.6.2" develop = false [package.dependencies] -django = ">=2.2" -lcoreapi = "*" +Django = "^3.1" +django-constance = "^2.4" +django-jsonfield = "^1.3" +importlib-metadata = {version = "^1.0", markers = "python_version < \"3.8\""} +pygal = "^2.4.0" +requests = "^2.22" [package.source] type = "git" url = "https://git.packetimpact.net/lvpn/django-lcore.git" -reference = "v1.7.1" -resolved_reference = "ca88237ef938a3bc2df7937d7e921825de2b36c2" +reference = "master" +resolved_reference = "9da69a356d17119b43f72572d7c55e8e866b0b09" [[package]] name = "django-picklefield" @@ -359,11 +363,11 @@ tests = ["tox"] [[package]] name = "django-pipayments" -version = "0.2.1" +version = "0.4.2" description = "" category = "main" optional = false -python-versions = "^3.6" +python-versions = ">3.6.2" develop = false [package.dependencies] @@ -371,6 +375,7 @@ celery = "^5" Django = "^3.1" django-constance = "^2.4" django-jsonfield = "^1.3" +importlib-metadata = {version = "^1.0", markers = "python_version < \"3.8\""} python-dateutil = "^2.8.1" requests = "^2.22" stripe = "^2.40" @@ -379,7 +384,7 @@ stripe = "^2.40" type = "git" url = "git@git.packetimpact.net:lvpn/django-pipayments.git" reference = "main" -resolved_reference = "2e12a1c27bf08dcb4fc27796924a6a9b424d9ec4" +resolved_reference = "b49f063dfab9c82f656b9d0427145336626690b1" [[package]] name = "django-timezone-field" @@ -444,20 +449,18 @@ python-versions = ">=3.5" [[package]] name = "importlib-metadata" -version = "4.6.1" +version = "1.7.0" description = "Read metadata from Python packages" category = "main" optional = false -python-versions = ">=3.6" +python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7" [package.dependencies] -typing-extensions = {version = ">=3.6.4", markers = "python_version < \"3.8\""} zipp = ">=0.5" [package.extras] -docs = ["sphinx", "jaraco.packaging (>=8.2)", "rst.linker (>=1.9)"] -perf = ["ipython"] -testing = ["pytest (>=4.6)", "pytest-checkdocs (>=2.4)", "pytest-flake8", "pytest-cov", "pytest-enabler (>=1.0.1)", "packaging", "pep517", "pyfakefs", "flufl.flake8", "pytest-perf (>=0.9.2)", "pytest-black (>=0.3.7)", "pytest-mypy", "importlib-resources (>=1.3)"] +docs = ["sphinx", "rst.linker"] +testing = ["packaging", "pep517", "importlib-resources (>=1.3)"] [[package]] name = "ipython" @@ -501,7 +504,7 @@ python-versions = "*" [[package]] name = "isort" -version = "5.9.2" +version = "5.9.3" description = "A Python utility / library to sort Python imports." category = "dev" optional = false @@ -745,7 +748,7 @@ python-versions = ">=3.5" [[package]] name = "pylint" -version = "2.9.5" +version = "2.9.6" description = "python code static checker" category = "dev" optional = false @@ -1023,7 +1026,7 @@ testing = ["pytest (>=4.6)", "pytest-checkdocs (>=2.4)", "pytest-flake8", "pytes [metadata] lock-version = "1.1" python-versions = ">=3.7,<4.0" -content-hash = "5e7e869eb1d76bb7621e1653d293566a4ad761932fcc33e74c88602554c6d7f4" +content-hash = "63e605b4bd9067f7fa2b83004fcf63d1e0a8a2bfcc25c055f6003b77b54a4152" [metadata.files] amqp = [ @@ -1152,8 +1155,8 @@ idna = [ {file = "idna-3.2.tar.gz", hash = "sha256:467fbad99067910785144ce333826c71fb0e63a425657295239737f7ecd125f3"}, ] importlib-metadata = [ - {file = "importlib_metadata-4.6.1-py3-none-any.whl", hash = "sha256:9f55f560e116f8643ecf2922d9cd3e1c7e8d52e683178fecd9d08f6aa357e11e"}, - {file = "importlib_metadata-4.6.1.tar.gz", hash = "sha256:079ada16b7fc30dfbb5d13399a5113110dab1aa7c2bc62f66af75f0b717c8cac"}, + {file = "importlib_metadata-1.7.0-py2.py3-none-any.whl", hash = "sha256:dc15b2969b4ce36305c51eebe62d418ac7791e9a157911d58bfb1f9ccd8e2070"}, + {file = "importlib_metadata-1.7.0.tar.gz", hash = "sha256:90bb658cdbbf6d1735b6341ce708fc7024a3e14e99ffdc5783edea9f9b077f83"}, ] ipython = [ {file = "ipython-7.25.0-py3-none-any.whl", hash = "sha256:aa21412f2b04ad1a652e30564fff6b4de04726ce875eab222c8430edc6db383a"}, @@ -1164,8 +1167,8 @@ ipython-genutils = [ {file = "ipython_genutils-0.2.0.tar.gz", hash = "sha256:eb2e116e75ecef9d4d228fdc66af54269afa26ab4463042e33785b887c628ba8"}, ] isort = [ - {file = "isort-5.9.2-py3-none-any.whl", hash = "sha256:eed17b53c3e7912425579853d078a0832820f023191561fcee9d7cae424e0813"}, - {file = "isort-5.9.2.tar.gz", hash = "sha256:f65ce5bd4cbc6abdfbe29afc2f0245538ab358c14590912df638033f157d555e"}, + {file = "isort-5.9.3-py3-none-any.whl", hash = "sha256:e17d6e2b81095c9db0a03a8025a957f334d6ea30b26f9ec70805411e5c7c81f2"}, + {file = "isort-5.9.3.tar.gz", hash = "sha256:9c2ea1e62d871267b78307fe511c0838ba0da28698c5732d54e2790bf3ba9899"}, ] jedi = [ {file = "jedi-0.18.0-py2.py3-none-any.whl", hash = "sha256:18456d83f65f400ab0c2d3319e48520420ef43b23a086fdc05dff34132f0fb93"}, @@ -1291,8 +1294,8 @@ pygments = [ {file = "Pygments-2.9.0.tar.gz", hash = "sha256:a18f47b506a429f6f4b9df81bb02beab9ca21d0a5fee38ed15aef65f0545519f"}, ] pylint = [ - {file = "pylint-2.9.5-py3-none-any.whl", hash = "sha256:748f81e5776d6273a6619506e08f1b48ff9bcb8198366a56821cf11aac14fc87"}, - {file = "pylint-2.9.5.tar.gz", hash = "sha256:1f333dc72ef7f5ea166b3230936ebcfb1f3b722e76c980cb9fe6b9f95e8d3172"}, + {file = "pylint-2.9.6-py3-none-any.whl", hash = "sha256:2e1a0eb2e8ab41d6b5dbada87f066492bb1557b12b76c47c2ee8aa8a11186594"}, + {file = "pylint-2.9.6.tar.gz", hash = "sha256:8b838c8983ee1904b2de66cce9d0b96649a91901350e956d78f289c3bc87b48e"}, ] pylint-django = [ {file = "pylint-django-2.4.4.tar.gz", hash = "sha256:f63f717169b0c2e4e19c28f1c32c28290647330184fcb7427805ae9b6994f3fc"}, diff --git a/pyproject.toml b/pyproject.toml index 88fdfea..e6505fc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,7 +21,7 @@ psycopg2-binary = "^2.8" python-frontmatter = "^1" django-tinymce4-lite = "^1.7" django-admin-list-filter-dropdown = "^1.0" -django-lcore = {git = "https://git.packetimpact.net/lvpn/django-lcore.git", tag = "v1.7.1"} +django-lcore = {git = "https://git.packetimpact.net/lvpn/django-lcore.git"} django-pipayments = {git = "git@git.packetimpact.net:lvpn/django-pipayments.git", branch = "main"} #django-pipayments = {path = "../lvpn/django-pipayments", develop=true} celery = "^5" diff --git a/templates/admin/index.html b/templates/admin/index.html deleted file mode 100644 index e8df2cf..0000000 --- a/templates/admin/index.html +++ /dev/null @@ -1,65 +0,0 @@ -{% extends "admin/base_site.html" %} -{% load i18n static %} - -{% block extrastyle %}{{ block.super }}{% endblock %} - -{% block coltype %}colMS{% endblock %} - -{% block bodyclass %}{{ block.super }} dashboard{% endblock %} - -{% block breadcrumbs %}{% endblock %} - -{% block nav-sidebar %}{% endblock %} - -{% block content %} -
-
- - - - - - - - - - -
- {% trans 'Status' %} -
{% trans 'Status' %} 
{% trans 'Referrers Stats' %} 
-
- {% include "admin/app_list.html" with app_list=app_list show_changelinks=True %} -
-{% endblock %} - -{% block sidebar %} - -{% endblock %}