shopyo-dashboard 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- shopyo_dashboard-1.0.0/PKG-INFO +13 -0
- shopyo_dashboard-1.0.0/pyproject.toml +36 -0
- shopyo_dashboard-1.0.0/setup.cfg +4 -0
- shopyo_dashboard-1.0.0/shopyo_dashboard/__init__.py +20 -0
- shopyo_dashboard-1.0.0/shopyo_dashboard/info.json +7 -0
- shopyo_dashboard-1.0.0/shopyo_dashboard/templates/shopyo_dashboard/index.html +36 -0
- shopyo_dashboard-1.0.0/shopyo_dashboard/templates/shopyo_dashboard/nav.html +0 -0
- shopyo_dashboard-1.0.0/shopyo_dashboard/view.py +68 -0
- shopyo_dashboard-1.0.0/shopyo_dashboard.egg-info/PKG-INFO +13 -0
- shopyo_dashboard-1.0.0/shopyo_dashboard.egg-info/SOURCES.txt +12 -0
- shopyo_dashboard-1.0.0/shopyo_dashboard.egg-info/dependency_links.txt +1 -0
- shopyo_dashboard-1.0.0/shopyo_dashboard.egg-info/requires.txt +1 -0
- shopyo_dashboard-1.0.0/shopyo_dashboard.egg-info/top_level.txt +2 -0
- shopyo_dashboard-1.0.0/tests/test_dashboard.py +47 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: shopyo_dashboard
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Base module containing jinja macros and templates
|
|
5
|
+
Author-email: Abdur-Rahmaan Janhangeer <arj.python@gmail.com>
|
|
6
|
+
Project-URL: Homepage, https://github.com/shopyo/shopyo
|
|
7
|
+
Project-URL: Bug Tracker, https://github.com/shopyo/shopyo/issues
|
|
8
|
+
Keywords: shopyo
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: License :: OSI Approved :: BSD License
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Requires-Python: >=3.8
|
|
13
|
+
Requires-Dist: shopyo
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "shopyo_dashboard"
|
|
3
|
+
authors = [{ name = "Abdur-Rahmaan Janhangeer", email = "arj.python@gmail.com" }]
|
|
4
|
+
description = "Base module containing jinja macros and templates"
|
|
5
|
+
# readme = "README.md"
|
|
6
|
+
requires-python = ">=3.8"
|
|
7
|
+
# license = { file = "LICENSE.txt" }
|
|
8
|
+
keywords = ["shopyo"]
|
|
9
|
+
classifiers = [
|
|
10
|
+
"Programming Language :: Python :: 3",
|
|
11
|
+
"License :: OSI Approved :: BSD License",
|
|
12
|
+
"Operating System :: OS Independent",
|
|
13
|
+
]
|
|
14
|
+
dependencies = ["shopyo"]
|
|
15
|
+
dynamic = ["version"]
|
|
16
|
+
|
|
17
|
+
[tool.setuptools.dynamic]
|
|
18
|
+
version = { attr = "shopyo_dashboard.__version__" }
|
|
19
|
+
|
|
20
|
+
[project.urls]
|
|
21
|
+
"Homepage" = "https://github.com/shopyo/shopyo"
|
|
22
|
+
"Bug Tracker" = "https://github.com/shopyo/shopyo/issues"
|
|
23
|
+
|
|
24
|
+
[build-system]
|
|
25
|
+
requires = ["setuptools>=61.0"]
|
|
26
|
+
build-backend = "setuptools.build_meta"
|
|
27
|
+
|
|
28
|
+
[tool.setuptools]
|
|
29
|
+
include-package-data = true
|
|
30
|
+
|
|
31
|
+
[tool.setuptools.packages.find]
|
|
32
|
+
where = ["."]
|
|
33
|
+
exclude = ["tests*", "docs*", "examples*"]
|
|
34
|
+
|
|
35
|
+
[tool.setuptools.package-data]
|
|
36
|
+
shopyo_dashboard = ["static/**", "templates/**", "*.json"]
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
from typing import Any
|
|
2
|
+
|
|
3
|
+
from flask import Flask
|
|
4
|
+
from shopyo_dashboard.view import module_blueprint
|
|
5
|
+
|
|
6
|
+
__version__ = "1.0.0"
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class ShopyoDashboard:
|
|
10
|
+
def __init__(self, app: Any = None) -> None:
|
|
11
|
+
if app is not None:
|
|
12
|
+
self.init_app(app)
|
|
13
|
+
|
|
14
|
+
def init_app(self, app: Flask) -> None:
|
|
15
|
+
if not hasattr(app, "extensions"):
|
|
16
|
+
app.extensions = {}
|
|
17
|
+
|
|
18
|
+
app.extensions["shopyo_dashboard"] = self
|
|
19
|
+
bp = module_blueprint
|
|
20
|
+
app.register_blueprint(bp)
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{% extends "shopyo_base/main_base.html" %}
|
|
2
|
+
|
|
3
|
+
{% set active_page ='control panel' %}
|
|
4
|
+
|
|
5
|
+
{% block pagehead %}
|
|
6
|
+
<title></title>
|
|
7
|
+
<link rel="stylesheet" href="/static/fontawesome/css/all.css">
|
|
8
|
+
<style>
|
|
9
|
+
|
|
10
|
+
</style>
|
|
11
|
+
{% endblock %}
|
|
12
|
+
|
|
13
|
+
{% block content %}
|
|
14
|
+
{% include 'shopyo_dashboard/nav.html' %}
|
|
15
|
+
|
|
16
|
+
<br>
|
|
17
|
+
|
|
18
|
+
{% for info in all_info %}
|
|
19
|
+
{% if all_info[info]['type'] == 'show'%}
|
|
20
|
+
{%if 'dashboard' in all_info[info]%}
|
|
21
|
+
<a class="shopyo-link" href="{{all_info[info]['url_prefix'] + all_info[info]['dashboard']}}">
|
|
22
|
+
{%else%}
|
|
23
|
+
<a class="shopyo-link" href="{{all_info[info]['url_prefix']}}">
|
|
24
|
+
{%endif%}
|
|
25
|
+
<div class="shopyo-dashboard-card card card-menu">
|
|
26
|
+
<div class="shopyo-dashboard-card-body card-body text-center">
|
|
27
|
+
<i class="shopyo-dashboard-card-menu card-menu-icon {{all_info[info]['fa-icon']}}"></i>
|
|
28
|
+
</div>
|
|
29
|
+
<div class="shopyo-dashboard-card-footer card-footer">
|
|
30
|
+
{{all_info[info]['display_string']}}
|
|
31
|
+
</div>
|
|
32
|
+
</div>
|
|
33
|
+
</a>
|
|
34
|
+
{% endif %}
|
|
35
|
+
{% endfor %}
|
|
36
|
+
{% endblock %}
|
|
File without changes
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import os
|
|
3
|
+
|
|
4
|
+
from flask import current_app
|
|
5
|
+
from flask import flash
|
|
6
|
+
from flask import render_template
|
|
7
|
+
from flask_login import login_required
|
|
8
|
+
from shopyo_appadmin.admin import admin_required
|
|
9
|
+
from shopyo_auth.decorators import check_confirmed
|
|
10
|
+
|
|
11
|
+
from shopyo.api.html import notify_success
|
|
12
|
+
from shopyo.api.module import ModuleHelp
|
|
13
|
+
|
|
14
|
+
mhelp = ModuleHelp(__file__, __name__)
|
|
15
|
+
globals()[mhelp.blueprint_str] = mhelp.blueprint
|
|
16
|
+
module_blueprint = globals()[mhelp.blueprint_str]
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
all_info = {}
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
@module_blueprint.route("/")
|
|
23
|
+
@login_required
|
|
24
|
+
@check_confirmed
|
|
25
|
+
@admin_required
|
|
26
|
+
def index():
|
|
27
|
+
context = {}
|
|
28
|
+
|
|
29
|
+
for folder in os.listdir(os.path.join(current_app.config["BASE_DIR"], "modules")):
|
|
30
|
+
if folder.startswith("__"):
|
|
31
|
+
continue
|
|
32
|
+
elif folder.startswith("box__"):
|
|
33
|
+
for sub_folder in os.listdir(
|
|
34
|
+
os.path.join(current_app.config["BASE_DIR"], "modules", folder)
|
|
35
|
+
):
|
|
36
|
+
if sub_folder in ["dashboard"]:
|
|
37
|
+
continue
|
|
38
|
+
if sub_folder.startswith("__"): # ignore __pycache__
|
|
39
|
+
continue
|
|
40
|
+
elif sub_folder.endswith(".json"): # box_info.json
|
|
41
|
+
continue
|
|
42
|
+
with open(
|
|
43
|
+
os.path.join(
|
|
44
|
+
current_app.config["BASE_DIR"],
|
|
45
|
+
"modules",
|
|
46
|
+
folder,
|
|
47
|
+
sub_folder,
|
|
48
|
+
"info.json",
|
|
49
|
+
)
|
|
50
|
+
) as f:
|
|
51
|
+
module_info = json.load(f)
|
|
52
|
+
all_info[sub_folder] = module_info
|
|
53
|
+
else:
|
|
54
|
+
if folder not in ["dashboard"]:
|
|
55
|
+
with open(
|
|
56
|
+
os.path.join(
|
|
57
|
+
current_app.config["BASE_DIR"],
|
|
58
|
+
"modules",
|
|
59
|
+
folder,
|
|
60
|
+
"info.json",
|
|
61
|
+
)
|
|
62
|
+
) as f:
|
|
63
|
+
module_info = json.load(f)
|
|
64
|
+
all_info[folder] = module_info
|
|
65
|
+
|
|
66
|
+
context["all_info"] = all_info
|
|
67
|
+
flash(notify_success("Notif test"))
|
|
68
|
+
return render_template("shopyo_dashboard/index.html", **context)
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: shopyo_dashboard
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Base module containing jinja macros and templates
|
|
5
|
+
Author-email: Abdur-Rahmaan Janhangeer <arj.python@gmail.com>
|
|
6
|
+
Project-URL: Homepage, https://github.com/shopyo/shopyo
|
|
7
|
+
Project-URL: Bug Tracker, https://github.com/shopyo/shopyo/issues
|
|
8
|
+
Keywords: shopyo
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: License :: OSI Approved :: BSD License
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Requires-Python: >=3.8
|
|
13
|
+
Requires-Dist: shopyo
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
pyproject.toml
|
|
2
|
+
shopyo_dashboard/__init__.py
|
|
3
|
+
shopyo_dashboard/info.json
|
|
4
|
+
shopyo_dashboard/view.py
|
|
5
|
+
shopyo_dashboard.egg-info/PKG-INFO
|
|
6
|
+
shopyo_dashboard.egg-info/SOURCES.txt
|
|
7
|
+
shopyo_dashboard.egg-info/dependency_links.txt
|
|
8
|
+
shopyo_dashboard.egg-info/requires.txt
|
|
9
|
+
shopyo_dashboard.egg-info/top_level.txt
|
|
10
|
+
shopyo_dashboard/templates/shopyo_dashboard/index.html
|
|
11
|
+
shopyo_dashboard/templates/shopyo_dashboard/nav.html
|
|
12
|
+
tests/test_dashboard.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
shopyo
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"""
|
|
2
|
+
This file (test_login.py) contains the functional tests for
|
|
3
|
+
the `login` blueprint.
|
|
4
|
+
|
|
5
|
+
These tests use GETs and POSTs to different endpoints to check
|
|
6
|
+
for the proper behavior of the `login` blueprint.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import pytest
|
|
10
|
+
from flask import request
|
|
11
|
+
from flask import url_for
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# class TestDashboardInvalidAccess:
|
|
15
|
+
# """
|
|
16
|
+
# Test all dashboard routes for correct user authentication
|
|
17
|
+
# """
|
|
18
|
+
|
|
19
|
+
# routes_get = [
|
|
20
|
+
# "/dashboard/",
|
|
21
|
+
# ]
|
|
22
|
+
|
|
23
|
+
# @pytest.mark.parametrize("route", routes_get)
|
|
24
|
+
# def test_redirect_if_not_logged_in_get(self, test_client, route, auth):
|
|
25
|
+
# auth.logout()
|
|
26
|
+
# response = test_client.get(route, follow_redirects=True)
|
|
27
|
+
|
|
28
|
+
# assert response.status_code == 200
|
|
29
|
+
# assert request.path == url_for("shopyo_auth.login")
|
|
30
|
+
|
|
31
|
+
# @pytest.mark.usefixtures("login_unconfirmed_user")
|
|
32
|
+
# @pytest.mark.parametrize("route", routes_get)
|
|
33
|
+
# def test_redirect_if_email_not_confirmed(self, test_client, route):
|
|
34
|
+
# response = test_client.get(route, follow_redirects=True)
|
|
35
|
+
|
|
36
|
+
# assert response.status_code == 200
|
|
37
|
+
# assert request.path == url_for("auth.unconfirmed")
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
# @pytest.mark.usefixtures("login_non_admin_user")
|
|
41
|
+
# class TestDashboardEndpoints:
|
|
42
|
+
# def test_confirmed_user_can_view_dashboard(self, test_client):
|
|
43
|
+
# response = test_client.get("/dashboard/", follow_redirects=True)
|
|
44
|
+
|
|
45
|
+
# assert response.status_code == 200
|
|
46
|
+
# assert b"Control panel" in response.data
|
|
47
|
+
# assert b"Notif test" in response.data
|